docs(agent-workflows): Plan usage and cost telemetry#5253
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🤖 The AI agent says: Please review the canonical runner-to-service usage shape, inclusive token and cache semantics, model-scoped cost provenance, and the phase boundary that requires CTO approval before any API-visible span attribution or semantic-convention change. The five open decisions are listed in status.md and the PR body. |
Context
Pi and Claude expose cache-aware token and cost information, but the agent runner reduces every
run to four ambiguous numbers. That loses cache buckets, currency, provenance, and model scope,
and it conflates ACP context-window occupancy with billed token usage. Tracing then repeats totals
on leaf and parent spans while the API recalculates producer-supplied cost, so the displayed cost
can be inaccurate or counted more than once.
This design starts at the pre-production harness, runner, and runner-to-service boundaries. It
keeps exported span attribution and service-to-API semantic-convention changes behind an explicit
CTO approval gate.
What this proposes
The runner normalizes each harness into inclusive input/output token totals with cache and
reasoning subcategories, monetary cost with currency and provenance, model-scoped observations,
and a separate context-utilization gauge. Pi and Claude adapters reconcile fields by authority and
temporality instead of replacing one whole usage object with another.
The plan also inventories the wider trace path: span hierarchy, model and response identity,
content policy, status/errors, timing, adapters, storage, rollups, query presets, and UI display.
It proposes one-owner incremental attribution and an Agenta cost semantic convention, but defers
all API-visible behavior changes until the CTO approves the convention, rollup, and cross-batch
strategy.
Before:
{"usage":{"input":10,"output":5,"total":15,"cost":0.001}}Proposed direction:
{ "usage": { "tokens": {"input":12000,"output":800,"total":12800,"details":{"cacheReadInput":10500}}, "costs": {"total":{"amount":0.021,"currency":"USD"},"provenance":{"kind":"reported","source":"provider"}} }, "context": {"usedTokens":12800,"windowTokens":200000} }How to review
context.mdfor scope and boundary constraints.research.mdandtrace-inventory.mdfor the end-to-end findings and deferred gaps.interface-design.md, especially inclusive token arithmetic, model-scoped costprovenance, final versus provisional events, and the service-to-API proposal.
plan.mdfor the runner-first sequence and the CTO gate before exported trace changes.qa.mdfor cache-heavy, multi-model, partial/error, streaming, and no-double-countingcoverage.
Decisions requested
public documentation.
Tests / notes
This PR contains design documents only. The research used the live runner, installed Pi and Claude
ACP packages, Python service contracts, API adapters and tree rollups, observability UI paths,
existing tests, and public tracing documentation.