Repository navigation
Conversation
MessagesSnapshotEvent tool calls are ag_ui.core.ToolCall objects, which store the name and arguments under `function` (arguments as a JSON string). Reading `tc.name` / `tc.args` always fell back to the defaults, so every tool call reconstructed from a snapshot came back as name='unknown_tool' with empty args.
|
Thanks for catching this and putting together the fix. As the author of the original AG-UI integration (#2395), I support this PR as the resolution for #3010. I reproduced the loss of tool names and arguments, then locally validated the exact patch at Validation results:
Between this PR and #3047, I prefer this smaller, focused change. It handles the supported nested schema without additional flat-format compatibility branches, preserves the It would be useful to include the round-trip and argument edge cases in the committed tests as well. My validation was scoped to the AG-UI integration, not the full repository suite. @anistark — you helped review and merge the original integration. Could you take a look when you have a chance, or point us to the current maintainer for this area? — Mark |
|
Thanks @contextablemark — glad this shape won out, and thanks for the explicit preference over #3047. Pushed
All 7 new tests fail against the pre-fix reader with the |
|
Thanks for adding the regression coverage in The added round-trip, multiple-call, metadata, nested/Unicode, empty-argument, malformed-JSON, and non-object-JSON cases address my earlier suggestion. The runtime fix is unchanged, and I continue to support #3011 as the resolution for #3010. For clarity, I’m the author of the original AG-UI integration, not a Ragas maintainer; this is contributor validation, not merge approval. The project appears to have stalled on the maintenance side: the latest merge I could verify was February 24, 2026, with no merges in the last 90 days, despite continued contributor activity. I can’t tell whether that reflects a pause or a change in ownership. The outstanding I hope a current maintainer can pick this up. Thanks again for following through. — Mark |
|
Up to date with |
Issue Link / Problem Description
convert_messages_snapshot()rebuilt tool calls from aMessagesSnapshotEventby readingtc.name/tc.argsthroughgetattr(..., default), butag_ui.core.ToolCallhas neither: the name and the (JSON-string) arguments live underToolCall.function. Bothgetattrcalls therefore always returned their defaults, so every tool call recovered from a snapshot came back asToolCall(name='unknown_tool', args={})with the real tool name and arguments discarded.Changes Made
src/ragas/integrations/ag_ui.py—AGUIEventCollector._handle_messages_snapshot(line 636): readname/argumentsfrom the nestedfunctionobject, andjson.loadstheargumentsstring. Empty arguments become{}. A string that is not valid JSON keeps the existing{"raw_args": ...}fallback already used by the streaming path (_handle_tool_call_end, line 406).tests/unit/integrations/test_ag_ui.py— new regression testtest_messages_snapshot_preserves_tool_call_name_and_argsasserting that a snapshot tool call converts toToolCall(name="get_weather", args={"city": "SF"}).The writer in the same file (
convert_messages_to_ag_ui, line 915) already emits the nestedFunctionCall(name=..., arguments=json.dumps(...))shape, so a Ragas → AG-UI → Ragas round-trip now preserves tool names and arguments.Testing
How to Test
The new test fails on
mainand passes with the fix:Lint/format (per the
Makefilerun-ci-format-check/run-ci-checktargets):Types:
pyright -p pyproject.toml srcreports no findings insrc/ragas/integrations/ag_ui.py. The 20 errors it reports elsewhere are present onmaintoo and are unchanged by this PR.Note:
-p no:phoenixis only needed in this local virtualenv, where thearize-phoenixpytest plugin fails to import (ModuleNotFoundError: No module named 'phoenix.evals.models'); it is unrelated to this change.Behaviour before / after
References
_handle_tool_call_end(src/ragas/integrations/ag_ui.py:406) already parsesfunction.argumentsJSON on the streaming path;convert_messages_to_ag_ui(src/ragas/integrations/ag_ui.py:915) already writes the nested shape.ag-ui-protocolToolCall/FunctionCallmodels (ag_ui.core).Screenshots/Examples (if applicable)
Not applicable — no UI change.