Skip to content

fix(session): lock title and usage scalar access#3659

Merged
Sayt-0 merged 1 commit into
mainfrom
fix/3591-session-scalar-locking
Jul 15, 2026
Merged

fix(session): lock title and usage scalar access#3659
Sayt-0 merged 1 commit into
mainfrom
fix/3591-session-scalar-locking

Conversation

@Sayt-0

@Sayt-0 Sayt-0 commented Jul 15, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #3591 by serializing access to session title, token, and cost fields through Session.mu.

  • adds locked title and token/cost setters with matching snapshot accessors
  • routes runtime, store, server, app, evaluation, and TUI call sites through those accessors
  • snapshots message usage data before rendering the cost dialog
  • adds race regressions for session accessors, in-memory store updates, API responses, and TUI cost rendering
  • preserves omitted fields when importing partial token usage events

Issue expectations

Expectation Implementation
Add locked SetTitle Added SetTitle and TitleSnapshot
Add locked SetTokensAndCost Added atomic SetTokensAndCost and TokensAndCost
Route all title/token/cost writes through setters Updated production writers across session, runtime, server, app, evaluation, ACP, A2A, CLI, and TUI paths
Race-clean access Updated live readers to use locked snapshots and added concurrent regression tests
Regression coverage Added session, store, HTTP API, evaluation import, and TUI cost-dialog tests

Validation

  • task build
  • task lint
  • env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy task test
  • go test -race -count=1 ./pkg/session/... ./pkg/server/... ./pkg/runtime/... ./pkg/app/... ./pkg/tui/dialog/...
  • go test -race -count=1 ./pkg/a2a/... ./pkg/acp/... ./pkg/cli/... ./pkg/tui/page/chat/... ./pkg/chatserver/...

The full evaluation race suite still reports the pre-existing stderrData race in pkg/evaluation/eval.go; the evaluation tests affected by this change pass, and the ordinary full suite is green.

@Sayt-0
Sayt-0 requested a review from a team as a code owner July 15, 2026 13:46
@aheritier aheritier added area/api For features/issues/fixes related to the usage of the cagent API area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) area/tui For features/issues/fixes related to the TUI kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Jul 15, 2026
@Sayt-0
Sayt-0 merged commit b2147d0 into main Jul 15, 2026
7 checks passed
@Sayt-0
Sayt-0 deleted the fix/3591-session-scalar-locking branch July 15, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api For features/issues/fixes related to the usage of the cagent API area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) area/tui For features/issues/fixes related to the TUI kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(session): route Title/token/cost writes through locked setters

3 participants