Skip to content

Record tool response in tool run span #2109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2025
Merged

Conversation

alexmojaki
Copy link
Contributor

Closes #2004

Copy link

@Copilot 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 ensures that the tool response is recorded within the tool run span, addressing issue #2004.

  • Updated tests to assert a more comprehensive snapshot of tool attributes when content is included.
  • Modified the tool execution flow in the tools module to capture and record the tool response in the current trace span.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/test_logfire.py Updated snapshot assertions to check additional tool fields
pydantic_ai_slim/pydantic_ai/tools.py Revised span handling to record the tool response within the span
Comments suppressed due to low confidence (1)

tests/test_logfire.py:548

  • [nitpick] The updated snapshot assertion now compares multiple keys. Please ensure that dynamic fields like 'gen_ai.tool.call.id' and the JSON schema remain stable across test runs and consider adding comments to clarify the expected snapshot structure.
    assert result.output == snapshot('{"add_numbers":84}')

Copy link

github-actions bot commented Jul 1, 2025

Docs Preview

commit: 40324fa
Preview URL: https://62ad36fa-pydantic-ai-previews.pydantic.workers.dev

@alexmojaki alexmojaki requested a review from DouweM July 1, 2025 16:43
@DouweM
Copy link
Contributor

DouweM commented Jul 1, 2025

@alexmojaki Thanks, makes sense, approved!

@alexmojaki alexmojaki merged commit 5b94841 into main Jul 1, 2025
18 checks passed
@alexmojaki alexmojaki deleted the alex/tool-response branch July 1, 2025 19:30
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.

Show tool response in the running tool span
2 participants