Skip to content

fix: agent stops replying when a session transcript has no header row - #115080

Merged
galiniliev merged 3 commits into
openclaw:mainfrom
galiniliev:fix/headerless-session-transcript
Jul 28, 2026
Merged

galiniliev merged 3 commits into
openclaw:mainfrom
galiniliev:fix/headerless-session-transcript

Conversation

@galiniliev

@galiniliev galiniliev commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where an agent would stop replying when its current SQLite
session transcript contained canonical conversation events but no initial
type: "session" header row. Every inbound message then failed with
Persisted legacy session transcripts require doctor/import migration before runtime use,
while openclaw doctor offered no repair.

The state was observed in a real channel-bound session with 11 canonical events
and no header. It also breaks consumers that require the persisted header,
including Codex history replay, manual compaction, and trajectory export.

Why This Change Was Made

Runtime remains strict: only a physically empty transcript may initialize
lazily, while any persisted headerless or legacy-shaped transcript continues to
fail closed. openclaw doctor now detects headerless transcripts only when all
known rows already satisfy the current schema, and openclaw doctor --fix
repairs them at the storage owner boundary.

The repair first takes a read-only snapshot, then re-reads and revalidates the
authoritative rows and session binding inside one synchronous SQLite
transaction. It prepends a current header, rewrites and reindexes the transcript,
rotates its generation, and preserves existing event IDs, parent links, row
timestamps, and session-list recency. Malformed, duplicate-identity, or legacy
rows remain untouched. No schema change is required.

User Impact

openclaw doctor now identifies affected sessions and tells operators to run
openclaw doctor --fix. After repair, the agent can resume with its existing
conversation history instead of failing every turn. Existing canonical event
identity and branching state remain stable.

Evidence

Focused real-SQLite integration coverage in
src/commands/doctor-session-transcript-headers.test.ts verifies:

  • runtime rejects the affected state before repair;
  • dry-run detection does not mutate rows;
  • --fix prepends a current header and preserves IDs, parent links, row
    timestamps, and sequence order;
  • transcript identity and active-event indexes are rebuilt;
  • session recency is invalidated monotonically without jumping to wall-clock
    time;
  • the repaired transcript opens with its prior history;
  • the repair is idempotent;
  • legacy, malformed, invalid-leaf, and duplicate-identity rows stay rejected;
  • header cwd comes from the owning session only, with the configured agent
    workspace as fallback.

CI is green for head cbba8f0a684b9df28676567b45c81ab9fa29b987, including
openclaw/ci-gate, check-docs, check-lint, the SQLite session schema and
flip-proof gates, and the session transcript/accessor boundary checks:
https://github.com/openclaw/openclaw/actions/runs/30382661735

Proof gap: no separate packaged or Docker end-to-end lane was run; the final
repair path is covered by the focused SQLite integration test and full PR CI.

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Jul 28, 2026
@galiniliev
galiniliev marked this pull request as ready for review July 28, 2026 08:28
@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jul 28, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 28, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 28, 2026, 11:44 AM ET / 15:44 UTC.

ClawSweeper review

What this changes

The PR recognizes headerless but otherwise canonical SQLite session transcripts as current data, preserves their event identity at runtime, and adds a Doctor repair that prepends a header while rebuilding transcript projections.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

This is an active, focused regression repair with convincing real-database evidence, but it changes durable session admission and adds a Doctor-owned SQLite rewrite. It should remain open for explicit maintainer approval and completion of the currently failing documentation/lint checks rather than being cleaned up or auto-closed.

Priority: P1
Reviewed head: 96785b07f179f9e43eaab65056e0f6843a2d3586
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The PR has strong real-world evidence and focused state-preservation coverage, with remaining merge work centered on explicit persistence-policy approval and resolving the active check failures.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body provides redacted after-fix output from a real affected SQLite transcript, showing the prior runtime failure disappears and persisted IDs remain stable; no private database details should be added to further proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body provides redacted after-fix output from a real affected SQLite transcript, showing the prior runtime failure disappears and persisted IDs remain stable; no private database details should be added to further proof.
Evidence reviewed 6 items Runtime admission is deliberately narrowed: The changed empty-transcript guard distinguishes a physically empty transcript from opaque persisted rows, preventing runtime initialization from silently replacing malformed stored history.
Doctor owns persistent header repair: The branch adds a dedicated header-health contribution that detects canonical headerless SQLite transcripts and performs a guarded repair rather than adding a runtime fallback writer.
Repair is registered in the standard Doctor flow: The initial Doctor health contributions register a new session-transcript-header check, making the repair reachable through the normal diagnostic and --fix workflow.
Findings None None.
Security None None.

