_extract_model_info_from_trace in ws_server.py:808 takes an invocation_idx and then never uses it. It's the only occurrence of that name in the codebase. The function walks trace.all_spans for every invocation, so each one gets the same session-wide aggregate instead of its own numbers.
Easy to spot live. Ran the three zero-code examples and every invocation in a session reports identical usage:
adk-zero-code 3 invocations, all in=3738 out=382
strands-zero-code 3 invocations, all in=3154 out=187
langchain-zero-code 3 invocations, all in=1033 out=65
Same story for provider, finishReasons and responseModels, all aggregated over the full trace. So the numbers we show per invocation are wrong, and anything summing them triple counts.
Direction: pick out the LLM spans that belong to the invocation and aggregate over just those. If we decide session-level really is what we want here, then drop the parameter and rename the function so it stops implying otherwise.
Probably worth doing before #77 splits up ws_server.py, otherwise the dead parameter gets carried into the new structure and the numbers stay broken.
_extract_model_info_from_tracein ws_server.py:808 takes aninvocation_idxand then never uses it. It's the only occurrence of that name in the codebase. The function walks trace.all_spans for every invocation, so each one gets the same session-wide aggregate instead of its own numbers.Easy to spot live. Ran the three zero-code examples and every invocation in a session reports identical usage:
Same story for
provider,finishReasonsandresponseModels, all aggregated over the full trace. So the numbers we show per invocation are wrong, and anything summing them triple counts.Direction: pick out the LLM spans that belong to the invocation and aggregate over just those. If we decide session-level really is what we want here, then drop the parameter and rename the function so it stops implying otherwise.
Probably worth doing before #77 splits up
ws_server.py, otherwise the dead parameter gets carried into the new structure and the numbers stay broken.