Skip to content

Checkpoint live session updates during prompt turns#314

Open
AndroidPoet wants to merge 1 commit into
openclaw:mainfrom
AndroidPoet:fix/live-session-history-304
Open

Checkpoint live session updates during prompt turns#314
AndroidPoet wants to merge 1 commit into
openclaw:mainfrom
AndroidPoet:fix/live-session-history-304

Conversation

@AndroidPoet
Copy link
Copy Markdown

Fixes #304.

Summary

This makes the persisted session record track live prompt progress instead of only the prompt submission and final turn state.

The change adds a small debounced checkpoint helper and wires it into both prompt execution paths:

  • foreground/session prompt runs through src/cli/session/runtime.ts
  • detached queue-owner/background runs through src/runtime/engine/manager.ts

When ACP session/update events arrive, the in-memory conversation is still updated first, but now a live checkpoint is scheduled after that mutation. The checkpoint also flushes pending ACP wire messages before saving, so the event stream and session record move forward together.

There is also an immediate checkpoint after reconnect/load resolution. That makes fields like agentSessionId visible before the prompt finishes, instead of waiting for the turn close path.

Why this shape

I avoided reading Codex rollout JSONL files. That would fix the reported Codex case, but it would make acpx depend on one adapter's private logs. This stays inside the ACP runtime and applies to any adapter that emits session/update notifications.

The live saves are debounced at 500ms so token-by-token streams do not write the session JSON file for every chunk. Boundary saves still flush immediately where it matters: after session resolution and on close/finalization.

Tests

  • pnpm run typecheck
  • pnpm run lint
  • pnpm run test

Added integration coverage for:

  • sessions read seeing assistant output while a foreground prompt is still sleeping
  • --no-wait --file - stdin prompts checkpointing assistant output before the detached turn finishes

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.

ACP session history only records prompts while Codex is running

1 participant