Skip to content

feat(server): HttpSessionStore.get_cost_data reads from platform#120

Merged
rdwj merged 1 commit into
mainfrom
feat/http-session-cost-data-read
Apr 28, 2026
Merged

feat(server): HttpSessionStore.get_cost_data reads from platform#120
rdwj merged 1 commit into
mainfrom
feat/http-session-cost-data-read

Conversation

@rdwj
Copy link
Copy Markdown
Contributor

@rdwj rdwj commented Apr 28, 2026

Summary

  • Replaces HttpSessionStore.get_cost_data's NotImplementedError placeholder with a real GET /v1/sessions/{id}/cost_data. HTTP-backed deployments now match the cumulative shallow-merge semantics that SQLite/Postgres provide natively — multi-turn sessions converge on cumulative token totals instead of last-write-wins.
  • ABC contract preserved: returns {} when the session is missing or has no cost_data yet (404 on the wire → empty dict). Older platforms (<= 0.2.0) 404 cleanly on every call and the agent degrades silently to the previous behavior — safe to roll forward independently of the platform redeploy.
  • Bumps to 0.14.2 + CHANGELOG entry.

Pairs with the platform-side endpoint at fips-agents/fipsagents-platform#5 (closes their #4).

Test plan

  • pytest tests/test_http_stores.py tests/test_http_stores_e2e.py — 50 passing locally (5 new across both files; the old NotImplementedError test is replaced).
  • Full agent unit suite: 770 passing.
  • Cluster smoke against the redeployed pair (cumulative numbers across N turns).

Assisted-by: Claude Code (Opus 4.7)

Replaces the NotImplementedError placeholder with a real
GET /v1/sessions/{id}/cost_data, closing the cumulative gap noted in
0.14.0's release notes. HTTP-backed deployments now match the
cumulative shallow-merge semantics that SQLite/Postgres provide
natively -- the per-turn accumulator on OpenAIChatServer reads
existing totals before computing the merge, so multi-turn sessions
converge on cumulative numbers instead of last-write-wins.

ABC contract preserved: returns {} when the session is missing or has
no cost_data yet (404 on the wire degrades to an empty dict). Older
platforms (<= 0.2.0) 404 cleanly on every call and the agent silently
falls back to the previous last-write-wins behavior, so this is safe
to roll forward independently of the platform redeploy.

Five new tests across the unit and e2e suites (200/dict, 404/empty,
empty-dict round-trip, live-ASGI cumulative round-trip, live-ASGI
missing). The unit test that asserted NotImplementedError is replaced.
Suite total 765 -> 770.

Pairs with fipsagents-platform#4.

Assisted-by: Claude Code (Opus 4.7)
@rdwj rdwj merged commit 447bbb4 into main Apr 28, 2026
@rdwj rdwj deleted the feat/http-session-cost-data-read branch April 28, 2026 11:10
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