Repository navigation
fix(py/otel): serialize Pydantic tool call arguments as valid JSON - #39
Merged
Merged
Conversation
huangjeff5
force-pushed
the
fix/py-otel-tool-call-arguments-json
branch
from
November 9, 2026 19:07
6dee8a0 to
c6369bb
Compare
cabljac
reviewed
Nov 10, 2026
cabljac
left a comment
Contributor
There was a problem hiding this comment.
A few comments/questions
huangjeff5
force-pushed
the
fix/py-otel-tool-call-arguments-json
branch
from
November 10, 2026 19:35
c8fa6b2 to
1fc198f
Compare
huangjeff5
enabled stacked auto-merge (squash)
November 10, 2026 20:42
huangjeff5
force-pushed
the
fix/py-otel-tool-call-arguments-json
branch
from
November 11, 2026 06:23
1fc198f to
fa849bd
Compare
genkit:input / genkit:output in core use model_dump_json(by_alias=True, exclude_none=True). The tool call encoder dumped Python field names and nulls, so the same object read differently on two attributes of one trace and disagreed with the arguments the model actually sent.
_encode_json_value returned str values unchanged, so a tool taking order_id: str wrote ORD-555 raw into gen_ai.tool.call.arguments and json.loads failed downstream. Encode strings like every other value, matching JS JSON.stringify. (BR-01)
huangjeff5
force-pushed
the
fix/py-otel-tool-call-arguments-json
branch
from
November 11, 2026 14:37
fa849bd to
6e2f115
Compare
stacked auto-merge was automatically disabled
November 11, 2026 14:38
Replaced by a newer auto-merge request
huangjeff5
enabled stacked auto-merge (squash)
November 11, 2026 14:38
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.
OpenTelemetry tool spans and events now serialize Pydantic arguments and results as JSON. Before,
json.dumps(..., default=str)fell back tostr(model), sogen_ai.tool.call.argumentsheld Pydantic's field string instead of parseable JSON.Changes
_encode_json_valuedumpsBaseModelinstances, including ones nested in lists and dicts, viamodel_dump(mode='json', by_alias=True, exclude_none=True)so keys match what the model sent. Other non-JSON values still fall back tostr().gen_ai.tool.call.argumentsandgen_ai.tool.call.resulton spans and on the operation-details log event, plusgenkit:input/genkit:outputwhencapture_action_io=True.strthrough raw while the log event encoded it. Now both writeORD-555as"ORD-555", so every JSON attribute round-trips throughjson.loads.Breaking changes
None.
Cross-SDK
Python traces now carry
gen_ai.tool.call.arguments/gen_ai.tool.call.resultas standard JSON instead of a Python string form, so Dev UI and OTel backends can parse them. No action needed for JS, Go, or Dart owners.