Skip to content

fix(gateway): chat history shows injected skill instructions on claude-cli sessions - #130269

Merged
obviyus merged 1 commit into
openclaw:mainfrom
brocktice:fix/cli-history-skip-ismeta
Aug 28, 2026
Merged

obviyus merged 1 commit into
openclaw:mainfrom
brocktice:fix/cli-history-skip-ismeta

Conversation

@brocktice

@brocktice brocktice commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #130268

What Problem This Solves

Claude Code marks injected skill bodies and other private harness input with isMeta: true. OpenClaw imported those rows as ordinary user messages, so chat.history returned instructions that the operator did not write.

Why This Change Was Made

Both Claude transcript import paths now reject isMeta rows before they create an OpenClaw message. The fix uses Claude's native marker and does not inspect message text.

The repair keeps real user commands, assistant replies, compact summaries, transcript-only context, tool rows, and reseed handling on their existing paths.

Maintainer decision

Full omission is intentional. isMeta is private harness input, so it must not be inspectable through chat.history. This replaces the collapsed-notice treatment for isMeta only; compact summaries and transcript-only context keep that treatment.

User Impact

Claude CLI session history now contains only the real conversation and the existing visible context rows. Private skill instructions no longer enter chat.history, including after session-catalog adoption.

Evidence

  • Live red/green: generated an isolated Claude Code 2.1.246 transcript with one test skill command, its native isMeta instruction row, and one assistant reply.
  • Exact main 345b2235e3c0b2f702bc1ccf06ce42a397dc0991: the production importer and an authenticated isolated Gateway chat.history request each returned three messages, including the injected instruction body.
  • Exact pre-rebase head 7de3acdc38379e2e30bd8c76c32754455ea67524: the same importer and Gateway request each returned only the real command and assistant reply; both native message identifiers remained stable.
  • Current head 2bf55f694ee883ac8e3986796bf1b7ff7930c367 is a patch-identical rebase onto main 871b18dff5039484e86c76d282699a8defcb1654; stable patch ID: 7b13b4157d151c06374494252ed1e33acce9bf06.
  • Regression proof: the importer, Gateway request, and session-catalog tests fail on the frozen main implementation and pass on this head.
  • Validation: 53 Claude history tests pass; 5 Anthropic session-catalog import tests pass; the focused Gateway request test passes; pnpm check:changed passes.
main  importer=3 gateway=3 injected=true  command=true reply=true stable-ids=true
head  importer=2 gateway=2 injected=false command=true reply=true stable-ids=true

Control UI

The head capture uses the proven pre-rebase head with the sanitized message set retained from the exact Gateway run. The current head has the same patch, and the UI renderer does not change in this pull request.

Main Head
The injected context is present and expanded. Only the real user and assistant messages remain.
Main shows injected context Head omits injected context

🤖 Generated with Claude Code

@clawsweeper

clawsweeper Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XS labels Aug 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 26, 2026
@clawsweeper

clawsweeper Bot commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 26, 2026, 2:25 PM ET / 18:25 UTC.

ClawSweeper review

What this changes

The PR filters Claude CLI transcript rows marked as internal metadata so gateway chat history does not present them as user messages.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 4 items remain

Keep this PR open for the required user-visible proof. The shared Claude CLI transcript parser fix is correct and narrowly repairs current-main behavior, but the supplied terminal importer output does not meet the applicable gateway policy’s Control UI screenshot/recording requirement.

Priority: P2
Reviewed head: d9b34bf6881eedb483f874d4f8d6ec7260d39edc

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The parser fix and regression test are sound, while the remaining rank-up move is user-visible gateway proof.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The PR body supplies redacted before/after terminal output from a real Claude CLI transcript and the actual importer, but this user-visible chat-history change still needs the applicable policy’s sanitized Control UI screenshot or recording; redact private paths, endpoints, and credentials. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The PR body supplies redacted before/after terminal output from a real Claude CLI transcript and the actual importer, but this user-visible chat-history change still needs the applicable policy’s sanitized Control UI screenshot or recording; redact private paths, endpoints, and credentials. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 7 items Current-main defect: Current main accepts a well-formed user-role metadata row because its visible-history guard checks only sidechain status before parsing the message.
Canonical repair boundary: The PR adds the metadata exclusion in the shared parser, before normalization, reseed processing, and message construction.
Production caller path: The chat-history page obtains the asynchronous external snapshot and reuses it for the import merge; that snapshot invokes the same shared parser for every JSONL row.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/gateway/cli-session-history.test.ts -t "does not import isMeta rows as visible user messages"

Result: PASS (completed)

[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130269-T9OUxQ/target

 ✓  gateway-core  ../../src/gateway/cli-session-history.test.ts (53 tests | 52 skipped) 46ms

 Test Files  1 passed (1)
      Tests  1 passed | 52 skipped (53)
   Start at  18:26:22
   Duration  9.82s (transform 7.73s, setup 958ms, import 8.44s, tests 46ms, environment 0ms)

[test] passed 1 Vitest shard in 16.19s
[test] starting test/vitest/vitest.gateway.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130269-T9OUxQ/target

 ✓  gateway-core  ../../src/gateway/cli-session-history.test.ts (53 tests | 52 skipped) 40ms

 Test Files  1 passed (1)
      Tests  1 passed | 52 skipped (53)
   Start at  18:26:39
   Duration  4.42s (transform 2.43s, setup 455ms, import 3.69s, tests 40ms, environment 0ms)

[test] passed 1 Vitest shard in 10.69s

Assertions:

  • NOT OBSERVED expect_output: does not import isMeta rows as visible user messages — command exited successfully; expected output was not observed in the captured pane

How this fits together

Gateway chat history imports a bound Claude CLI JSONL transcript, merges its visible turns with local history, and returns the result to chat clients. The shared parser decides which external transcript rows are eligible to become visible messages.

flowchart LR
  A[Claude CLI transcript] --> B[Gateway snapshot reader]
  B --> C[Shared transcript parser]
  C --> D{Metadata or sidechain row?}
  D -->|Yes| E[Omit internal row]
  D -->|No| F[Merge visible turn]
  F --> G[Chat history response]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The PR body supplies redacted before/after terminal output from a real Claude CLI transcript and the actual importer, but this user-visible chat-history change still needs the applicable policy’s sanitized Control UI screenshot or recording; redact private paths, endpoints, and credentials. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - The physical production delta is +5 lines because the new predicate expands under formatting; it remains a single parser-boundary condition rather than a new path.
  • Resolve merge risk (P1) - The PR body includes credible redacted importer output, but not a sanitized Control UI before/after capture of the user-visible chat-history result required by applicable gateway policy.
  • Complete next step (P2) - No repair job is appropriate: the patch has no actionable defect, and the remaining requirement is contributor-supplied user-visible proof.
Agent review details

Security

None.

PR surface

Source +5, Tests +36. Total +41 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 1 +5
Tests 1 36 0 +36
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 42 1 +41

Review metrics

Metric Value Why it matters
Production versus test delta production +5, tests +36 The production change is one metadata predicate at the canonical parser boundary; the larger test addition verifies omission and preservation of adjacent visible turns.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/cli-session-history.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the shared parser exclusion and attach a redacted before/after Control UI screenshot or short recording showing that a real gateway chat-history view omits the metadata row while preserving adjacent real turns.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the shared parser exclusion and attach a redacted before/after Control UI screenshot or short recording showing that a real gateway chat-history view omits the metadata row while preserving adjacent real turns.

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

Yes—current main has a precise offline reproduction: a well-formed user-role JSONL row with isMeta true passes the visible-history guard and reaches the shared importer; the added regression case encodes that path.

Is this the best way to solve the issue?

Yes—the shared parser is the correct producer boundary because synchronous import, asynchronous chat-history snapshots, fallback seeding, and activity classification all reuse it.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This fixes incorrect visible history for Claude CLI-backed sessions, with a bounded provider-specific blast radius.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The PR body supplies redacted before/after terminal output from a real Claude CLI transcript and the actual importer, but this user-visible chat-history change still needs the applicable policy’s sanitized Control UI screenshot or recording; redact private paths, endpoints, and credentials. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Introduced the split Claude CLI history pipeline and the central import-aware chat-history feature; path history shows sustained ownership. (role: feature owner; confidence: high; commits: 00aedb341415, 238c7973adea; files: src/gateway/cli-session-history.claude.ts, src/gateway/server-methods/chat-history-pages.ts)
  • ZOOWH: Added the existing synthetic Claude reseed-prompt filtering that already treats metadata rows as non-user content. (role: metadata-policy contributor; confidence: medium; commits: 9aa4250c58ad; files: src/gateway/cli-session-history.claude.ts)
  • Vincent Koc: Recently maintained Claude CLI history deduplication in the same gateway history surface. (role: recent area contributor; confidence: medium; commits: c9afcbb90473; files: src/gateway/cli-session-history.test.ts)

Rank-up moves

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

  • Attach a redacted before/after Control UI screenshot or short recording from a real gateway showing the metadata row absent and adjacent real turns retained.

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-08-26T17:46:54.541Z sha d9b34bf6881eedb483f874d4f8d6ec7260d39edc :: needs real behavior proof before merge. :: none

@brocktice

Copy link
Copy Markdown
Contributor Author

Added the requested real-behavior proof to the PR body: a redacted before/after run of the actual importer entry point (readClaudeCliSessionMessages) against a real Claude Code CLI v2.1.246 transcript generated in an isolated $HOME. At merge-base 44789598 the skill-injected isMeta: true row imports as a visible user message; at this PR's head it is excluded while the genuine user and assistant turns import unchanged.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 26, 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.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 26, 2026
@obviyus
obviyus force-pushed the fix/cli-history-skip-ismeta branch from d9b34bf to 7de3acd Compare August 28, 2026 07:55
@obviyus
obviyus force-pushed the fix/cli-history-skip-ismeta branch from 7de3acd to 2bf55f6 Compare August 28, 2026 08:14
@obviyus
obviyus merged commit f054203 into openclaw:main Aug 28, 2026
258 checks passed
@obviyus

obviyus commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks @brocktice!

Proof: An isolated Claude Code 2.1.246 session produced one real command, one native metadata instruction row, and one assistant reply. The same transcript went through the production importer and an authenticated Gateway history request. Main returned all three rows. The repaired head returned only the real command and reply, with both native message identifiers unchanged. Sanitized Control UI captures confirm the visible result. Landed in f054203aba11ca430767a009e991e8f926077b3b.

  • Bug: Claude skill instructions entered session history as user messages that the operator did not write.
  • Fix: Both Claude transcript import paths now omit native isMeta rows before they can enter history.

Example

Before After
History includes the user command, injected skill instructions, and assistant reply. History includes only the user command and assistant reply.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 29, 2026
Prevent Claude harness-injected isMeta rows from entering visible session history while keeping real conversation and other context markers unchanged.

Co-authored-by: Brock Tice <[email protected]>
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

extensions: anthropic gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: chat.history imports isMeta claude-cli transcript rows, leaking injected instructions as user messages

2 participants