Use response_id to track token usage for MessageActions (#6913)

Co-authored-by: Calvin Smith <email@cjsmith.io>
This commit is contained in:
Engel Nyst
2025-03-26 21:07:01 +01:00
committed by GitHub
parent c5491e87aa
commit 9850f1767a
4 changed files with 125 additions and 17 deletions

View File

@@ -215,6 +215,13 @@ def response_to_actions(response: ModelResponse) -> list[Action]:
)
)
# Add response id to actions
# This will ensure we can match both actions without tool calls (e.g. MessageAction)
# and actions with tool calls (e.g. CmdRunAction, IPythonRunCellAction, etc.)
# with the token usage data
for action in actions:
action.response_id = response.id
assert len(actions) >= 1
return actions