mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
feat(agents): report per-run stats (code-mode engagement, round trips, cost) in agent JSON envelopes (#114688)
* feat(agents): add per-run stats to embedded agent run meta Adds codeModeEngaged, assistantTurns, bridgeCalls, and costUsd to EmbeddedAgentRunMeta.agentMeta and mirrors them on the agent exec --json envelope. Code-mode engagement is stamped from the tool-surface truth, round trips accumulate across attempts beside usage, bridge counts come from the run's tool-search catalog counters, and cost reuses the shared model pricing helpers (cache tiers included, omitted without cost data). * fix(agents): accumulate bridge call counts across run attempts Attempt cleanup clears the per-attempt tool-search catalog, so retries and fallbacks discarded earlier bridge counts. Fold each attempt's bridgeCalls into the run accumulator beside assistantTurns and stamp the cumulative totals into agentMeta, matching the documented per-run contract.
This commit is contained in:
committed by
GitHub
parent
e1ced6de50
commit
cf4cb0ac85
@@ -971,6 +971,24 @@ breakdown (`openclaw`/`mcp`/`client` counts), cumulative search/describe/call
|
||||
counts for the run's catalog, and the model-visible tool names (`exec`,
|
||||
`wait`, and retained direct-only tools).
|
||||
|
||||
The run metadata (`meta.agentMeta` in `openclaw agent --json`, mirrored on the
|
||||
`agent exec --json` envelope) adds per-run stats:
|
||||
|
||||
- `codeModeEngaged`: `true` only when code mode actually owned the model tool
|
||||
surface. This is the reliable engagement signal — do not infer engagement
|
||||
from config or tool names: the shell tool is also named `exec`, the
|
||||
`"auto"` tier engages per model capability, and a model routed through a
|
||||
native harness surface (for example OpenAI-family models on their harness)
|
||||
reports `codeModeEngaged: false` even with `tools.codeMode.enabled=true`,
|
||||
making the silent no-op observable.
|
||||
- `assistantTurns`: completed assistant/provider round trips across the run.
|
||||
- `bridgeCalls`: the run's cumulative inner bridge counts
|
||||
(`{ search, describe, call }`). These calls never reach the provider;
|
||||
provider-visible outer tool calls remain in `meta.toolSummary.calls`.
|
||||
- `costUsd`: estimated USD cost from the run's accumulated usage and the
|
||||
model's cost config (cache read/write tiers included); omitted when the
|
||||
model has no cost data.
|
||||
|
||||
Telemetry must not include secrets, raw environment values, or unredacted
|
||||
tool inputs beyond existing OpenClaw trajectory policy.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user