Skip to content

Adding tool response in running tool spans #2081

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

Closed
wants to merge 4 commits into from

Conversation

adtyavrdhn
Copy link
Contributor

Fixes #2004

@adtyavrdhn adtyavrdhn changed the title [WIP] Adding tool response in running tool spans Adding tool response in running tool spans Jun 26, 2025
current_span = get_current_span()
if current_span.is_recording() and include_content:
current_span.set_attribute(
'gen_ai.tool.call.response',
Copy link
Contributor Author

@adtyavrdhn adtyavrdhn Jun 26, 2025

Choose a reason for hiding this comment

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

https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/

I could not find an attribute for tool response so went with this for now

if current_span.is_recording() and include_content:
current_span.set_attribute(
'gen_ai.tool.call.response',
response_content if isinstance(response_content, str) else str(response_content),
Copy link
Contributor Author

@adtyavrdhn adtyavrdhn Jun 26, 2025

Choose a reason for hiding this comment

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

Unsure about this part, should we retain the type of the tool response? Does that serve any useful case?

We could also have a helper function check against AttributeValue and fallback to str().

@adtyavrdhn
Copy link
Contributor Author

Hi @alexmojaki. I would appreciate it if could take a look.

@alexmojaki
Copy link
Contributor

Hi @adtyavrdhn, thanks for giving this a go. The ideas were right but there were enough details that I felt iffy about that it seemed easier to just open #2109 instead.

@alexmojaki alexmojaki closed this Jul 1, 2025
@adtyavrdhn
Copy link
Contributor Author

No problem, thanks for taking the time :)

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