Repository navigation
fix(diagnostics-otel): model call spans drop Anthropic cache-write TTL split - #171663
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesPreserves reported Anthropic and Bedrock cache-write TTL counts through usage accounting into OpenTelemetry spans. Example: A response reports 1000000 cache-write tokens: 400000 with one-hour retention and 600000 with five-minute retention.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains This PR fixes a current telemetry defect using existing accounting owners; no introduced correctness or security defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherProvider adapters normalize response usage, agent accounting preserves and accumulates it, and diagnostics-otel exports numeric model-call attributes to OTLP collectors. flowchart LR
A[Provider usage] --> B[Provider accounting]
B --> C[Agent usage normalization]
C --> D[Recovery and accumulation]
C --> E[Model call diagnostics]
D --> E
E --> F[OpenTelemetry exporter]
F --> G[OTLP collector]
Technical reviewBest possible solution: Retain the focused optional-field propagation and OpenClaw-specific TTL attributes while preserving existing generic totals and pricing. Do we have a high-confidence way to reproduce the issue? Current-main source demonstrably drops five-minute provider counts and exports neither TTL bucket; no target code or tests were executed during this read-only review. Is this the best way to solve the issue? The patch is the smallest coherent repair across existing owners: preserve independently reported buckets, retain zero versus absent semantics, and export subsets outside the additive generic namespace. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 745d2e768dff. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +48, Tests +240, Docs +1. Total +289 across 16 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (5 earlier review cycles)
Reviewed October 24, 2026, 11:59 PM ET / October 25, 2026, 03:59 UTC (Revision 6). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…te pricing Keep the blended generic usage count and export TTL subsets only as OpenClaw attributes. Preserve reported zero and absent buckets across provider usage, recovery, and accumulation. Integrate current main without restoring retired test paths.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…L split (openclaw#171663) Preserve reported Anthropic cache-write TTL buckets through provider accounting and model-call diagnostics. Export the breakdown only under OpenClaw attributes so generic pricing does not count the same writes twice. Preserve explicit zero and absence through normalization, recovery, and accumulation. Regression coverage includes provider compaction and delivery through a real HTTP/protobuf OTLP receiver. Co-authored-by: ryan-dyer-sp <[email protected]>
What Problem This Solves
Anthropic's five-minute and one-hour cache-write counts are lost before model-call traces reach OpenTelemetry collectors, so operators cannot inspect the reported TTL breakdown.
User Impact
Model-call spans preserve both reported TTL buckets under
openclaw.model_call.usage.cache_creation_input_tokens_1hand_5m, including explicit zero. Unreported buckets remain absent. Existing generic cache totals and pricing behavior stay intact; consumers can use the OpenClaw attributes for TTL-aware analysis.Why This Change Was Made
Carry the provider's facts through the existing usage, recovery, and accumulation owners. Keep TTL subsets outside the additive
gen_ai.usage.*namespace: emitting both a blended total and its decomposition there causes generic consumers such as Langfuse to charge for the same writes twice.The accumulator uses optional totals instead of separate reporting flags, and Bedrock sums both TTLs in one snapshot-local loop. Preserve main's consolidation of normalization tests and removal of duplicate transport coverage.
Thanks @ryan-dyer-sp for the original fix and provider/accounting coverage.
Evidence
400000one-hour and600000five-minute counts arrive intact; zero and absent controls pass. The generic namespace carries only the blended1000000count.6af0b026aa63910cfda67a31834138f6d0ae1d3aagainst the captured spans. The mixed-TTL example has one existing blended charge of $3.75. A control using the original PR's overlapping generic attributes produces $8.40. This preserves generic pricing rather than adding a new TTL-pricing policy.0e6ab27f8873a65d8d89cb1634098bdf2716c5d9exercised a spawned Gateway through Anthropic HTTP into OTLP and observed the same 400000/600000 OpenClaw attributes; that remains prior-revision evidence, not a current-head live run.Exact-head CI, including the CI/security gate, passes for
8771c0302a948716bf23fb8cd978b90646a75ae5. The native watcher reports GREEN with zero pending checks. ClawSweeper found no code issues on this head; its remaining advisory request is a fresh full Gateway/provider trace, whose absence is disclosed above.