Repository navigation
feat(system-agent): durable rolling transcript with openclaw.chat.history - #111440
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7ca1e10ae4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!params.reset) { | ||
| engine.seedHistory( | ||
| readTranscriptTail(SYSTEM_AGENT_SEED_HISTORY_LIMIT, { afterLastReset: true }).map( | ||
| ({ role, text }) => ({ role, text }), | ||
| ), |
There was a problem hiding this comment.
Isolate durable context from delegated callers
Do not seed every fresh engine from the machine-wide transcript when params.delegation is present. The openclaw tool is exposed to regular, non-sandboxed agent runs through src/agents/tools/openclaw-delegate-tool.ts:59-73, and delegation sessions are otherwise isolated by resolveSystemAgentDelegationKey; with this unconditional seed, one agent/session's messages become model-visible history for another agent or the admin UI. Besides disclosing prior conversation text, an externally influenced delegated call can persist instructions that poison later system-agent sessions. Scope stored context by delegation identity, or omit shared transcript seeding for delegated sessions.
Useful? React with 👍 / 👎.
| function persistEngineHistory(engine: SystemAgentChatSession["engine"], startIndex: number): void { | ||
| const at = Date.now(); | ||
| for (const turn of engine.historySince(startIndex)) { | ||
| // Engine history is authoritative here: sensitive user text has already | ||
| // been replaced by the mask marker before it crosses this boundary. | ||
| appendTranscriptTurn({ ...turn, at }); | ||
| } |
There was a problem hiding this comment.
Persist asynchronously resolved approval replies
Persist history added by delegated approval resolution, not only history added during an openclaw.chat RPC. When the approval manager later invokes engine.resolveOperatorApproval(...), that method appends a non-null assistant reply to engine history, but this helper is never called for that asynchronous path; the next chat call snapshots historyLength() after the reply, so it can never pick the omitted entry up. After an approved or denied delegated proposal, the durable transcript and post-restart model context therefore lose the approval outcome.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a2b79463db
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| engine.seedHistory( | ||
| readTranscriptTail(SYSTEM_AGENT_SEED_HISTORY_LIMIT, { afterLastReset: true }).map( | ||
| ({ role, text }) => ({ role, text }), | ||
| ), |
There was a problem hiding this comment.
Seed durable history into the primary agent turn
For a fresh engine after restart or eviction, this seed never reaches the normal model path. resolveAssistantTurn invokes runAgentTurn with only the current input, overview, and a newly created agent session (src/system-agent/chat-engine.ts:697-718); that session receives a random ID and a new session file in src/system-agent/agent-turn.ts:70-81 and src/system-agent/agent-turn.ts:307-327. The seeded this.history is supplied only to the fallback planner at src/system-agent/chat-engine.ts:739-752. Consequently, whenever the primary embedded/CLI turn succeeds, it answers without the persisted conversation, so the advertised cross-restart model context is absent; seed the primary agent session or prompt as well.
Useful? React with 👍 / 👎.
| @@ -578,7 +573,7 @@ export class CustodianPage extends OpenClawLightDomElement { | |||
| const client = this.activeClient; | |||
| const params = this.retryParams; | |||
| if (client && params && params.message === undefined && this.chatAvailable && !this.sending) { | |||
| void this.requestReply(client, params); | |||
| void this.initializeSession(client, params); | |||
There was a problem hiding this comment.
Avoid duplicating a persisted welcome on retry
When the initial openclaw.chat completes server-side but its response times out or is lost, the welcome has already been persisted. Retrying now calls initializeSession with transcript loading enabled, so history reloads that welcome and the subsequent request with the same session ID returns the stored welcome again; appendAssistant then renders an identical second row after the “Earlier” divider. Skip the history refresh for a same-session welcome retry or deduplicate the replayed welcome.
Useful? React with 👍 / 👎.
a2b7946 to
58d97e9
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 58d97e99e0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (params.reset) { | ||
| appendTranscriptReset(); |
There was a problem hiding this comment.
Record the reset boundary before fallible initialization
When a reset: true request arrives while inference verification or welcome construction fails, openclaw.chat has already removed and disposed the existing session, but execution returns before this marker is written. A later ordinary fresh request therefore seeds the replacement engine from the pre-reset durable transcript, undoing the reset across recovery or restart. Persist the boundary when the old session is reset, before the fallible inference/welcome steps.
Useful? React with 👍 / 👎.
| if (loadTranscript) { | ||
| await this.refreshTranscriptHistory(client, epoch); |
There was a problem hiding this comment.
Do not serialize chat startup behind history loading
When openclaw.chat.history is slow or stops responding, this awaited refresh delays the welcome request for the full 15-second history timeout; sending also remains true, so the composer is disabled during that delay. This contradicts the additive-history behavior promised by refreshTranscriptHistory: a history failure eventually falls through, but it still blocks chat startup. Start the welcome independently of the bounded history read and reconcile the rows without delaying interaction.
Useful? React with 👍 / 👎.
|
Merged via squash.
|
…tory (openclaw#111440) * feat(system-agent): durable rolling transcript with openclaw.chat.history * chore(ui): scanner-safe auth root in custodian session ownership key * fix(system-agent): durable reset boundary for transcript seeding * fix(ui): ownership-aware custodian session rotation with capability gating * fix(ui): bounded history load and reconnect-safe transcript refresh * fix(ui): keep unknown-outcome warning and event nudges across transport transitions * fix(ui): flag-backed unknown-outcome warning independent of retry state * fix(ui): armed ownership boundaries and abandon-before-rotate ordering * chore(ui): localize the server-side sensitive mask in durable history * fix(ui): repair rebase-dropped import and mock arity * chore: gate fixes — void history handler, module-local transcript internals * refactor(gateway): leaf history-turn contract to keep the module graph acyclic * chore(gateway): stamp openclaw.chat.history with its introduction train * test(gateway): record openclaw.chat.history in the 2026.7 train pin
…tory (openclaw#111440) * feat(system-agent): durable rolling transcript with openclaw.chat.history * chore(ui): scanner-safe auth root in custodian session ownership key * fix(system-agent): durable reset boundary for transcript seeding * fix(ui): ownership-aware custodian session rotation with capability gating * fix(ui): bounded history load and reconnect-safe transcript refresh * fix(ui): keep unknown-outcome warning and event nudges across transport transitions * fix(ui): flag-backed unknown-outcome warning independent of retry state * fix(ui): armed ownership boundaries and abandon-before-rotate ordering * chore(ui): localize the server-side sensitive mask in durable history * fix(ui): repair rebase-dropped import and mock arity * chore: gate fixes — void history handler, module-local transcript internals * refactor(gateway): leaf history-turn contract to keep the module graph acyclic * chore(gateway): stamp openclaw.chat.history with its introduction train * test(gateway): record openclaw.chat.history in the 2026.7 train pin
Related: #110896
What Problem This Solves
Ask OpenClaw conversations were process-local by design (8-session LRU in the gateway) — a restart, eviction, or reload erased the operator's exchange with the system agent. Admins could not revisit yesterday's setup conversation, and the model lost all cross-restart context.
Why This Change Was Made
Phase 4 of #110896 — the conversation becomes the machine's durable logbook:
system-agent-transcriptscope in the shared state DB (newest 1000 rows; scope reuse, no schema change). Only the engine's already-masked history is ever persisted — sensitive wizard replies are redacted before they enter history, so credentials structurally cannot reach the store.openclaw.chat.history(additiveoperator.adminRPC, Swift/Kotlin clients regenerated): serves the transcript tail; the custodian UI renders it above an "Earlier" divider before the live welcome, with a bounded (15s) load that can never block chat.reset: truewrites a durable boundary marker — reset survives eviction and restarts without deleting the logbook; markers never appear in RPC output.User Impact
The Ask OpenClaw thread persists across gateway restarts and reconnects — one continuous maintenance logbook per machine, with the model remembering prior exchanges. Sensitive input remains masked everywhere (live, persisted, and re-rendered history).
Evidence
Focused suites (all pass): server handler 29 (persist-on-turn, tail seeding, reset boundary, history limits/order, sensitive masking), transcript store 4 (append/tail/prune/reset marker with real SQLite reopen), custodian UI 42 across 6 files (history render + divider, rotation matrix: same-ownership swap, ownership change, unsupported gateway, transient drop, abandoned-turn warning, nudge survival), protocol schema 6, gateway chat 87; full UI shard 337 files / 4734 tests green post-rebase;
pnpm protocol:check-equivalent regen clean.Live proof on a session-owned dev gateway built from this branch (isolated state dir, port 19877, Anthropic key via 1Password env-injection):
openclaw.setup.detectfound the env key;openclaw.setup.activateverifiedanthropic/claude-haiku-4-5with a real completion (28s).openclaw.chatwelcome + a real agentic turn ("is my gateway healthy?" → live model reply).openclaw.chat.historyreturned the full prior conversation — durability proven end-to-end.invalid: true), content-identical restore (opaqueChange), offline edit across restart (startuprecord), all visible viaopenclaw.changes.list; fingerprint key file created 0600.openclaw doctoron a pre-program config reports no repairs (the doctor invariant holds — nothing to migrate).Autoreview (codex/gpt-5.6-sol, xhigh): two-pass reviews (scanner-safe split) iterated through session-boundary, reset-durability, and resilience findings to convergence; the final flagged item (client-side re-masking of history) was consciously resolved by localizing the server's mask marker — the server-side masking guarantee is the boundary, proven by tests and the live run.