Conversation
lmolkova
force-pushed
the
tool-any-value
branch
from
October 1, 2026 01:49
1849a15 to
65a24dc
Compare
Pull request dashboard statusWaiting on reviewers · refreshed 2026-10-04 17:33 UTC Review the latest changes. Status above doesn't look right?
|
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The serializer can bypass sanitization and emit invalid JSON for non-finite floats.
Review effort: Balanced
Findings: 1
What changed in this PR
Centralizes tool and prompt-value normalization in opentelemetry-util-genai, then adopts it across six instrumentations.
Changes:
- Adds reusable object-to-
AnyValueconversion. - Standardizes tool arguments/results as compact JSON.
- Fixes LangChain result capture without a tool-call ID.
| File | Description |
|---|---|
util/opentelemetry-util-genai/tests/test_utils.py |
Tests conversion and prompt variables. |
util/opentelemetry-util-genai/tests/test_toolcall.py |
Tests tool attribute serialization. |
util/opentelemetry-util-genai/tests/test_stream.py |
Tests streamed model conversion. |
util/opentelemetry-util-genai/src/opentelemetry/util/genai/utils.py |
Adds conversion utilities. |
util/opentelemetry-util-genai/src/opentelemetry/util/genai/stream.py |
Converts streamed tool results. |
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_tool_invocation.py |
Centralizes tool serialization. |
util/opentelemetry-util-genai/src/opentelemetry/util/genai/_invocation.py |
Serializes prompt/tool values. |
util/opentelemetry-util-genai/.changelog/821.changed |
Documents changed serialization. |
util/opentelemetry-util-genai/.changelog/821.added |
Documents new utilities. |
instrumentation/opentelemetry-instrumentation-google-genai/tests/utils/test_tool_call_wrapper.py |
Updates conversion tests. |
instrumentation/opentelemetry-instrumentation-google-genai/tests/requirements.oldest.txt |
Uses local updated util. |
instrumentation/opentelemetry-instrumentation-google-genai/src/opentelemetry/instrumentation/google_genai/tool_call_wrapper.py |
Uses shared conversion. |
instrumentation/opentelemetry-instrumentation-google-genai/pyproject.toml |
Raises util dependency floor. |
instrumentation/opentelemetry-instrumentation-google-genai/.changelog/821.changed |
Documents tool capture changes. |
instrumentation/opentelemetry-instrumentation-genai-qwen-agent/tests/test_tool.py |
Updates compact JSON expectation. |
instrumentation/opentelemetry-instrumentation-genai-qwen-agent/tests/requirements.oldest.txt |
Uses local updated util. |
instrumentation/opentelemetry-instrumentation-genai-qwen-agent/src/opentelemetry/instrumentation/genai/qwen_agent/patch.py |
Converts tool values consistently. |
instrumentation/opentelemetry-instrumentation-genai-qwen-agent/pyproject.toml |
Raises util dependency floor. |
instrumentation/opentelemetry-instrumentation-genai-qwen-agent/.changelog/821.changed |
Documents serialization changes. |
instrumentation/opentelemetry-instrumentation-genai-qwen-agent/.changelog/.gitignore |
Preserves changelog directory. |
instrumentation/opentelemetry-instrumentation-genai-openai-agents/tests/test_processor.py |
Expands JSON argument cases. |
instrumentation/opentelemetry-instrumentation-genai-openai-agents/tests/requirements.oldest.txt |
Uses local updated util. |
instrumentation/opentelemetry-instrumentation-genai-openai-agents/src/opentelemetry/instrumentation/genai/openai_agents/processor.py |
Uses shared tool conversion. |
instrumentation/opentelemetry-instrumentation-genai-openai-agents/pyproject.toml |
Raises util dependency floor. |
instrumentation/opentelemetry-instrumentation-genai-openai-agents/.changelog/821.changed |
Documents normalized arguments. |
instrumentation/opentelemetry-instrumentation-genai-llama-index/tests/test_agent.py |
Updates numeric result expectation. |
instrumentation/opentelemetry-instrumentation-genai-llama-index/tests/requirements.oldest.txt |
Uses local updated util. |
instrumentation/opentelemetry-instrumentation-genai-llama-index/src/opentelemetry/instrumentation/genai/llama_index/_handler.py |
Converts tool inputs and outputs. |
instrumentation/opentelemetry-instrumentation-genai-llama-index/pyproject.toml |
Raises util dependency floor. |
instrumentation/opentelemetry-instrumentation-genai-llama-index/.changelog/821.changed |
Documents result serialization. |
instrumentation/opentelemetry-instrumentation-genai-langchain/tests/test_tools.py |
Tests results with/without IDs. |
instrumentation/opentelemetry-instrumentation-genai-langchain/tests/requirements.oldest.txt |
Uses local updated util. |
instrumentation/opentelemetry-instrumentation-genai-langchain/src/opentelemetry/instrumentation/genai/langchain/callback_handler.py |
Preserves raw tool results. |
instrumentation/opentelemetry-instrumentation-genai-langchain/pyproject.toml |
Raises util dependency floor. |
instrumentation/opentelemetry-instrumentation-genai-langchain/.changelog/821.fixed |
Documents result-capture fix. |
instrumentation/opentelemetry-instrumentation-genai-dspy/tests/test_tools.py |
Updates numeric result expectations. |
instrumentation/opentelemetry-instrumentation-genai-dspy/tests/requirements.oldest.txt |
Uses local updated util. |
instrumentation/opentelemetry-instrumentation-genai-dspy/src/opentelemetry/instrumentation/genai/dspy/patch.py |
Converts tool inputs and outputs. |
instrumentation/opentelemetry-instrumentation-genai-dspy/pyproject.toml |
Raises util dependency floor. |
instrumentation/opentelemetry-instrumentation-genai-dspy/.changelog/821.changed |
Documents result serialization. |
instrumentation/opentelemetry-instrumentation-genai-agno/tests/test_tools.py |
Updates compact JSON expectations. |
instrumentation/opentelemetry-instrumentation-genai-agno/tests/test_agent.py |
Updates structured-result tests. |
instrumentation/opentelemetry-instrumentation-genai-agno/tests/requirements.oldest.txt |
Uses local updated util. |
instrumentation/opentelemetry-instrumentation-genai-agno/src/opentelemetry/instrumentation/genai/agno/utils.py |
Reuses shared conversion. |
instrumentation/opentelemetry-instrumentation-genai-agno/src/opentelemetry/instrumentation/genai/agno/patch.py |
Captures structured tool values. |
instrumentation/opentelemetry-instrumentation-genai-agno/pyproject.toml |
Raises util dependency floor. |
instrumentation/opentelemetry-instrumentation-genai-agno/.changelog/821.changed |
Documents compact JSON output. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
7 of 11 tasks
rads-1996
reviewed
Oct 1, 2026
…attributes Assisted-by: Claude Opus 5
…values Assisted-by: Claude Opus 5
…kip LangChain conversion when not capturing Assisted-by: Claude Opus 5
…test Assisted-by: Claude Opus 4.6
lmolkova
force-pushed
the
tool-any-value
branch
from
October 4, 2026 17:04
0f3db9b to
277b5c9
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Adds
object_to_any_valuetoopentelemetry-util-genaiand uses it for tool call arguments, tool call results and prompt variables. Also fixes LangChain dropping the tool result when a tool runs without a tool call id.Each instrumentation converted tool values its own way, so the same result could show up as
str()output, spaced JSON or a raw primitive. Now the conversion lives in one place, and a value that can't be converted is dropped on its own instead of taking the whole attribute with it. Prompt variables go through the same conversion, and a variable set toNoneis no longer recorded as"null".Non-string values are now always recorded as compact JSON, so
42becomes"42". Tool call arguments and results areanyin semconv and we serialize every non-string value to JSON on spans, so primitives follow the same rule.Next step is recording these as complex attributes, which OpenTelemetry Python supports on spans since 1.45. Then the
AnyValuegoes on the span as is and no JSON serialization is needed.