How this fits together

OpenClaw loads an agent’s SQLite transcript before an inbound channel message can run the agent. The session loader either accepts a canonical transcript, routes legacy data to Doctor, or initializes an empty session; Doctor can then repair persistent transcript state and its derived indexes.

flowchart TD
  A[Inbound channel message] --> B[SQLite transcript loader]
  B --> C{Header and event shape}
  C -->|Canonical but headerless| D[Use current in-memory header]
  C -->|Legacy or malformed| E[Doctor diagnostic]
  C -->|Physically empty| F[Initialize new session]
  D --> G[Agent reply]
  E --> H[Guarded SQLite transcript repair]
  H --> B
Loading

Decision needed

Question Recommendation
Should OpenClaw adopt this new Doctor --fix repair for canonical headerless SQLite transcripts as the supported persisted-state migration path? Approve the Doctor repair path: Accept the runtime predicate and Doctor-owned rewrite after confirming the focused tests cover the intended durable-state invariants.

Why: The runtime classification is narrowly scoped, but the new behavior also transactionally rewrites durable transcript data and affects session recency and derived indexes; this persistence policy needs explicit owner approval.

Before merge

  • Resolve merge risk (P1) - The new Doctor path replaces durable transcript rows and derived projections; merge review should confirm it preserves event IDs, parent links, sequence order, row timestamps, session-window recency, and index generation for every accepted shape.
  • Resolve merge risk (P1) - The branch is behind current main, and check-docs plus check-lint are currently failing; refresh and resolve the actual failures before landing, without treating base drift alone as a code-regression finding.
  • Complete next step (P2) - The remaining action is explicit approval of the new Doctor-owned durable-state repair and a refreshed green branch, not an automated code repair.
Agent review details

Security

None.

PR surface

Source +456, Tests +366, Docs +7. Total +829 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 7 461 5 +456
Tests 1 366 0 +366
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 834 5 +829

Review metrics

Metric Value Why it matters
New persistent repair surface 1 new Doctor health contribution It adds a user-invoked rewrite of SQLite transcript data, so upgrade and state-preservation review matters before merge.

Stored data model

Persistent data-model change detected: migration/backfill/repair: docs/cli/doctor.md, migration/backfill/repair: src/commands/doctor-session-sqlite-readers.ts, migration/backfill/repair: src/commands/doctor-session-transcript-headers.test.ts, migration/backfill/repair: src/commands/doctor-session-transcript-headers.ts, migration/backfill/repair: src/flows/doctor-health-contribution-runners.state.ts, migration/backfill/repair: src/flows/doctor-health-contributions-initial.ts, and 7 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Validate and merge the guarded repair (recommended)
    Confirm the Doctor transaction preserves all durable transcript and session-window invariants, then refresh the branch and merge with passing required checks.
  2. Retain runtime relief and defer persistence repair
    If maintainers do not want Doctor to rewrite transcript rows in this release, split the durable repair into a separately approved migration change.

Technical review

Best possible solution:

Keep runtime strict for malformed or genuinely legacy transcripts, accept only fully canonical headerless rows, and land the Doctor repair once a maintainer confirms its persisted-state contract and the refreshed branch has the required checks green.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: a SQLite transcript with canonical event rows but no session header takes the legacy rejection path described by the PR, and the contributor supplied redacted after-fix output from a real affected database. I did not independently execute the reproduction in this read-only review.

Is this the best way to solve the issue?

Yes, conditionally: keeping runtime strict for legacy-shaped rows while putting the physical header rewrite in Doctor matches the repository’s canonical-runtime and migration ownership rules. Maintainer approval is still needed because the Doctor path rewrites persisted session data.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against cbe19ed3be23.

Labels

Label justifications:

  • P1: The reported persisted-transcript condition can make an affected channel-bound agent fail before every reply.
  • merge-risk: 🚨 session-state: The branch changes durable transcript admission and adds a transaction that replaces transcript rows and rebuilds projections.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides redacted after-fix output from a real affected SQLite transcript, showing the prior runtime failure disappears and persisted IDs remain stable; no private database details should be added to further proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides redacted after-fix output from a real affected SQLite transcript, showing the prior runtime failure disappears and persisted IDs remain stable; no private database details should be added to further proof.

