Skip to content

fix(chat): refresh context usage between model calls - #1058

Open
xuzijian2019 wants to merge 1 commit into
agegr:mainfrom
xuzijian2019:fix/live-context-usage
Open

xuzijian2019 wants to merge 1 commit into
agegr:mainfrom
xuzijian2019:fix/live-context-usage

Conversation

@xuzijian2019

Copy link
Copy Markdown

Refs #1031 (the refresh gap while a run is busy).

During a multi-call agent run, the context usage indicator stays blank or at its pre-run value: running-state reconciliation returns for a busy wrapper before applying usage, and assistant message_end does not request fresh usage.

Apply usage from busy reconciliation replies and refresh it when each assistant message completes. Mount, message completion, reconciliation and agent_end reads share a monotonic request id with session, run and mount checks so slow replies cannot overwrite newer usage. Remove the duplicate unguarded mount write and update the existing cleanup test fixture for the new ref.

This adds one state GET per completed assistant message and keeps the existing polling cadence. It does not address #1031's separate idle-session mount/connected race, so it should not close that issue in full.

Validation

  • Five behavioral tests execute the actual hook callbacks: busy updates without settling, out-of-order poll/message replies, old run/session/unmount invalidation, failed reads and recovery, and assistant-only refreshes.
  • npm test: 2,288 tests passed.
  • node_modules/.bin/tsc --noEmit and npm run lint passed.
  • git diff --check passed.
  • No browser E2E or paid model run performed.

Adapted from the desktop fork's independent fix; original tracking: xuzijian2019/pi-agent-desktop#3. No desktop or fork UI dependencies.

Change-Id: I423982a12d024afebc8da1e67836722a6e2aae3b

This branch has not been deployed

No deployments
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