feat: add $usage field to adapter protocol #80
Reference in New Issue
Block a user
Delete Branch "feat/74-usage-in-protocol"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Add
Usagetype and$usagefield throughout the adapter protocol for token usage reporting.Why
Eval framework (#34) needs per-step token consumption data. This is the foundation — adapters currently return
null, real implementations in #76/#77.Changes
protocol/types.ts—Usagetype, added toStepRecord+StepEntryprotocol/schemas.ts—usageinSTEP_NODE_SCHEMA(not required, backward compatible)util-agent/types.ts—usageinAgentRunResult+AdapterOutpututil-agent/run.ts— threaded throughwriteStepNode→persistStep→createAgentagent-mock/agent-hermes/agent-claude-code/agent-builtin— returnusage: nullstep-timing,step-show-json,protocol typesRef
Fixes #74
Refs #68
LGTM ✅ Usage 类型设计合理,schema anyOf null 向后兼容,全链路 threaded through。eval 基础到位。