feat(server): HttpSessionStore.get_cost_data reads from platform#120
Merged
Conversation
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HttpSessionStore.get_cost_data'sNotImplementedErrorplaceholder with a realGET /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.{}when the session is missing or has nocost_datayet (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.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).Assisted-by: Claude Code (Opus 4.7)