Skip to content

Invoke Agent wrapper span populates tool-call turns and gen_ai.tool.definitions#174

Merged
rads-1996 merged 4 commits into
microsoft:mainfrom
rads-1996:fix-invoke-agent
May 28, 2026
Merged

Invoke Agent wrapper span populates tool-call turns and gen_ai.tool.definitions#174
rads-1996 merged 4 commits into
microsoft:mainfrom
rads-1996:fix-invoke-agent

Conversation

@rads-1996
Copy link
Copy Markdown
Member

Fixes #172

Copilot AI review requested due to automatic review settings May 28, 2026 20:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #172 by improving LangChain invoke_agent span aggregation so wrapper spans can carry ordered ReAct-style message history and tool definitions.

Changes:

  • Adds LangChain utilities for tool-call response extraction, role normalization, tuple shorthand handling, and agent-history building.
  • Updates agent span aggregation to build cumulative input history from LLM/tool child runs and defer final assistant output until finalization.
  • Updates and expands LangChain tests for spec-compliant message extraction and aggregation behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/microsoft/opentelemetry/_genai/_langchain/_utils.py Adds message/tool-response helpers and improves role/message extraction.
src/microsoft/opentelemetry/_genai/_langchain/_tracer.py Aggregates invoke-agent input history, final output messages, and tool definitions.
tests/langchain/test_utils.py Updates session assertions and adds structured message extraction tests.
tests/langchain/test_tracer.py Updates tool-output behavior tests and adds aggregation/tool-definition tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/microsoft/opentelemetry/_genai/_langchain/_utils.py
Comment thread src/microsoft/opentelemetry/_genai/_langchain/_tracer.py
@rads-1996 rads-1996 changed the title Fix invoke agent Invoke Agent wrapper span populates tool-call turns and gen_ai.tool.definitions May 28, 2026
@rads-1996 rads-1996 merged commit 52a2350 into microsoft:main May 28, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

invoke_agent wrapper span omits tool-call turns and gen_ai.tool.definitions, violating GenAI semconv

4 participants