Evidence

What I checked:

  • Runtime admission is deliberately narrowed: The changed empty-transcript guard distinguishes a physically empty transcript from opaque persisted rows, preventing runtime initialization from silently replacing malformed stored history. (src/agents/sessions/session-manager-core.ts:73, 96785b07f179)
  • Doctor owns persistent header repair: The branch adds a dedicated header-health contribution that detects canonical headerless SQLite transcripts and performs a guarded repair rather than adding a runtime fallback writer. (src/commands/doctor-session-transcript-headers.ts:1, 96785b07f179)
  • Repair is registered in the standard Doctor flow: The initial Doctor health contributions register a new session-transcript-header check, making the repair reachable through the normal diagnostic and --fix workflow. (src/flows/doctor-health-contributions-initial.ts:326, 96785b07f179)
  • Regression coverage exercises durable transcript behavior: The added test suite covers headerless canonical transcript repair, stable IDs and parent links, row ordering, timestamps, and session recency rather than only codec-level classification. (src/commands/doctor-session-transcript-headers.test.ts:1, 96785b07f179)
  • Regression provenance: The PR’s stated regression point is the merged SQLite-only transcript refactor, whose merge commit introduced the hard legacy-session admission path this change narrows. (src/agents/sessions/session-manager-core.ts:73, 4273ca9dbd9b)
  • Real behavior proof: The PR body reports an after-fix run against a copy of a real affected SQLite transcript: the prior repeated legacy-session error disappears and persisted event IDs remain stable across loads. (96785b07f179)

