Skip to content

Skill API reference: a session's spend and usage are totals, its elapsed is the latest task's - #4

Open
eric-epsilla wants to merge 2 commits into
HarnessRouter:mainfrom
eric-epsilla:session-totals-vs-latest
Open

eric-epsilla wants to merge 2 commits into
HarnessRouter:mainfrom
eric-epsilla:session-totals-vs-latest

Conversation

@eric-epsilla

Copy link
Copy Markdown

Problem

GET /v1/sessions and GET /v1/sessions/{id} show spend_usd and elapsed side by side, but they count different spans. spend_usd (and usage) add up every task in the session; elapsed is the latest task's alone. Nothing in the Skill says so. A builder who divides one by the other, or reconciles costs against time, gets wrong numbers.

Change

references/api-reference.md, under GET /v1/sessions/{session_id}: one paragraph. It says which fields are session totals and which is the latest task's, and points to each turn's own elapsed in /turns (sum those for the session's time).

tests/test_cloud_scope.py: checks the paragraph stays. It fails on main.

Verification

  • python3 -m unittest discover -s tests -p 'test_*.py': 45 tests, OK (1 skipped).
  • With the reference change reverted, the new test fails.
  • How each field is computed was read from the service's code; I did not check against live data.

🤖 Generated with Claude Code

…sed is the latest task's

The session list and the session read show spend_usd and elapsed side by side, and they count
different spans: spend_usd and usage add up every task in the session, elapsed is the latest
task's alone. A team reconciling its own records found the difference by hand. One paragraph says
so, and where each task's own time is (the turn's elapsed in /turns).

tests/test_cloud_scope.py checks it stays; it fails on main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eric-epsilla

Copy link
Copy Markdown
Author

@richard-epsilla, a one-paragraph doc fix.

Problem. Session spend_usd and usage are totals over every task in the session, but elapsed is only the latest task's. The Skill shows them side by side without saying so.

Approach. Document the difference rather than add a total_elapsed field. Each turn already carries its own elapsed in /turns.

What I'd like from you:

  1. Merge. Same spot in tests/test_cloud_scope.py as Skill references: the codes for a task refused for credit, stopped early, or failed #1 and Skill API reference: a task's own reasoning level, and sharing a session by link #3, so I'll rebase whichever conflicts.
  2. If you'd rather the service return a total_elapsed, say so and I'll file that separately. My recommendation is the doc: the per-turn figures are already there.

The service now leaves spend_usd out for a session nothing was metered for, rather than writing 0,
and keeps 0 for a known figure: nothing charged here (the organization's own key, a model listed
free). A reader who shows a missing figure as $0 brings the old confusion back, so the reference
says to show "—" for it and what a 0 means.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@eric-epsilla

Copy link
Copy Markdown
Author

Added one paragraph in a second commit, under the same heading. spend_usd absent or null means nothing was metered yet: unknown, show "—". A number, 0 included, is a known figure; 0 means nothing was charged here (own key, or a model listed free). That is how the service answers since the unknown-spend change; the test checks the line. Tests: 45, OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant