Skip to content

fix(claude-cli): keep each steered input's own origin and context - #185945

Merged
obviyus merged 2 commits into
mainfrom
fix/claude-cli-steered-input-origin
Oct 28, 2026
Merged

obviyus merged 2 commits into
mainfrom
fix/claude-cli-steered-input-origin

Conversation

@obviyus

@obviyus obviyus commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #185915, #185746

What Problem This Solves

Fixes: when a message arrives while a Claude CLI turn is running (for example a subagent's completion while its parent is busy), OpenClaw injects it into that turn. The Claude runtime then dropped that input's private context and never marked it as host input. The parent lost the child's result, and Claude told the model "The user sent a new message".

Why This Change Was Made

The host already prepares each queued input's provenance and currentInboundContext. Only the Claude injection path threw them away:

  • the UserPromptSubmit hook returned no context for injected inputs
  • the native write never set isSynthetic

Changes:

  • CliBackendMessageInjection.queueMessage takes optional per-input promptOrigin and promptContext. This is the same contract as the initial prompt. An injected input never inherits the running turn's origin: a person can steer a host turn, and a completion can arrive during a person's turn.
  • The steering adapter sets them from the input's own transcript provenance and inbound context.
  • The Claude runtime returns that context from the prompt hook, including on hook reruns, and sends host inputs with isSynthetic.
  • inter_session provenance (forwarded messages, subagent completions) is now host input as well as internal_system. A message from another session was not typed by this session's operator.
  • Removed readClaudeCliInterSessionProvenance, which read forwarded-message provenance from native prompt text. Forwarded inputs are now synthetic meta rows that the importer never reads.
    • Local Claude runs always use the plugin transport, and node-placed Claude history is not imported by the Gateway.
    • So the parser only served transcripts written before this change: those rows now show as plain user rows.

The canonical transcript is unchanged: forwarded messages keep their provenance, sender and visibility.

User Impact

A subagent result that arrives while its Claude CLI parent is busy now reaches the parent with its content, and the parent no longer treats it as the user's message. When Claude falls back to another provider, its recent-turns prelude skips forwarded prompts, as it already skips cron and recovery prompts (#185746).

Evidence

Live, real Claude CLI (Claude Code 2.1.310). I ran isolated Gateways on main (53763ed) and on this branch:

  • The parent spawns a subagent that must reply with a secret, then runs sleep 75, then reports the subagent's reply.
  • It must not poll or use subagents/sessions_history.
  • The subagent finishes during the sleep, so its completion is steered into the running turn.
Parent's answer How Claude presented the steered completion to the model
main NO-RESULT "The user sent a new message while you were working"
this PR the subagent's exact secret "[MESSAGE FROM NON-USER SOURCE - NOT USER INPUT]", with the completion context

In an earlier run without the polling ban, the main parent had to fetch the result itself with subagents wait and sessions_history. On this branch it already had the result.

Tests

  • execute-plugin.steering.test.ts: the real Claude stdio transport against a fixture CLI.
    • Steered internal_system and inter_session inputs are sent as synthetic; human steering is not.
    • A steered subagent completion delivers its result ("The fixture count is 42.") through the prompt hook. This fails on main.
    • A recorder failure before native acceptance rejects the input instead of losing it.
  • cli-runtime.test.ts: an injected input's context is returned on the first hook pass and on reruns.
  • execute-plugin.test.ts: the origin comes from provenance kind only.
  • These suites pass: cli-session-history.routed-prompts, session-history.subagent-visibility, chat-history-handler.cli-import, cli-session-history*, extensions/anthropic/cli-runtime.
  • oxlint and oxfmt are clean.

Size: +169/−125. Production is +93/−77; the rest is the steering regression tests (net +28 test lines). The test-line ratchet passes against current main without a ceiling change.

Credit: @Marvinthebored found this and wrote the original fix and its tests in #185915. This PR is the first part of that change.

Merge danger: two-way door. A revert restores the old injection path. Native meta rows already written stay hidden. Blast radius: Claude CLI steered and forwarded inputs, and third-party CLI backends that implement registerMessageInjection (the new argument is optional).

@clawsweeper

clawsweeper Bot commented Oct 27, 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 docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling extensions: anthropic size: M labels Oct 27, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserves each steered Claude input’s private context and provenance instead of discarding context or attributing forwarded input to the operator.

Example: A subagent returns “The fixture count is 42.” while its Claude parent is busy.

  • Before: The parent receives the runtime-event prompt without the completion result.
  • After: The parent receives the result through private prompt context, with the input marked as non-user input.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused repair with reported shipped-entry-point proof, distinct transport regressions, successful current-head gates, and no open findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The body reports real Claude Code 2.1.310 through isolated Gateways: a child completes during the parent’s foreground sleep, polling is prohibited, and the branch parent returns the child’s secret where main returns NO-RESULT; native presentation also changes to non-user input with completion context. The subsequent commit changes only tests, so this behavior evidence remains applicable.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A busy Claude parent misses a child’s completion result and treats the injected notification as a new message from the operator.
Reason: The repair restores an existing steering contract with clear user value; the collaborator-authored PR records the intended history and fallback tradeoffs.

Merge readiness

✅ Ready for maintainer review

Keep open for merge: this PR fixes a current Claude steering defect, and the prior test-ratchet blocker is resolved; no actionable patch defects remain.

Priority: P2
Reviewed head: 366cb08fd1d059df6fbc1184b13d25eb6f423ac0

Before merge

None.

Findings

None.

Agent review details

How this fits together

The CLI runner admits queued session inputs and passes them to the Anthropic plugin, which writes Claude stream-JSON input and supplies private context through UserPromptSubmit; canonical OpenClaw transcripts retain sender attribution.

flowchart LR
  A[Queued session input] --> B[Session admission]
  B --> C[CLI steering adapter]
  C --> D[Claude stream transport]
  D --> E[UserPromptSubmit context]
  E --> F[Claude parent response]
  C --> G[Canonical transcript]
Loading

Technical review

Best possible solution:

Merge the focused per-input context repair using the existing admission, transport, and transcript owners.

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

Current-main source deterministically drops injected prompt context; the submitted real-Claude before/after report corroborates the busy-parent failure, but no target code was executed during this review.

Is this the best way to solve the issue?

The patch repairs the producer-to-transport handoff through existing owners, shares provenance classification between initial and steered inputs, and retains native lifecycle and admission checks without adding parallel storage or policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 19327c554138.

Provenance checked

  • Steered prompt-context isolation changes intended behavior with a stated reason (5c3dcc5: The original steering implementation prevented injected inputs from inheriting the initial prompt’s private context while preserving native receipt ownership.)
  • Steering adapter ownership keeps the original intent (de08be2: Localized single-consumer runtime phases under their existing owners while preserving authorization and accepted-work settlement.)
  • Synthetic native-input classification changes intended behavior with a stated reason (acc6ea2: Replaced fragile host-prompt text matching with native synthetic markers derived from internal-system provenance.)
  • Imported forwarded-message provenance changes intended behavior with a stated reason (97e81ce: Recovered routed-message provenance from native prompt envelopes so unmatched forwarded rows did not appear as operator-authored messages; this PR explicitly retires that historical interpretation.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current-main defect remains: Fetched main still returns an empty hook response for injected prompts, and its steering adapter forwards neither per-input context nor origin. (extensions/anthropic/cli.runtime.ts:200, 19327c554138)
  • Focused repair through existing owners: The adapter resolves the queued input’s provenance and projects its context while retaining current-source and injection-authority checks immediately before submission. (src/agents/cli-runner/execute-plugin.steered-transcript.ts:42, 366cb08fd1d0)
  • Live behavior evidence: The PR body reports isolated Gateways using real Claude Code 2.1.310: with polling prohibited, the busy parent answered NO-RESULT on main and returned the child’s exact secret on the branch. (366cb08fd1d0)
  • Prior blocker resolved: The reviewed head’s checks-fast-baseline-ratchets and openclaw/ci-gate checks pass; aggregate CI, dependency-review, and security-sensitive-review statuses are successful. (366cb08fd1d0)
  • Maintainer-authored compatibility choice: The body explicitly accepts that older unmatched forwarded native rows become plain user rows and that synthetic forwarded prompts leave the native fallback seed; canonical transcript provenance remains unchanged, and the added injection argument is optional. (src/gateway/cli-session-history.claude.ts:463, 366cb08fd1d0)
  • Related contribution credited: The broader work in fix(claude-cli): preserve completion context when queued inputs arrive #185915 contains the same completion-context repair plus additional prompt changes; this PR credits Marvinthebored’s original fix and tests.

Likely related people:

  • Kiran V K: Raw commit 5c3dcc5 adds extensions/anthropic/cli.runtime.ts:167 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5c3dcc52002d; files: extensions/anthropic/cli.runtime.ts)

PR surface

Source +13, Tests +28, Docs +3. Total +44 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 84 71 +13
Tests 4 76 48 +28
Docs 1 9 6 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 169 125 +44

Review metrics

Metric Value Why it matters
Production versus test delta Production +84/−71; tests +76/−48 The modest production growth carries per-input metadata through existing owners; tests add distinct completion-delivery, origin-isolation, hook-rerun, and pre-acceptance rejection coverage.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, 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:

  • P2: Claude parents can miss subagent results arriving during active work; the affected path is limited to CLI steering and forwarded-input handling.
  • merge-risk: 🚨 compatibility: The documented plugin injection contract gains an optional argument, and native-history attribution and fallback seeding change intentionally; the maintainer-authored body accepts these tradeoffs.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-27T13:43:41.849Z sha 9cc3bd4 :: needs changes before merge. :: [P2] Offset the added test lines so the required ratchet passes

Reviewed October 27, 2026, 9:47 PM ET / October 28, 2026, 01:47 UTC (Revision 2).

@obviyus
obviyus force-pushed the fix/claude-cli-steered-input-origin branch from 3095894 to 366cb08 Compare October 28, 2026 01:12
@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 28, 2026
@obviyus
obviyus merged commit 80cc38d into main Oct 28, 2026
135 of 136 checks passed
@obviyus
obviyus deleted the fix/claude-cli-steered-input-origin branch October 28, 2026 01:49
@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in 80cc38d.

  • Bug: a message steered into a running Claude CLI turn lost its private context and was presented to the model as the user's message. A subagent result arriving while its parent was busy never reached the parent.
  • Fix: each injected input carries its own origin and context; host inputs go to Claude as synthetic input.
  • Proof: live Claude CLI run. On main the busy parent answered NO-RESULT; on this branch it reported the subagent's exact secret.

Thanks @Marvinthebored for finding this and for the original fix in #185915. The private inbound context part follows in a separate PR.

obviyus added a commit that referenced this pull request Oct 28, 2026
…r's message (#186439)

Related: #185915, #185945

## What Problem This Solves

Fixes: on Claude CLI sessions, OpenClaw put its own context into the text of the user's message: inbound conversation context, the Git co-author note, queued `System:` events, and the session drift and gap notes. Claude saved that text as the user's prompt. Chat history then imported it as a second user bubble, because the importer's text stripping did not recognize every fragment (the co-author note, for example).

## Why This Change Was Made

The plugin transport already has a private channel for host context: the `UserPromptSubmit` hook's `additionalContext`, which #185945 also uses for steered inputs.

- `buildCliCurrentPrompt` returns the inbound context fragments and the drift/gap notes as `prependContext` when the session runs on the plugin transport. The rendered prompt holds only the sender's text. Other transports keep the old inline rendering.
- Native Claude prompts now hold only what the person typed, and forwarded inputs are synthetic meta rows (#185945). So the importer's prompt-decoration matching has no new input to clean. This PR removes it:
  - `cli-session-history.prompt-text.ts` (system-event, gap-note, requester-hint and routed-envelope stripping)
  - the `routed_key` / `undecorated_text` views and the matchers that used them
  - the display cleanup for unmatched imported rows
- History import goes back to the two keys that v2026.10.7 shipped: the text, plus a copy without the drift note. The removed views shipped only on `main` and beta. The history index is an in-memory SQLite table rebuilt on each read, so no stored schema changes.

## User Impact

A Claude CLI message shows once in chat history, as the person wrote it. Claude still gets the same context, through the prompt hook. On sessions that ran before this change, rows written by beta builds can show their old context prefix again, as they did on v2026.10.7.

## Evidence

**Live, real Claude CLI, Control UI.** Same turns on `main` and on this branch (stacked on #185945):

| `main` | this PR |
| --- | --- |
| ![main: OpenClaw context shown as the user's message](https://github.com/user-attachments/assets/40df4e35-a1a4-46d4-96f5-5812d5de426f) | ![this PR: only the typed message](https://github.com/user-attachments/assets/929d9f9d-a3fd-44dd-868e-ab2fdcb1dda9) |

- `main`: the user bubble holds the Git co-author note and the queued `System:` session-creation events above "Reply with exactly the word DONE."
- This PR: `chat.history` has one user row per turn, holding only the typed text. Claude's transcript records the same context as `hook_additional_context` on `UserPromptSubmit`.
- The busy-parent scenario from #185945 still passes on this branch: the subagent result steered into the running turn reaches the parent, and history shows no extra user rows.

**Tests and checks**
- `prompt-context.test.ts`, `prepare.durable-context.test.ts`, `prepare.existing-session.test.ts` and `execute.native-history-owner.test.ts` cover the plugin-transport split and the unchanged inline rendering.
- All `cli-session-history*`, `session-history*`, `chat-history*cli*`, `strip-inbound-meta` and `cli-runner` suites pass (93 files).
- `check:changed` lanes: typecheck, lint and boundaries pass. The dead-export scan flags three exports in files this PR does not touch; `main` has the same failures.

Size: +250/−698. Test lines: −240.

Credit: @Marvinthebored found this and wrote the private-context change in #185915. This PR is its second part.

**Merge danger:** two-way door. A revert restores inline context and the old matchers; nothing persisted changes. Blast radius: Claude CLI prompt rendering on the plugin transport and imported Claude CLI history display.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 28, 2026
…enclaw#185945)

Related: openclaw#185915, openclaw#185746

## What Problem This Solves

Fixes: when a message arrives while a Claude CLI turn is running (for example a subagent's completion while its parent is busy), OpenClaw injects it into that turn. The Claude runtime then dropped that input's private context and never marked it as host input. The parent lost the child's result, and Claude told the model "The user sent a new message".

## Why This Change Was Made

The host already prepares each queued input's provenance and `currentInboundContext`. Only the Claude injection path threw them away:
- the `UserPromptSubmit` hook returned no context for injected inputs
- the native write never set `isSynthetic`

Changes:

- `CliBackendMessageInjection.queueMessage` takes optional per-input `promptOrigin` and `promptContext`. This is the same contract as the initial prompt. An injected input never inherits the running turn's origin: a person can steer a host turn, and a completion can arrive during a person's turn.
- The steering adapter sets them from the input's own transcript provenance and inbound context.
- The Claude runtime returns that context from the prompt hook, including on hook reruns, and sends host inputs with `isSynthetic`.
- `inter_session` provenance (forwarded messages, subagent completions) is now host input as well as `internal_system`. A message from another session was not typed by this session's operator.
- Removed `readClaudeCliInterSessionProvenance`, which read forwarded-message provenance from native prompt text. Forwarded inputs are now synthetic meta rows that the importer never reads.
  - Local Claude runs always use the plugin transport, and node-placed Claude history is not imported by the Gateway.
  - So the parser only served transcripts written before this change: those rows now show as plain user rows.

The canonical transcript is unchanged: forwarded messages keep their provenance, sender and visibility.

## User Impact

A subagent result that arrives while its Claude CLI parent is busy now reaches the parent with its content, and the parent no longer treats it as the user's message. When Claude falls back to another provider, its recent-turns prelude skips forwarded prompts, as it already skips cron and recovery prompts (openclaw#185746).

## Evidence

**Live, real Claude CLI (Claude Code 2.1.310).** I ran isolated Gateways on `main` (`30df06f`) and on this branch:
- The parent spawns a subagent that must reply with a secret, then runs `sleep 75`, then reports the subagent's reply.
- It must not poll or use `subagents`/`sessions_history`.
- The subagent finishes during the sleep, so its completion is steered into the running turn.

| | Parent's answer | How Claude presented the steered completion to the model |
| --- | --- | --- |
| `main` | `NO-RESULT` | "The user sent a new message while you were working" |
| this PR | the subagent's exact secret | "[MESSAGE FROM NON-USER SOURCE - NOT USER INPUT]", with the completion context |

In an earlier run without the polling ban, the `main` parent had to fetch the result itself with `subagents wait` and `sessions_history`. On this branch it already had the result.

**Tests**
- `execute-plugin.steering.test.ts`: the real Claude stdio transport against a fixture CLI.
  - Steered `internal_system` and `inter_session` inputs are sent as synthetic; human steering is not.
  - A steered subagent completion delivers its result ("The fixture count is 42.") through the prompt hook. This fails on `main`.
  - A recorder failure before native acceptance rejects the input instead of losing it.
- `cli-runtime.test.ts`: an injected input's context is returned on the first hook pass and on reruns.
- `execute-plugin.test.ts`: the origin comes from provenance kind only.
- These suites pass: `cli-session-history.routed-prompts`, `session-history.subagent-visibility`, `chat-history-handler.cli-import`, `cli-session-history*`, `extensions/anthropic/cli-runtime`.
- `oxlint` and `oxfmt` are clean.

Size: +169/−125. Production is +93/−77; the rest is the steering regression tests (net +28 test lines). The test-line ratchet passes against current `main` without a ceiling change.

Credit: @Marvinthebored found this and wrote the original fix and its tests in openclaw#185915. This PR is the first part of that change.

**Merge danger:** two-way door. A revert restores the old injection path. Native meta rows already written stay hidden. Blast radius: Claude CLI steered and forwarded inputs, and third-party CLI backends that implement `registerMessageInjection` (the new argument is optional).

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 28, 2026
…r's message (openclaw#186439)

Related: openclaw#185915, openclaw#185945

## What Problem This Solves

Fixes: on Claude CLI sessions, OpenClaw put its own context into the text of the user's message: inbound conversation context, the Git co-author note, queued `System:` events, and the session drift and gap notes. Claude saved that text as the user's prompt. Chat history then imported it as a second user bubble, because the importer's text stripping did not recognize every fragment (the co-author note, for example).

## Why This Change Was Made

The plugin transport already has a private channel for host context: the `UserPromptSubmit` hook's `additionalContext`, which openclaw#185945 also uses for steered inputs.

- `buildCliCurrentPrompt` returns the inbound context fragments and the drift/gap notes as `prependContext` when the session runs on the plugin transport. The rendered prompt holds only the sender's text. Other transports keep the old inline rendering.
- Native Claude prompts now hold only what the person typed, and forwarded inputs are synthetic meta rows (openclaw#185945). So the importer's prompt-decoration matching has no new input to clean. This PR removes it:
  - `cli-session-history.prompt-text.ts` (system-event, gap-note, requester-hint and routed-envelope stripping)
  - the `routed_key` / `undecorated_text` views and the matchers that used them
  - the display cleanup for unmatched imported rows
- History import goes back to the two keys that v2026.10.7 shipped: the text, plus a copy without the drift note. The removed views shipped only on `main` and beta. The history index is an in-memory SQLite table rebuilt on each read, so no stored schema changes.

## User Impact

A Claude CLI message shows once in chat history, as the person wrote it. Claude still gets the same context, through the prompt hook. On sessions that ran before this change, rows written by beta builds can show their old context prefix again, as they did on v2026.10.7.

## Evidence

**Live, real Claude CLI, Control UI.** Same turns on `main` and on this branch (stacked on openclaw#185945):

| `main` | this PR |
| --- | --- |
| ![main: OpenClaw context shown as the user's message](https://github.com/user-attachments/assets/40df4e35-a1a4-46d4-96f5-5812d5de426f) | ![this PR: only the typed message](https://github.com/user-attachments/assets/929d9f9d-a3fd-44dd-868e-ab2fdcb1dda9) |

- `main`: the user bubble holds the Git co-author note and the queued `System:` session-creation events above "Reply with exactly the word DONE."
- This PR: `chat.history` has one user row per turn, holding only the typed text. Claude's transcript records the same context as `hook_additional_context` on `UserPromptSubmit`.
- The busy-parent scenario from openclaw#185945 still passes on this branch: the subagent result steered into the running turn reaches the parent, and history shows no extra user rows.

**Tests and checks**
- `prompt-context.test.ts`, `prepare.durable-context.test.ts`, `prepare.existing-session.test.ts` and `execute.native-history-owner.test.ts` cover the plugin-transport split and the unchanged inline rendering.
- All `cli-session-history*`, `session-history*`, `chat-history*cli*`, `strip-inbound-meta` and `cli-runner` suites pass (93 files).
- `check:changed` lanes: typecheck, lint and boundaries pass. The dead-export scan flags three exports in files this PR does not touch; `main` has the same failures.

Size: +250/−698. Test lines: −240.

Credit: @Marvinthebored found this and wrote the private-context change in openclaw#185915. This PR is its second part.

**Merge danger:** two-way door. A revert restores inline context and the old matchers; nothing persisted changes. Blast radius: Claude CLI prompt rendering on the plugin transport and imported Claude CLI history display.

Co-authored-by: Ayaan Zaidi <[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 docs Improvements or additions to documentation extensions: anthropic gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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