Likely related people:

  • steipete: The merged SQLite-only transcript refactor identified by the PR as regression provenance is attributable to this contributor and owns the surrounding runtime/storage migration boundary. (role: introduced adjacent transcript-runtime refactor; confidence: high; commits: 4273ca9dbd9b; files: src/agents/sessions/session-manager-core.ts, src/config/sessions/session-accessor.sqlite-transcript-store.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Refresh against current main and resolve the specific check-docs and check-lint failures.
  • Have the session-storage owner confirm the Doctor rewrite’s transcript, index, and recency-preservation contract.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-07-28T08:34:14.962Z sha 87c38f89dadfe9b282e0da11405dd8619e5627c9 :: needs maintainer review before merge. :: none

@galiniliev galiniliev self-assigned this Jul 28, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: L and removed size: S labels Jul 28, 2026
@galiniliev

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@galiniliev
galiniliev force-pushed the fix/headerless-session-transcript branch 4 times, most recently from 96785b0 to 60be910 Compare July 28, 2026 16:49
Galin Iliev and others added 3 commits July 28, 2026 20:22
…gacy

Sessions whose SQLite transcript has no session header row were treated as
version 1 and hard-failed every run with "Persisted legacy session transcripts
require doctor/import migration before runtime use". Only an actual header now
declares a legacy version.

Co-authored-by: Copilot <[email protected]>
Rebuild the header at the current version instead of inferring v1, and route
header-less transcripts that still hold legacy-shaped entries to doctor.

Co-authored-by: Copilot <[email protected]>
@galiniliev
galiniliev force-pushed the fix/headerless-session-transcript branch from 60be910 to cbba8f0 Compare July 28, 2026 17:23
@galiniliev
galiniliev merged commit 8aa6763 into openclaw:main Jul 28, 2026
125 checks passed
@galiniliev

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@galiniliev
galiniliev deleted the fix/headerless-session-transcript branch July 28, 2026 18:47
vincentkoc added a commit to christian-lallo/openclaw that referenced this pull request Jul 28, 2026
* origin/main: (61 commits)
  perf(ui): debounce event-driven session list refreshes and right-size child paging (openclaw#115374)
  feat(talk): support GPT-Live realtime voice over ChatGPT OAuth (openclaw#115226)
  feat(system-agent): guide gateway configuration in Ask OpenClaw (openclaw#115363)
  fix(agents): make overflow recovery append-only via branch-and-reappend (openclaw#115271) (openclaw#115310)
  fix(macos): bound websocket ping so a dropped pong cannot orphan its continuation (openclaw#115362)
  fix(codex): isolate native hook relay startup (openclaw#115078)
  fix(ci): stop reviving superseded pull request workflows (openclaw#115378)
  feat(openshell): add workspace selection (openclaw#114952)
  fix(skills): persist workshop apply reason; correct Skill Workshop docs (openclaw#114471)
  fix: agent stops replying when a session transcript has no header row (openclaw#115080)
  perf(usage): stale-while-revalidate caches for usage.status and sessions.usage (openclaw#115369)
  fix(discord): reject invalid UTF-8 probe responses (openclaw#111734)
  feat(gateway): add memory.search operator method (openclaw#115346)
  fix(android): keep welcome action reachable with large text (openclaw#111747)
  fix(gateway): validate doctor memory agent ids (openclaw#115365)
  refactor: harden shell completion and shard Control UI E2E (openclaw#115332)
  fix(ui): anchor the thread branches menu to its trigger button (openclaw#115352)
  perf(sessions): incremental snapshot revalidation and shallow list projections (openclaw#115359)
  refactor(sessions): consolidate entry state (openclaw#115299)
  feat(ui): swap three plain Lobsterdex palettes for balloon, ascii, and portal (openclaw#115308)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
…openclaw#115080)

* fix(sessions): stop rejecting header-less persisted transcripts as legacy

Sessions whose SQLite transcript has no session header row were treated as
version 1 and hard-failed every run with "Persisted legacy session transcripts
require doctor/import migration before runtime use". Only an actual header now
declares a legacy version.

Co-authored-by: Copilot <[email protected]>

* fix(sessions): keep entry ids stable for header-less transcripts

Rebuild the header at the current version instead of inferring v1, and route
header-less transcripts that still hold legacy-shaped entries to doctor.

Co-authored-by: Copilot <[email protected]>

* fix(sessions): repair headerless transcripts in doctor

---------

Co-authored-by: Galin Iliev <[email protected]>
Co-authored-by: Copilot <[email protected]>
steipete pushed a commit that referenced this pull request Oct 8, 2026
)

* fix(sessions): stop resets from wedging never-materialized session transcripts

A /new or daily reset against a session entry whose SQLite transcript had no
rows appended the reset boundary at seq 0 with no session header. Every later
load then classified the transcript as legacy v1 and failed the session lane
on each turn, while the group silent-reply policy swallowed the generic
failure text - the bot showed typing, then nothing, forever.

- buildSessionResetBoundaryEvent builds no boundary when the transcript has
  nothing to reset; both lifecycle call sites share one owner helper.
- Loads distinguish headerless transcripts from legacy versions and point at
  "openclaw doctor --fix", which actually repairs that state (#115080).
- Transcript-repair load failures are classified as actionable rather than
  generic, so the repair notice stays visible in group chats instead of
  being silenced to NO_REPLY.

* test(auto-reply): materialize transcripts in reset-authorization fixtures

The durable-reset assertions seeded a session entry with zero transcript
rows and asserted the reset boundary landed there - exactly the headerless
seq-0 corruption the parent fix removes. Seed one message first so an
allowed reset still proves a durable boundary on a real conversation.

Co-authored-by: izshaw <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
…claw#135253)

* fix(sessions): stop resets from wedging never-materialized session transcripts

A /new or daily reset against a session entry whose SQLite transcript had no
rows appended the reset boundary at seq 0 with no session header. Every later
load then classified the transcript as legacy v1 and failed the session lane
on each turn, while the group silent-reply policy swallowed the generic
failure text - the bot showed typing, then nothing, forever.

- buildSessionResetBoundaryEvent builds no boundary when the transcript has
  nothing to reset; both lifecycle call sites share one owner helper.
- Loads distinguish headerless transcripts from legacy versions and point at
  "openclaw doctor --fix", which actually repairs that state (openclaw#115080).
- Transcript-repair load failures are classified as actionable rather than
  generic, so the repair notice stays visible in group chats instead of
  being silenced to NO_REPLY.

* test(auto-reply): materialize transcripts in reset-authorization fixtures

The durable-reset assertions seeded a session entry with zero transcript
rows and asserted the reset boundary landed there - exactly the headerless
seq-0 corruption the parent fix removes. Seed one message first so an
allowed reset still proves a durable boundary on a real conversation.

Co-authored-by: izshaw <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant