Skip to content

fix(agents): preserve post-compaction continuation prompts - #136236

Merged
vincentkoc merged 2 commits into
mainfrom
refactor/qa-lab-sse-fixture
Sep 4, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
refactor/qa-lab-sse-fixture

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

OpenAI Responses can finish an attempt with only a compaction checkpoint and no visible assistant answer. The runner requested a continuation, but split that instruction from the session prompt owner. A later reasoning-only or empty-response retry could then replace the active prompt and silently drop the compaction constraint before the model produced a visible answer.

This PR also consolidates duplicate one-shot OpenAI Responses SSE test writers onto the existing shared fixture.

Root Cause And Fix

Prompt identity, persistence, and prepared-user handling belong to sessionPromptState, while compaction continuation was previously appended from separate retry state during dispatch. The first repair moved it into the active prompt, but represented it as the same replaceable value used by later retry instructions.

The canonical fix keeps one session-owned prompt model with two components:

  • the latest replaceable per-attempt retry instruction
  • an independently retained compaction continuation overlay

Reasoning-only, missing-assistant, and empty-response retries replace only the base instruction. Visible or terminal resolution clears the retained overlay before any final-revision prompt is installed. The original operator prompt is never replayed because the compaction checkpoint already owns it.

User Impact

Compaction-only OpenAI Responses attempts now retain their continuation constraint through chained invisible retries and continue to a visible final answer.

Evidence

Exact head: e3305f44a7eb4f5124d5ef3b9d04deefb2df5fdd

  • pre-fix reproduction: compaction followed by reasoning-only retry dropped the continuation instruction
  • focused unit coverage: 63 tests passed (session prompt state 15, terminal resolution 48)
  • real Gateway/model-transport E2E: 1 test passed
  • request 3 retains the compaction checkpoint and continuation instruction exactly once
  • request 3 includes the reasoning-only retry instruction exactly once
  • changed-surface gate passed: core/root test typechecks, dead exports, database-first, import cycles, formatting, and lint
  • exact-head hosted CI: 131 passed, 45 skipped, 0 failed
  • unrelated Slack loopback timeout reproduced as healthy locally (19 ms) and passed on the isolated failed-job rerun
  • independent high-reasoning review: no P0-P2 findings; owner-level fix judged best
  • direct Codex contract check: reasoning and compaction are distinct response items; reasoning-only output is not a visible assistant answer
  • fresh main: 6a97159ececbf6c0f5a2180b97d761ba1c5fe4df
  • no fresh-main commits touch the repaired paths; synthetic merge tree 5f13ce26fc1f6ded7f02c525dd6dc5ab36b76813

ClawSweeper Follow-Up

Applied the required rank-up move and P1 finding:

  • compaction continuation survives reasoning-only and empty-response retry prompts
  • shared-state coverage exercises compaction -> reasoning -> empty retry
  • Gateway request-shape coverage exercises compaction -> reasoning-only -> visible answer

The reported data-model compatibility item is not applicable: this changes ephemeral in-memory prompt composition only. No serialized state, schema, migration, config, protocol, or persistence contract changes.

Test Audit

The regression coverage is split by owner:

  • session prompt state proves overlay composition, replacement, exact-once retention, and visible-path release
  • terminal resolution proves the real retry ordering and lifecycle boundary
  • the Gateway E2E proves the provider-visible request sequence

The shared SSE helper remains framing-only. Scenario events and behavioral assertions stay local.

Scope

  • production: +26/-11 (net +15)
  • tests/test support: +309/-152 (net +157)
  • docs/changelog: +0/-0

The production growth is the session-owned overlay and explicit lifecycle release seam; moving it into dispatch or individual retry callers would recreate split ownership.

@vincentkoc vincentkoc self-assigned this Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Sep 2, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Sep 2, 2026
@clawsweeper

clawsweeper Bot commented Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 12:50 PM ET / 16:50 UTC.

ClawSweeper review

What this changes

The PR makes OpenAI Responses compaction continuation a session-owned prompt overlay, adds chained-retry regression coverage, and reuses a shared SSE test helper.

Merge readiness

⛔ Blocked before merge - 5 items remain

