Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,16 @@ Abridged; items carry more fields, which you ignore. `spend_usd` and `created_at
`status` observed: `done`, `cancelled`. Here `spend_usd` and `created_at` are strings; parse them
as numbers.

A session holds every task in it, and its fields do not all count the same span. In the list and
here, `spend_usd` and `usage` are the session's totals across all its tasks, while `elapsed` is
the latest task's seconds only. Do not divide one by the other. For each task's own time, read the
turn's `elapsed` in `GET /v1/sessions/{session_id}/turns`; sum those for the session's.

`spend_usd` absent or `null` means nothing was metered for the session yet: the cost is unknown,
not zero. Show "—", never "$0". A number, `0` included, is a known figure; `0` means nothing was
charged here (the model ran on the organization's own key, whose provider bills it, or the model
is listed free).

### GET /v1/sessions/{session_id}/turns

```json
Expand Down
8 changes: 8 additions & 0 deletions tests/test_cloud_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ def test_memory_guidance_names_no_internal_systems(self):
for n, line in enumerate(p.read_text().splitlines(), 1) if forbidden.search(line)]
self.assertEqual(failures, [])

def test_session_totals_and_latest_task_fields_are_told_apart(self):
# A team reconciling its records found spend_usd summed over the session while elapsed was
# the latest task's only; the examples show them side by side, so the reference has to say so.
api = (SKILL_ROOT / "references" / "api-reference.md").read_text()
self.assertIn("`spend_usd` and `usage` are the session's totals across all its tasks", api)
self.assertIn("`elapsed` is\nthe latest task's seconds only", api)
self.assertIn("the cost is unknown,\nnot zero", api)

def test_skill_relative_markdown_links_resolve(self):
markdown_files = [SKILL_ROOT / "SKILL.md", *sorted((SKILL_ROOT / "references").glob("*.md"))]
failures = []
Expand Down