feat(workflows): add tool call count tracking to agent workflow
AH
4mo ago+102+102+012345678901234567890123456789-0-0-0123456789
- Introduced
countToolCallsInMessageto track tool invocations in the agent's response message. - Updated
runAgentWorkflowto includetoolCallCountin the metadata sent tohandleChatCredits. - Enhanced tests to verify that
toolCallCountis correctly passed and handled during the workflow execution.
Summary by cubic
Track and record tool call counts per agent turn so spend reports reflect actual tool usage.
-
New Features
- Added
countToolCallsInMessageto count tool UI parts on assistant messages; defaults to 0 with tests. runAgentWorkflownow passestoolCallCounttohandleChatCredits(stored asusage_events.tool_call_count, source set to "api");handleChatCreditsaccepts and forwards this value with tests.
- Added
-
Refactors
- Streamlined test assertions and formatting in
runAgentWorkflow.test.tsandcountToolCallsInMessage.test.ts.
- Streamlined test assertions and formatting in
Summary by CodeRabbit
- Chores
- Enhanced credit deduction tracking to capture per-turn tool invocation counts and include them in usage/audit records.
- Added message-level tool-call counting so credit recording can account for tool usage more accurately without changing user-facing behavior.