Repository navigation
docs(#7230): document computing cost from token telemetry - #7232
Conversation
|
🤖 Finished Review · ✅ Success · Started 12:21 PM UTC · Completed 12:34 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $2.98 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
<!-- fullsend:risk-assessment --> DetailsLow-risk documentation-only changes with strong issue alignment, but elevated recent commit churn and regression history across touched documentation files keep the composite score at 2 (moderate). Previous run<!-- fullsend:risk-assessment --> DetailsTier 1 metadata reflects a low-risk docs-only change (4 files, 162 lines, bot author, no protected paths) and Tier 3 confirms strong issue alignment, but elevated Tier 2 commit churn and regression history keep the composite score at 2 (moderate). Previous run (2)<!-- fullsend:risk-assessment --> DetailsTier 1 metadata reflects a low-risk docs-only change (4 files, 162 lines, bot author, no protected paths) and Tier 3 confirms strong issue alignment, but elevated Tier 2 commit churn and regression history keep the composite score at 2 (moderate). Previous run (3)<!-- fullsend:risk-assessment --> DetailsTier 1 metadata reflects a low-risk docs-only change (4 files, 193 lines, bot author, no protected paths) and Tier 3 confirms strong issue alignment, but elevated Tier 2 commit churn and regression history keep the composite score at 2 (moderate). Previous run (4)Risk Assessment: moderate (2/5) DetailsRe-review anchoring: Tier 1 metadata is unchanged (3 doc files, 128 lines, no protected or CI paths, bot author) and Tier 3 confirms full issue alignment, but Tier 2 churn in shared tracing docs elevates the composite score to 2 (moderate). Previous run (5)Risk Assessment: moderate (2/5) DetailsRe-review anchoring: Tier 1 metadata is unchanged from the prior round (3 files, docs-only, no protected/security/dependency/CI paths, bot author); this round only reworks wording in the already-touched reasoning/output disjointness passage and adds one reference table row, with no new files or protected paths. Tier 2 history reflects shared, frequently-edited tracing docs churn unrelated to instability from this change, and Tier 3 remains a well-matched, fully-satisfied docs issue, preserving the prior score of 2 (moderate). Previous run (6)Risk Assessment: moderate (2/5) DetailsRe-review confirms Tier 1 metadata is unchanged (3 files, docs-only, no protected/security/dependency/CI paths, bot author); the only new commit reworks wording in the already-touched cancelled-run cost/reasoning passage with no new files or protected paths. Tier 2 churn/fix-revert signals remain elevated but reflect general repo-wide edit activity on shared, frequently-modified tracing docs rather than instability from this change. Tier 3 remains a well-matched, fully-satisfied documentation issue. Weighted composite (~1.7) rounds to 2, preserving the prior score of 2 (moderate). Previous run (7)Risk Assessment: moderate (2/5) DetailsRe-review confirms Tier 1 metadata is unchanged (3 files, ~114 lines, docs-only, no protected/security/dependency/CI paths, bot author); the latest commit only reworks wording in two already-touched docs with no new files or protected paths. Tier 2 churn/fix-revert/coupling signals are elevated but reflect general repo-wide edit activity on shared, frequently-modified runtime/tracing docs rather than instability introduced by this change. Tier 3 remains a well-matched, fully-satisfied documentation issue. Weighted composite (0.51.25 + 0.33.0 + 0.2*1.0 = 1.73 -> 2) preserves the prior score of 2 (moderate). Previous run (8)Risk Assessment: moderate (2/5) DetailsRe-review: Tier 1 metadata is unchanged (3 files, 102 lines, docs-only, no protected/security/dependency/CI paths, bot author), and the only new commit since the prior assessment adds a single caveat row to one doc in response to reviewer feedback with no new files or protected paths; Tier 2 elevated churn/fix-revert counts reflect general repo-wide edit activity on these shared doc files rather than instability introduced by this change, and Tier 3 remains a well-matched, fully-satisfied documentation issue, so the prior composite score of 2 (moderate) is preserved. Previous run (9)Risk Assessment: moderate (2/5) DetailsRe-review anchoring applies: Tier 1 metadata is unchanged from the prior run (3 files, ~91 lines, small blast radius, no protected/security paths, no CI or dependency changes, bot author), and the single new commit since the prior review only adds a missing 'Reasoning' row and caveat to distributed-tracing.md in response to a reviewer finding, without introducing new files, protected paths, or dependency/CI changes; per the anchoring rules the prior composite of 2 (moderate) is preserved. Previous run (10)Risk Assessment: moderate (2/5) DetailsTier 1 metadata is uniformly low-risk (small, docs-only, no security/protected paths, no dependency or CI changes, bot author), Tier 2 shows moderately active recent churn on two of the three touched doc files with no instability tied to this specific content, and Tier 3 shows a well-matched, low-priority documentation issue with acceptance criteria met, yielding a composite of 2 (moderate) driven mainly by the touched files' higher recent edit frequency despite the change itself being trivial and additive. |
ReviewFindingsLow
Previous run<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJhcHByb3ZlIiwiZmluZGluZ3MiOlt7InNldmVyaXR5IjoibWVkaXVtIiwiY2F0ZWdvcnkiOiJhcGktY29udHJhY3QiLCJmaWxlIjoiZG9jcy9ydW50aW1lcy9jb2RleC5tZCIsImlkIjoiZl81ZWM3MjZkYjc0MWU0ZjI3IiwibGluZSI6Mjk4LCJhY3Rpb25hYmxlIjp0cnVlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJzY29wZS1jcmVlcCIsImZpbGUiOiJkb2NzL3J1bnRpbWVzL2NvZGV4Lm1kIiwiaWQiOiJmXzZjN2NkNGU1MzZjYWUyY2UiLCJsaW5lIjoyOTMsImFjdGlvbmFibGUiOmZhbHNlfV0sImRpc3Bvc2l0aW9ucyI6W3siaWQiOiJmXzVlYzcyNmRiNzQxZTRmMjciLCJzdGF0dXMiOiJkaXNtaXNzZWRfYnlfaHVtYW4ifSx7ImlkIjoiZl82YzdjZDRlNTM2Y2FlMmNlIiwic3RhdHVzIjoiZGlzbWlzc2VkX2J5X2h1bWFuIn1dfQ== --> Looks good to me Previous run (2)<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJhcHByb3ZlIiwiZmluZGluZ3MiOlt7InNldmVyaXR5IjoibWVkaXVtIiwiY2F0ZWdvcnkiOiJhcGktY29udHJhY3QiLCJmaWxlIjoiZG9jcy9ydW50aW1lcy9jb2RleC5tZCIsImlkIjoiZl81ZWM3MjZkYjc0MWU0ZjI3IiwibGluZSI6Mjk4LCJhY3Rpb25hYmxlIjp0cnVlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJzY29wZS1jcmVlcCIsImZpbGUiOiJkb2NzL3J1bnRpbWVzL2NvZGV4Lm1kIiwiaWQiOiJmXzZjN2NkNGU1MzZjYWUyY2UiLCJsaW5lIjoyOTMsImFjdGlvbmFibGUiOmZhbHNlfV0sImRpc3Bvc2l0aW9ucyI6W3siaWQiOiJmXzVlYzcyNmRiNzQxZTRmMjciLCJzdGF0dXMiOiJkaXNtaXNzZWRfYnlfaHVtYW4ifSx7ImlkIjoiZl82YzdjZDRlNTM2Y2FlMmNlIiwic3RhdHVzIjoiZGlzbWlzc2VkX2J5X2h1bWFuIn1dfQ== --> Looks good to me Labels: PR changes user-facing documentation only. Previous run (3)<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJyZXF1ZXN0LWNoYW5nZXMiLCJmaW5kaW5ncyI6W3sic2V2ZXJpdHkiOiJtZWRpdW0iLCJjYXRlZ29yeSI6ImFwaS1jb250cmFjdCIsImZpbGUiOiJkb2NzL3J1bnRpbWVzL2NvZGV4Lm1kIiwiaWQiOiJmXzVlYzcyNmRiNzQxZTRmMjciLCJsaW5lIjoyOTgsImFjdGlvbmFibGUiOnRydWV9LHsic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6InNjb3BlLWNyZWVwIiwiZmlsZSI6ImRvY3MvcnVudGltZXMvY29kZXgubWQiLCJpZCI6ImZfNmM3Y2Q0ZTUzNmNhZTJjZSIsImxpbmUiOjI5MywiYWN0aW9uYWJsZSI6ZmFsc2V9XX0= --> ReviewFindingsMedium
Low
Next steps:
Previous run (4)ReviewThe prior finding (the cancelled Codex/pi "non-zero reasoning whenever a turn/message finished" overstatement) is fixed in this revision — the correctness sub-agent verified the current text now qualifies that reasoning is non-zero only when the finished turn/message actually reported reasoning tokens, checked against FindingsLow
Next steps:
Previous run (5)ReviewThe prior finding (pi's FindingsLow
Next steps:
Previous run (6)ReviewBoth findings from the prior review (the "cancelled runs ⇒ 0" grouping at the old line 281, and the worked example's missing FindingsMedium
Next steps:
Previous run (7)ReviewThe three findings from the prior review (completed-only Codex reasoning wording, the FindingsLow
Next steps:
Previous run (8)ReviewFindingsMedium
Low
Next steps:
Previous run (9)ReviewFindingsMedium
Low
Next steps:
Previous run (10)ReviewFindingsMedium
Next steps:
|
|
🤖 Finished Fix · ✅ Success · Started 12:36 PM UTC · Completed 12:42 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $0.64 |
Addresses review feedback on PR #7232: the worked example priced only four token fields and implied that formula covered both cancelled runs and Codex. Codex counts reasoning tokens separately from output, so a Codex user following the four-field formula would undercount cost. Adds a Reasoning row to the persisted-token-fields table, scopes the worked example explicitly to cancelled runs (where reasoning is typically zero), and adds an explicit caveat that completed/Codex runs must add a fifth term for reasoning tokens or the formula undercounts. Addresses #7232
🔧 Fix agent — iteration 1 (bot-triggered)Fixed the reviewer's single medium-severity finding: the token-telemetry cost guide implied its four-field formula applied to both cancelled runs and Codex, but Codex reports reasoning tokens as a fifth, disjoint counter not covered by the formula. Added a Reasoning table row, clarified the disjointness for Codex, scoped the worked example to cancelled runs, and added an explicit caveat/formula term for completed and Codex runs. Fixed (1):
Tests: passed Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 12:44 PM UTC · Completed 12:57 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $3.07 |
|
🤖 Finished Fix · ✅ Success · Started 12:59 PM UTC · Completed 1:06 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $0.93 |
…metry Address fullsend-ai-review findings on PR #7232: - The completed-run cost guidance told readers to add a fifth reasoning/1e6 term generally, calling out Codex only as an example. For Codex, output excludes reasoning tokens (codexUsage.counters subtracts them), so the extra term is required. For Claude and pi, output already includes reasoning tokens (Claude copies output_tokens verbatim, which Anthropic already folds thinking tokens into; pi's message_end usage shows reasoning as a subset of output), so adding the term on top double-counts and overbills. Reworded both the caveat and the worked-example guidance to scope the fifth term to Codex explicitly and warn against it for Claude/pi. - The "Persisted token fields" table listed Reasoning as a peer row without noting that its span attribute is omitted entirely when zero (agentSpanEndAttrs in internal/cli/run.go only appends gen_ai.usage.reasoning_tokens when greater than zero), unlike the other four gen_ai.usage attributes which are always attached. Added a footnote clarifying metrics.json always includes reasoning (0 when none) while the span attribute does not. Addresses #7232
🔧 Fix agent — iteration 2 (bot-triggered)Fixed both review findings in docs/guides/infrastructure/distributed-tracing.md: scoped the fifth reasoning-token cost term to Codex only (Claude/pi already fold reasoning into output, so adding it there double-counts), and added a footnote documenting that the reasoning span attribute is omitted when zero while metrics.json always includes it. Verified both claims directly against internal/runtime/{codex,pi,claude}_progress.go, the pi reasoning_run.ndjson fixture, and agentSpanEndAttrs in internal/cli/run.go before editing. Fixed (2):
Tests: passed Decision points
Next steps:
|
|
🤖 Finished Review · ✅ Success · Started 1:08 PM UTC · Completed 1:22 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $3.44 |
|
🤖 Finished Fix · ✅ Success · Started 1:23 PM UTC · Completed 1:31 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $1.40 |
🔧 Fix agent — iteration 3 (bot-triggered)Fixed all three review findings on PR #7232 by reworking the Codex reasoning-token guidance in docs/guides/infrastructure/distributed-tracing.md to key off 'reasoning > 0' rather than 'completed run' (verified Codex's finish() emits ResultEvent with high-water reasoning counters even on killed/interrupted streams), adding an explicit OpenCode caveat noting its output/reasoning disjointness is unconfirmed, and rewording the docs/cli/run.md token_usage row so it no longer calls all five persisted fields uniformly disjoint. Fixed (3):
Tests: passed
Decision points
Next steps:
|
…d-only Address review feedback on PR #7232: the cost-from-telemetry guide and CLI reference tied Codex's reasoning-token handling to "completed" runs, but Codex's stream parser synthesizes a ResultEvent from high-water counters on every stream, including killed/interrupted ones, so a cancelled Codex run with at least one finished turn can carry non-zero, output-disjoint reasoning tokens too. Reworded the intro, the per-runtime caveat, and the worked-example addendum in docs/guides/infrastructure/distributed-tracing.md to key off "reasoning > 0" rather than "completed", and to name OpenCode explicitly as an unconfirmed case since its parser passes reasoning through without the Codex-style subtraction. Also reworded the docs/cli/run.md token_usage row so it no longer calls all five fields uniformly disjoint, since reasoning is disjoint from output only for Codex. Addresses #7232
|
🤖 Finished Review · ✅ Success · Started 1:34 PM UTC · Completed 1:47 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $3.92 |
|
🤖 Finished Fix · ✅ Success · Started 1:49 PM UTC · Completed 1:55 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $0.73 |
🔧 Fix agent — iteration 4 (bot-triggered)Fixed both low-severity findings from the latest review: scoped the cancelled-run zero-cost claim to Claude and Codex (excluding pi, which can carry non-zero cost/reasoning after cancellation), and added the missing reasoning field to the worked example's metrics.json with corrected prose attribution. Fixed (2):
Tests: passedNext steps:
|
Superseded by updated review
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can reply 'qodo' on any finding to push back, ask questions, or dig deeper |
PR Summary by QodoDocument estimating inference cost from token telemetry
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
|
🤖 Review · ❌ Terminated · Started 11:56 AM UTC · Ended 12:01 PM UTC Commit: |
|
/fs-fix I believe this statement is wrong "Use |
|
🤖 Finished Fix · ✅ Success · Started 12:00 PM UTC · Completed 12:03 PM UTC Commit: Runtime: claude · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.27 |
Superseded by updated review
|
🤖 Finished Review · ✅ Success · Started 11:56 AM UTC · Completed 12:01 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $0.76 |
Fullsend does not support configuring or calculating a contracted rate, so the token-telemetry cost procedure yields a list-price estimate. Reword the contracted-rate language in the tracing, MLflow, and Codex docs accordingly. Note: pre-commit hooks and lychee link check could not run (sandbox network/exec restrictions). No links or anchors were changed. Addresses #7232 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
🔧 Fix agent — iteration 1 (human-triggered)Clarified that the token-telemetry cost procedure gives a list-price estimate, not a contracted rate, and that contracted-rate configuration is not supported. Applied consistently across the three docs that referenced it. Pre-commit and lychee could not run in the sandbox; no links or anchors were changed. Fixed (2):
Tests: passed CI inspections (6):
Conflict update: skipped; strategy
|
|
🤖 Finished Review · ✅ Success · Started 12:05 PM UTC · Completed 12:25 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $1.67 |
Superseded by updated review
Summary
Explains how to estimate inference cost from persisted token counts using contracted rates, including runs whose runtime-reported cost is zero. Uses
run-telemetry.jsonlagent spans as the primary source andmetrics.jsonas the run-level fallback.Closes #7230.
Changes
Validation
git diff --checkpassed.1c0e9b1bef834f5d936119dad8d83b9aa044a598.Fresh hosted CI and automated review results are reported separately on the PR.