Keep open: the prior P1 finding is fixed at the current head, and the member-authored PR carries the protected maintainer label requiring explicit maintainer review before merge.

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

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The current head resolves the prior P1 with focused owner and Gateway-boundary coverage; maintainer review and CI are separate merge gates.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored PR is exempt from the external-contributor proof gate; source inspection confirms a Gateway-to-local-model regression scenario, while its claimed execution was not rerun here.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored PR is exempt from the external-contributor proof gate; source inspection confirms a Gateway-to-local-model regression scenario, while its claimed execution was not rerun here.
Evidence reviewed 7 items Prompt ownership repair: The session owner separately retains the compaction instruction and composes it with replaceable retry guidance exactly once.
Retry and release lifecycle: Reasoning-only and empty-response paths return before clearing the overlay; terminal and visible paths release it before final-revision guidance is installed.
Dispatch consumer: Each attempt reads the composed session-owned prompt rather than appending a separate retry-state instruction at dispatch.
Findings None None.
Security None None.

How this fits together

The embedded agent runner converts an operator prompt and model output into successive provider requests and a visible answer. A compaction checkpoint requires an internal continuation prompt that must remain present through invisible retries.

flowchart LR
  A[Operator prompt] --> B[Embedded agent runner]
  B --> C[Session prompt state]
  C --> D[Model request]
  D --> E[Compaction or invisible retry]
  E --> C
  D --> F[Visible final answer]
Loading

Decision needed

Question Recommendation
Should this protected member-authored retry-lifecycle repair be approved once exact-head checks complete? Approve after checks: Accept the owner-bound prompt lifecycle once the exact head has green required checks.

Why: The maintainer label and MEMBER authorship require explicit maintainer judgment even though the prior P1 finding is resolved.

Before merge

  • Resolve merge risk (P1) - The repair changes session-scoped prompt composition across retries; merge only with the focused exact-head regression coverage and required checks green.
  • Resolve merge risk (P1) - The bug-fix branch has a net production increase of 15 lines; the retained overlay and its explicit release seam are the smallest owner-bound representation found for this lifecycle.
  • Complete next step (P2) - Obtain protected maintainer review and wait for exact-head required checks before merge.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +15, Tests +157. Total +172 across 22 files.

View PR surface stats
Area Files Added Removed Net
Source 5 26 11 +15
Tests 17 309 152 +157
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 22 335 163 +172

Review metrics

Metric Value Why it matters
Production versus test delta production +26/-11 (net +15); tests and test support +309/-152 (net +157) Most added code is regression coverage; the production growth implements the prompt-owner overlay and release boundary.

Stored data model

Persistent data-model change detected: serialized state: src/agents/embedded-agent-runner/run-loop.ts, serialized state: src/agents/embedded-agent-runner/run/session-prompt-state.ts, unknown-data-model-change: src/agents/embedded-agent-runner/run/session-prompt-state.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Merge with the owner-bound lifecycle (recommended)
    Accept the session-state change after maintainer review and exact-head checks confirm the existing retry-sequence coverage.
  2. Pause for additional proof
    Keep the PR open if maintainers require evidence beyond the Gateway compaction-to-reasoning-to-visible-answer sequence.

Technical review

Best possible solution:

Retain the session-owned overlay and explicit terminal release, then merge after protected maintainer review confirms the exact-head Gateway regression and required checks.

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

Yes: the focused Gateway test defines a deterministic compaction → reasoning-only → visible-answer path that would expose the prior overwrite; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes: composing the retained continuation in the session prompt owner prevents later retry guidance from replacing it while preserving the terminal release boundary.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored PR is exempt from the external-contributor proof gate; source inspection confirms a Gateway-to-local-model regression scenario, while its claimed execution was not rerun here.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: The repaired retry sequence can otherwise silently fail to reach a visible agent answer.
  • merge-risk: 🚨 session-state: The branch changes session-scoped internal prompt retention and release across retries.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored PR is exempt from the external-contributor proof gate; source inspection confirms a Gateway-to-local-model regression scenario, while its claimed execution was not rerun here.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vito Cappello: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (5 earlier review cycles)
  • reviewed 2026-09-02T10:01:18.771Z sha 0b6b331 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-02T10:39:15.740Z sha 0b6b331 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-03T07:42:12.706Z sha 9e91deb :: needs changes before merge. :: none
  • reviewed 2026-09-03T07:50:50.813Z sha 9e91deb :: needs maintainer review before merge. :: none
  • reviewed 2026-09-04T15:52:17.436Z sha 1694df0 :: blocked before merge. :: [P1] Retain compaction continuation through later retries

@vincentkoc
vincentkoc force-pushed the refactor/qa-lab-sse-fixture branch from 0b6b331 to 9e91deb Compare September 3, 2026 07:33
@vincentkoc
vincentkoc marked this pull request as ready for review September 3, 2026 07:46
@vincentkoc
vincentkoc force-pushed the refactor/qa-lab-sse-fixture branch from 9e91deb to cb77a12 Compare September 4, 2026 15:01
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations agents Agent runtime and tooling size: M and removed size: XS labels Sep 4, 2026
@vincentkoc vincentkoc changed the title refactor(qa): reuse OpenAI responses SSE fixture fix(agents): preserve post-compaction continuation prompts Sep 4, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

The head now includes a root-cause runtime repair for the compaction replay E2E failure, with owner-level unit coverage, real Gateway proof, and updated production/test LOC metrics in the PR body.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc
vincentkoc force-pushed the refactor/qa-lab-sse-fixture branch from cb77a12 to 1694df0 Compare September 4, 2026 15:21
@clawsweeper clawsweeper Bot added 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Sep 4, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

The P1 chained-retry finding is fixed at e3305f44a7eb4f5124d5ef3b9d04deefb2df5fdd.

  • session prompt state retains compaction continuation independently from reasoning-only and empty-response retry prompts
  • visible and terminal paths release the retained overlay before final-revision prompts
  • focused coverage passes 63/63
  • real Gateway coverage now proves compaction -> reasoning-only -> visible answer and exact-once request text
  • full changed-surface gate passes

The PR body contains the current root cause, production/test LOC, direct protocol evidence, and fresh-main merge proof.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 4, 2026
@vincentkoc
vincentkoc merged commit fb716dc into main Sep 4, 2026
319 of 321 checks passed
@vincentkoc
vincentkoc deleted the refactor/qa-lab-sse-fixture branch September 4, 2026 17:00
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 4, 2026
Backport the canonical session-prompt owner repair from #136236
(fb716dc) for the 2026.9.2 release.
Preserve continuation constraints when compaction, reasoning, or empty-result
retries replace the active prompt; retain the stronger Gateway replay proof.

Validated with original-code failures, 113 owner/sibling tests, the full
changed-file gate, independent review, and the rebuilt Gateway E2E.

Co-authored-by: Vincent Koc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…136236)

* fix(agents): preserve post-compaction continuation prompts

