Repository navigation
fix(tracing): mark deferred tool responses as pending on tool spans - #1210
Open
gitwillsky wants to merge 1 commit into
Open
gitwillsky wants to merge 1 commit into
gitwillsky wants to merge 1 commit into
Conversation
A long-running tool, or ADK's task-delegation tool (`_defers_response`),
can finish its call without a response: ADK synthesizes it later. The
tool span then recorded `<unknown_tool_output>` for gen_ai.output,
gen_ai.tool.output and cozeloop.output, indistinguishable from a missing
output. Record `{"status": "pending"}` for these tools instead; other
tools without a response keep `<unknown_tool_output>`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
A tool whose response arrives after its call returns finishes its
execute_toolspan without a function response:_TaskAgentTool,_defers_response=True) returnsNone; ADK synthesizes the response once the sub-agent finishes (google/adk/flows/llm_flows/functions.py, theis_long_running or _defers_responsebranch).is_long_running=True) that has not responded yet behaves the same way.record_tool_executionthen calls the patchedtrace_tool_callwithfunction_response_event=None, andtool_gen_ai_tool_outputwrites<unknown_tool_output>togen_ai.output(APMPlus),gen_ai.tool.output(TLS) andcozeloop.output(CozeLoop). On APMPlus a delegated or long-running call therefore looks like a missing or broken output. Callers cannot work around it: returning a value from an after-tool callback turns the tool into an immediate response and breaks the delegation.Fix
In
tool_gen_ai_tool_output, when there is no function response and the tool is long-running or defers its response, record{"status": "pending"}. Every other tool without a response keeps<unknown_tool_output>. This matches what the Codex runtime already returns to the model in the same situation ({"status": "pending", "call_id": ...}inveadk/runtime/codex/tools_bridge.py); the call id is not available to the extractor, so it is omitted.Compatibility
Only the recorded output value of these spans changes; no public API, configuration or event contract changes. Content tracing (
OBSERVABILITY_OPENTELEMETRY_TRACE_CONTENT) still gates these attributes as before.Verification (2026-11-05, against
main@ e5bfe04)tests/test_tracing_content.py: a deferred-response tool and a long-running tool record{"status": "pending"}on all three attributes (fail onmain, pass here); a plain tool without a response still records<unknown_tool_output>.pytest -c pytest.ini tests/test_tracing_content.py tests/test_tracing.py tests/test_portal_metrics.py tests/test_inmemory_exporter.py tests/test_llm_attributes_extractors.py: 85 passed.ruff@0.11.12 format --checkandruff checkon the changed files: pass.main, overlaid with this change, not a fulluv synccheckout. Not run:pre-commit run --all-files(including gitleaks) and the full parallel regression.Found while tracing ADK task delegation to a remote A2A sub-agent: the delegation's
execute_toolspan showed<unknown_tool_output>even though the delegation worked.This PR was prepared with an AI coding agent; I authorized the submission.
🤖 Generated with Claude Code