Repository navigation
fix(gaia-agent): report tools_used in _usage_from_result on unprinted turns - #7265
Merged
Merged
Conversation
model_messages replays the session's earlier turns, so counting its tool results reported tools from previous turns as this one's. Without the turn's own conversation, the stream handler's count for the turn is used. Adds the flagship changelog entry for the fix.
Collaborator
|
Thanks @txltedxgod, this is a clean fix for #7262, and the wire-format tests made it easy to check. I pushed one follow-up commit to your branch: without the turn's own
🔍 Technical details
|
Merged
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.
Summary
Include
tools_usedin_usage_from_resultinsidehub/agents/gaia/python/gaia_agent/stdio.pyso turns that return without printing ananswerevent (such as error exits and step-limit exits whose closing summary fails) still report their executed tool call count infinal["usage"].Why
Without a printed
answerevent, non-verbosegaia -prelies exclusively onfinal["usage"]to populatenum_tool_calls. Because_usage_from_resultpreviously extracted onlysteps,input_tokens,tokens, andcached_tokens, non-verbose error turns always recorded0tool calls even when tools had executed before the failure.Linked issue
Closes #7262
Changes
_tool_count_from_result(value, fallback=...)inhub/agents/gaia/python/gaia_agent/stdio.pyto resolvetools_usedfrom an explicittools_usedinteger, else countrole == "tool"entries in this turn'sconversation, falling back tohandler._tool_count(nevermodel_messages, which replays earlier turns) while keeping the omit-when-zero rule._usage_from_resultand itsrun_turncall site to passtool_count=getattr(handler, "_tool_count", 0)and includetools_usedwhen> 0.hub/agents/gaia/python/tests/test_stdio.pycovering error exits withconversation, fallback tohandler._tool_count, explicit zero/bool guards, and that earlier turns' tool results inmodel_messagesare not counted.Test plan
pytest hub/agents/gaia/python/tests/test_stdio.py tests/unit/test_print_mode.py tests/unit/test_final_usage_completeness.py tests/unit/test_turn_metrics_wire.py -q(282 passed)pytest hub/agents/gaia/python/tests/test_transport_dispatch.py -q(22 passed)black --check,isort --check-only, andflake8passed on modified filesEvidence
gaia-agentstdio wire usage builder for unprinted turns rather than the web UI.gaia_agent.stdio.run_turnover the newline-delimited stdio transport with a simulated error exit after tool execution (python -c "... stdio.run_turn(...)"):{"type": "final", "answer": "Language model unreachable at step 2", "usage": {"steps": 2, "input_tokens": 500, "tools_used": 1}}Checklist
Closes #7262).black,isort,flake8,pytest).usage.tools_usedschema).