* fix(agents): retain compaction continuation across retries
etzelm added a commit to etzelm/openclaw that referenced this pull request Oct 20, 2026
- openclaw#177050 (07b59a0) persists internal retry prompts as hidden internal_system rows.
- openclaw#136236 retained the compaction continuation instruction across later invisible retries because that prompt was not saved.
- A reasoning-only retry after a compaction continuation then sent the instruction twice: once replayed from history and once appended to the retry prompt.
- Drop the retained instruction once the internal prompt carrying it is persisted.
- Fixes test/gateway-openai-compaction-replay.e2e.test.ts on main.
roboclaw-bot pushed a commit that referenced this pull request Oct 21, 2026
… native login (#164796)

* fix(agents): restore saved history for fresh Claude CLI sessions on a native login

A Claude CLI conversation on a native login with no forwarded credential
had no history owner, so saved history was refused whenever its Claude
session was replaced. The owner is now the account Anthropic's OAuth
profile endpoint attests for the exact access token the child Claude
would use, rechecked synchronously at every spawn, prompt send and
coverage commit against an in-process attestation cache.

Rebased onto main as one commit. On main a resumed turn also receives
durable reference context and interrupted inputs, so any native turn
whose writer replays history now refuses an unattested credential at
spawn and send, and a turn that runs without saved history receives no
interrupted inputs. SessionManager appends committed by the metadata
worker take the host's live owner check on their transaction admission,
and a writer that needs the check never advances coverage on a path
that cannot ask for it.

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

* fix(anthropic): withhold prompt hook context when the owner check fails

- The UserPromptSubmit hook response that carries the turn's private
  context now takes the full account-bound check at its final write,
  not only the stream check.
- If that check fails, Claude receives an empty hook response and the
  saved context is withheld.
- Docs: the prompt hook is listed among the points where the native
  login is rechecked.

* fix(anthropic): require an explicit opt-in for native login attestation

- Native Claude login attestation now runs only when
  plugins.entries.anthropic.config.historyRecovery.attestNativeLogin
  is true. It is off by default, and while it is off history recovery
  never reads or sends the native token, so a native login keeps the
  current refusal.
- The anthropic plugin manifest declares the setting with a default of
  false and a UI hint naming the endpoint the token is sent to.
- The stream check for control requests is no longer part of the
  plugin SDK CliBackendExecuteContext type. The host passes it to the
  bundled Claude runtime the way it passes auth credentials.
- Config baseline: the plugin surface grows by these two keys (budget
  4527 to 4529).
- Removed a duplicate Keychain read test.
- Docs: the native login clause names the opt-in and its default.

* fix(cli-runner): port native history owner onto main's boundary design

- adopt main's async assertReadable and transport-side private history checks
- keep the attestNativeLogin opt-in and the in-transaction owner probe
- split the private-input runtime tests into cli-runtime.private-input.test.ts
- regenerate the config baseline hash

* simplify: drop duplicate Keychain readers and same-path native-login tests

Folds the two added Keychain readers into the existing ones, removes duplicate and same-path test cases, fixes a prepared-backend leak in prepare-native-history.test.ts, and restores the fresh-recovery-turn, non-native auth env and split secure-storage guards. Production code is unchanged except the reader fold.

* refactor(cli-runner): own the native owner-check failure in one place

- readNativeOwner treats a login lookup that throws as no owner, so the
  coverage check (worker probe and host actor memory) keeps rows uncovered
  and a turn without saved history runs on instead of failing
- answerCliHistoryOwnerProbe drops its now-redundant catch
- writer exposes checkNativeLoginBoundary directly instead of a forwarder
- planCliHistoryBoundary keeps main's inline provider normalization
- resolveCliChildEnv comment names the installation target layer too
- helper-only cli-history-owner-probe.test.ts replaced by a real
  SessionManager and boundary case in the native-login suite

* test(cli-runner): prove native-login paths found untested by mutation

- Add an incognito session case: the host actor path covers a native-login
  row only while the attested login holds (no test failed when its owner
  check was removed, trusted or dropped).
- Assert a refresh-due turn reads no interrupted inputs; a same-login turn
  still does (no test failed when the turn read them).
- Use a parseable Keychain payload without a usable login in the
  unusable-payload case, so it pins the readable-but-unusable branch.
- Drop four native-login cases and one prepare case whose every caught
  mutation is caught by a kept case on the same path, and the HTTP 500
  row that repeats the HTTP 401 row.

* refactor(cli-runner): drop the child env base parameter no caller passes

resolveCliChildEnv always reads the Gateway process env; the extraction is now a pure move of the executor's lines.

* fix(agents): send a compaction continuation once after it is persisted

- #177050 (07b59a0) persists internal retry prompts as hidden internal_system rows.
- #136236 retained the compaction continuation instruction across later invisible retries because that prompt was not saved.
- A reasoning-only retry after a compaction continuation then sent the instruction twice: once replayed from history and once appended to the retry prompt.
- Drop the retained instruction once the internal prompt carrying it is persisted.
- Fixes test/gateway-openai-compaction-replay.e2e.test.ts on main.

---------

Co-authored-by: Mitchell Etzel <[email protected]>
Co-authored-by: xydigitLybnnnn <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 21, 2026
The 2026.10.6 backport of #177050 (b1e91c4) persists internal retry
prompts as hidden internal_system rows, but the line kept #136236's
retained compaction continuation instruction across later invisible
retries. A reasoning-only retry after a compaction continuation then sent
the instruction twice: once replayed from history and once appended to
the retry prompt (test/gateway-openai-compaction-replay.e2e.test.ts,
Repo E2E Gateway 2/4).

Drop the retained instruction once the internal prompt carrying it is
persisted. Partial backport of the session-prompt-state hunk and its test
from main 29ce97a (#164796); the rest of that PR is unrelated.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
… native login (openclaw#164796)

* fix(agents): restore saved history for fresh Claude CLI sessions on a native login

A Claude CLI conversation on a native login with no forwarded credential
had no history owner, so saved history was refused whenever its Claude
session was replaced. The owner is now the account Anthropic's OAuth
profile endpoint attests for the exact access token the child Claude
would use, rechecked synchronously at every spawn, prompt send and
coverage commit against an in-process attestation cache.

Rebased onto main as one commit. On main a resumed turn also receives
durable reference context and interrupted inputs, so any native turn
whose writer replays history now refuses an unattested credential at
spawn and send, and a turn that runs without saved history receives no
interrupted inputs. SessionManager appends committed by the metadata
worker take the host's live owner check on their transaction admission,
and a writer that needs the check never advances coverage on a path
that cannot ask for it.

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

* fix(anthropic): withhold prompt hook context when the owner check fails

- The UserPromptSubmit hook response that carries the turn's private
  context now takes the full account-bound check at its final write,
  not only the stream check.
- If that check fails, Claude receives an empty hook response and the
  saved context is withheld.
- Docs: the prompt hook is listed among the points where the native
  login is rechecked.

* fix(anthropic): require an explicit opt-in for native login attestation

- Native Claude login attestation now runs only when
  plugins.entries.anthropic.config.historyRecovery.attestNativeLogin
  is true. It is off by default, and while it is off history recovery
  never reads or sends the native token, so a native login keeps the
  current refusal.
- The anthropic plugin manifest declares the setting with a default of
  false and a UI hint naming the endpoint the token is sent to.
- The stream check for control requests is no longer part of the
  plugin SDK CliBackendExecuteContext type. The host passes it to the
  bundled Claude runtime the way it passes auth credentials.
- Config baseline: the plugin surface grows by these two keys (budget
  4527 to 4529).
- Removed a duplicate Keychain read test.
- Docs: the native login clause names the opt-in and its default.

* fix(cli-runner): port native history owner onto main's boundary design

- adopt main's async assertReadable and transport-side private history checks
- keep the attestNativeLogin opt-in and the in-transaction owner probe
- split the private-input runtime tests into cli-runtime.private-input.test.ts
- regenerate the config baseline hash

* simplify: drop duplicate Keychain readers and same-path native-login tests

Folds the two added Keychain readers into the existing ones, removes duplicate and same-path test cases, fixes a prepared-backend leak in prepare-native-history.test.ts, and restores the fresh-recovery-turn, non-native auth env and split secure-storage guards. Production code is unchanged except the reader fold.

* refactor(cli-runner): own the native owner-check failure in one place

- readNativeOwner treats a login lookup that throws as no owner, so the
  coverage check (worker probe and host actor memory) keeps rows uncovered
  and a turn without saved history runs on instead of failing
- answerCliHistoryOwnerProbe drops its now-redundant catch
- writer exposes checkNativeLoginBoundary directly instead of a forwarder
- planCliHistoryBoundary keeps main's inline provider normalization
- resolveCliChildEnv comment names the installation target layer too
- helper-only cli-history-owner-probe.test.ts replaced by a real
  SessionManager and boundary case in the native-login suite

* test(cli-runner): prove native-login paths found untested by mutation

- Add an incognito session case: the host actor path covers a native-login
  row only while the attested login holds (no test failed when its owner
  check was removed, trusted or dropped).
- Assert a refresh-due turn reads no interrupted inputs; a same-login turn
  still does (no test failed when the turn read them).
- Use a parseable Keychain payload without a usable login in the
  unusable-payload case, so it pins the readable-but-unusable branch.
- Drop four native-login cases and one prepare case whose every caught
  mutation is caught by a kept case on the same path, and the HTTP 500
  row that repeats the HTTP 401 row.

* refactor(cli-runner): drop the child env base parameter no caller passes

resolveCliChildEnv always reads the Gateway process env; the extraction is now a pure move of the executor's lines.

* fix(agents): send a compaction continuation once after it is persisted

- openclaw#177050 (6a6f792) persists internal retry prompts as hidden internal_system rows.
- openclaw#136236 retained the compaction continuation instruction across later invisible retries because that prompt was not saved.
- A reasoning-only retry after a compaction continuation then sent the instruction twice: once replayed from history and once appended to the retry prompt.
- Drop the retained instruction once the internal prompt carrying it is persisted.
- Fixes test/gateway-openai-compaction-replay.e2e.test.ts on main.

---------

Co-authored-by: Mitchell Etzel <[email protected]>
Co-authored-by: xydigitLybnnnn <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 27, 2026
The 2026.10.6 backport of #177050 (b1e91c4) persists internal retry
prompts as hidden internal_system rows, but the line kept #136236's
retained compaction continuation instruction across later invisible
retries. A reasoning-only retry after a compaction continuation then sent
the instruction twice: once replayed from history and once appended to
the retry prompt (test/gateway-openai-compaction-replay.e2e.test.ts,
Repo E2E Gateway 2/4).

Drop the retained instruction once the internal prompt carrying it is
persisted. Partial backport of the session-prompt-state hunk and its test
from main 29ce97a (#164796); the rest of that PR is unrelated.

(cherry picked from commit 236b0c1)
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 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. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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