Skip to content

fix(agents): don't fail CLI turn when the native harness owns compaction#87785

Closed
solomonneas wants to merge 1 commit into
openclaw:mainfrom
solomonneas:fix/codex-compaction-owned-skip
Closed

fix(agents): don't fail CLI turn when the native harness owns compaction#87785
solomonneas wants to merge 1 commit into
openclaw:mainfrom
solomonneas:fix/codex-compaction-owned-skip

Conversation

@solomonneas

@solomonneas solomonneas commented May 28, 2026

Copy link
Copy Markdown
Contributor

AI-assisted: built with Codex (GPT-5.5) and Claude (Opus 4.8). Human-run real behavior proof from a self-hosted gateway is included below.

Summary

Budget/auto-triggered compaction on a Codex-backed session calls the Codex app-server, which owns automatic compaction and returns a successful no-op ({ ok: true, compacted: false, reason: "codex app-server owns automatic compaction" }, the behavior added in #86772). The host lifecycle runCliTurnCompactionLifecycle in src/agents/command/cli-compaction.ts treated any non-compacted native outcome without fallbackToContextEngine as a hard failure and threw CLI native harness compaction failed …. That fails the agent run (UNAVAILABLE) and the session lane never releases — on a large thread the bot shows a "typing" indicator indefinitely and never replies.

This honors a contract the codebase already establishes elsewhere: the auto-reply preflight path skips compaction for Codex runtimes outright (src/auto-reply/reply/agent-runner-memory.ts: "Its harness owns automatic compaction; OpenClaw preflight compaction is only for non-Codex embedded runtimes"). runCliTurnCompactionLifecycle was the one host path that did not honor it and threw instead.

Fix

Surface an ownedByNativeHarness flag on the native outcome when the harness reports a successful no-op (result.ok === true), and add a caller branch before the throw that skips both the error and the context-engine fallback, letting the turn proceed so the harness compacts itself. Minimal and additive; no refactor. Genuine failures (ok:false, thrown, or undefined result) and the unsupported / recoverable-binding cases are unchanged.

Note on shape: I extended the existing NativeHarnessCliCompactionOutcome (which already uses parallel optional fields) rather than refactoring it into a discriminated union, to keep the fix small. Happy to take the union refactor in a follow-up if maintainers prefer.

Sibling surfaces (not one-sided)

The other native-harness compaction entry points already tolerate the ok:true no-op, so this is the only path that needed fixing:

  • src/agents/embedded-agent-runner/compact.queued.tsshouldFallbackAfterHarnessCompaction only fires on ok:false; the ok:true no-op is returned directly.
  • src/auto-reply/reply/agent-runner-memory.ts — Codex runtimes skip preflight compaction entirely; otherwise only isDeferredPreflightCompactionReason throws, which the owned-skip reason is not.

Real behavior proof

  • Behavior addressed: A successful native-harness compaction no-op (ok:true, compacted:false, "codex app-server owns automatic compaction") must let the turn proceed instead of throwing and jamming the session lane.

  • Real environment tested: A self-hosted OpenClaw 2026.5.28 gateway on Linux (Node 22.22.2) where this failure occurred in production, with the equivalent fix applied to the running build and the gateway restarted.

  • Exact steps or command run after this patch: Drove one real agent turn through the live gateway against the same over-budget Codex session that had been failing (no channel delivery):
    openclaw agent --session-id <redacted> --message "Reply with exactly: COMPACTION_FIX_OK" --json

  • Evidence after fix: Console output / redacted runtime logs copied from the live gateway (same session), captured via openclaw agent --session-id <redacted> --message "Reply with exactly: COMPACTION_FIX_OK" --json, before vs. after the fix.

    Before (pre-fix) — the throw and resulting lane jam:

    [diagnostic] lane wait exceeded: lane=session:agent:main:discord:channel:<redacted> waitedMs=176928 queueAhead=0 activeAhead=1 activeNow=0
    [ws] ⇄ res ✗ agent errorCode=UNAVAILABLE errorMessage=Error: CLI native harness compaction failed for openai-codex/gpt-5.5: codex app-server owns automatic compaction
    

    After (post-fix) — same compaction outcome, now skipped instead of thrown; turn completes:

    [agent/embedded] skipping codex app-server compaction for non-manual trigger
    [agents/cli-compaction] CLI native harness compaction did not reduce context for openai-codex/gpt-5.5: codex app-server owns automatic compaction
    COMPACTION_FIX_OK
    

    Agent result JSON: stopReason: "stop", executionTrace.winnerProvider: "openai-codex", winnerModel: "gpt-5.5", attempts[0].result: "success", fallbackUsed: false.

  • Observed result after fix: Copied live output — the previously-jammed over-budget Codex session completed a turn and the agent returned COMPACTION_FIX_OK (gateway console output above). Zero CLI native harness compaction failed occurrences in gateway logs since the fix was deployed.

  • What was not tested: Not re-driven through the Discord channel UI specifically — the turn was driven via the gateway agent command without --deliver; behavior is proven at the live gateway turn boundary.

Supplemental validation

  • New regression test in cli-compaction.test.ts: node scripts/run-vitest.mjs src/agents/command/cli-compaction.test.ts → 24 passed. Reverting only the source change makes the new test fail with CLI native harness compaction failed for codex/gpt-5.5: codex app-server owns automatic compaction (the exact production error).
  • oxfmt --check clean · oxlint clean · tsgo:test (core + extensions) exit 0.
  • codex review --base origin/main run locally: no actionable correctness issues.
  • Diff: +14 src / +77 test, 0 deletions.

Complements #87158 (Codex plugin side); coordinates with #87738 (same file, missing-thread ok:false case). Related: #85160, #86772, #66263.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels May 28, 2026
@clawsweeper

clawsweeper Bot commented May 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed May 29, 2026, 8:04 AM ET / 12:04 UTC.

Summary
The branch adds a native-owned no-op outcome in CLI compaction and a regression test so ok:true, compacted:false native harness compaction results proceed without context-engine fallback.

PR surface: Source +14, Tests +77. Total +91 across 2 files.

Reproducibility: yes. current main's Codex app-server returns ok:true, compacted:false for non-manual compaction, and current CLI compaction throws for non-compacted native outcomes that do not fall back. The PR body also supplies live before/after gateway logs for the same failure class.

Review metrics: 1 noteworthy metric.

  • Native compaction outcome paths: 1 added. The new successful no-op branch changes whether a budget-triggered native harness result throws, falls back, or proceeds.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] Merging changes native-harness budget compaction from fail-closed to proceed-on-successful-no-op; if maintainers expect context-engine fallback for this path, session usage/accounting may remain un-compacted until the harness performs its own maintenance.
  • [P1] fix(codex): recover context overflow and budget skip paths #87879 overlaps the same CLI compaction branch with broader recovery work, so maintainers should avoid landing divergent semantics.

Maintainer options:

  1. Accept native-owned no-op semantics (recommended)
    Merge the narrow fix once maintainers accept that successful native harness no-ops should not trigger host fallback in this CLI lifecycle.
  2. Constrain the ownership predicate
    If maintainers want a smaller blast radius, require the known ownership reason or native result details before skipping the throw and fallback.
  3. Prefer the broader recovery branch
    If fix(codex): recover context overflow and budget skip paths #87879 is the desired landing path, pause or close this PR after that branch lands so only one CLI compaction policy ships.

Next step before merge

Security
Cleared: The diff only changes TypeScript control flow and a colocated regression test; it does not touch dependencies, workflows, credentials, package metadata, or code-download surfaces.

Review details

Best possible solution:

Land one coherent CLI native-owned compaction behavior, preferably this narrow branch if maintainers want the minimal fix, or close it after the broader overlapping recovery PR lands.

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

Yes: current main's Codex app-server returns ok:true, compacted:false for non-manual compaction, and current CLI compaction throws for non-compacted native outcomes that do not fall back. The PR body also supplies live before/after gateway logs for the same failure class.

Is this the best way to solve the issue?

Yes: adding a nonfatal native-owned no-op branch at the CLI lifecycle matches the sibling Codex preflight behavior and keeps genuine failures unchanged. The main maintainer choice is whether to land this narrow path or the broader overlapping recovery PR.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 351d056ca64f.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes redacted before/after live gateway logs showing the prior compaction failure and an after-fix successful CLI/gateway turn result.
  • 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. Sufficient (logs): The PR body includes redacted before/after live gateway logs showing the prior compaction failure and an after-fix successful CLI/gateway turn result.
  • remove rating: 🌊 off-meta tidepool: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P1: The reported failure can leave a real agent/channel turn stuck after Codex compaction, so it is urgent workflow repair work.
  • merge-risk: 🚨 session-state: The PR changes how CLI budget compaction handles native harness session state and whether host fallback runs after a non-compacted native result.
  • 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. Sufficient (logs): The PR body includes redacted before/after live gateway logs showing the prior compaction failure and an after-fix successful CLI/gateway turn result.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes redacted before/after live gateway logs showing the prior compaction failure and an after-fix successful CLI/gateway turn result.
Evidence reviewed

PR surface:

Source +14, Tests +77. Total +91 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 14 0 +14
Tests 1 77 0 +77
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 91 0 +91

What I checked:

Likely related people:

  • joshavant: Authored the merged native CLI compaction work that added the fatal native compaction failure path and core lifecycle this PR changes. (role: introduced behavior; confidence: high; commits: b8e9ab9385c0; files: src/agents/command/cli-compaction.ts)
  • pfrederiksen: Authored the recent merged raw missing-thread recovery work that changed the same CLI fallback classification path and shared compaction recovery helper. (role: recent area contributor; confidence: high; commits: e69855e68c04; files: src/agents/command/cli-compaction.ts, src/agents/harness/compaction-recovery.ts)
  • Steady-ai: Authored the merged Codex app-server change that introduced the successful codex app-server owns automatic compaction no-op result consumed by this PR. (role: adjacent owner; confidence: high; commits: eb8f9b46da39; files: extensions/codex/src/app-server/compact.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added 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. 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 May 28, 2026
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 28, 2026
@solomonneas

Copy link
Copy Markdown
Contributor Author

Added real behavior proof from a live self-hosted gateway (the prior review predated it): the Evidence after fix section now shows redacted before/after gateway console output for the same over-budget Codex session — the native owned no-op is hit (skipping codex app-server compaction for non-manual triggerdid not reduce context ... codex app-server owns automatic compaction) and the turn now completes (COMPACTION_FIX_OK) with no throw and no context-engine fallback, versus the pre-fix UNAVAILABLE throw + lane wait exceeded jam. The "Real behavior proof" gate is now green.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 28, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@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. and removed 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 May 28, 2026
runCliTurnCompactionLifecycle threw on the Codex app-server's successful
no-op (ok:true, compacted:false) when it owns automatic compaction, failing
the agent run and jamming the session lane (endless 'typing' on large Codex
threads). Treat the owned no-op as benign: skip the throw and the
context-engine fallback so the turn proceeds and the harness self-compacts.
Matches the existing 'Codex owns compaction' contract in the auto-reply
preflight path.
@solomonneas solomonneas force-pushed the fix/codex-compaction-owned-skip branch from 4c07fc7 to 28f22f0 Compare May 29, 2026 01:53
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 29, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 29, 2026
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed 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. labels May 29, 2026
@solomonneas

Copy link
Copy Markdown
Contributor Author

Previous ClawSweeper run errored before completing ("Review failed before ClawSweeper could summarize" / AGENTS.md not fully read) after the rebase onto latest main (now includes #87738). The diff is unchanged (+14 src / +77 test) and the prior completed review rated patch quality 🐚 platinum hermit with no code defects. Requesting a fresh run.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented May 29, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels May 29, 2026
@steipete steipete self-assigned this May 30, 2026
@steipete

Copy link
Copy Markdown
Contributor

Closing as superseded by current main.

Current main already avoids the original hard failure for the Codex-owned native compaction no-op by recognizing that result and falling back to context-engine compaction. That keeps the no-throw fix while preserving a known host-side compaction/rotation path before the turn proceeds.

This PR now conflicts with that landed policy because its generic successful-no-op branch would skip both the throw and the context-engine fallback, while the merged main path intentionally falls back for the exact Codex-owned reason. If there is still a reproducible failure on current main after 81505ad, please open a fresh/rebased PR with that repro and a narrow regression test against the current CLI compaction behavior.

Thanks for the detailed proof and for chasing the lane-jam failure.

@steipete steipete closed this May 30, 2026
anagnorisis2peripeteia added a commit to anagnorisis2peripeteia/openclaw that referenced this pull request May 31, 2026
Add `ownsNativeCompaction` capability to CliBackendPlugin so backends
that manage their own transcript compaction (e.g. Claude Code) can
declare it once and OpenClaw defers instead of fighting or failing.

Today only Codex declares compaction ownership (via the embedded runner
path + agentHarnessId). Claude-cli never reaches that path because it
runs as a CLI subprocess with no harness id set, so the safeguard
summarizer fires and hard-fails the turn.

This PR:
- Adds `ownsNativeCompaction?: boolean` to the backend plugin type
- Propagates it through all 4 backend resolution paths
- In `runCliTurnCompactionLifecycle`, when a backend declares ownership
  but has no harness endpoint, returns a no-op instead of falling
  through to the safeguard
- Sets the flag on claude-cli (first adopter)

Codex's existing native-harness path is unchanged: when
`isNativeHarnessCompactionSession` matches, the harness compaction
endpoint is still called as before.

Generalizes the partial fix in openclaw#87785 (codex-scoped) to a capability
any backend can opt into.
anagnorisis2peripeteia added a commit to anagnorisis2peripeteia/openclaw that referenced this pull request May 31, 2026
Add `ownsNativeCompaction` capability to CliBackendPlugin so backends
that manage their own transcript compaction (e.g. Claude Code) can
declare it once and OpenClaw defers instead of fighting or failing.

Today only Codex declares compaction ownership (via the embedded runner
path + agentHarnessId). Claude-cli never reaches that path because it
runs as a CLI subprocess with no harness id set, so the safeguard
summarizer fires and hard-fails the turn.

This PR:
- Adds `ownsNativeCompaction?: boolean` to the backend plugin type
- Propagates it through all 4 backend resolution paths
- In `runCliTurnCompactionLifecycle`, when a backend declares ownership
  but has no harness endpoint, returns a no-op instead of falling
  through to the safeguard
- Sets the flag on claude-cli (first adopter)

Codex's existing native-harness path is unchanged: when
`isNativeHarnessCompactionSession` matches, the harness compaction
endpoint is still called as before.

Generalizes the partial fix in openclaw#87785 (codex-scoped) to a capability
any backend can opt into.
obviyus pushed a commit to anagnorisis2peripeteia/openclaw that referenced this pull request Jun 2, 2026
Add `ownsNativeCompaction` capability to CliBackendPlugin so backends
that manage their own transcript compaction (e.g. Claude Code) can
declare it once and OpenClaw defers instead of fighting or failing.

Today only Codex declares compaction ownership (via the embedded runner
path + agentHarnessId). Claude-cli never reaches that path because it
runs as a CLI subprocess with no harness id set, so the safeguard
summarizer fires and hard-fails the turn.

This PR:
- Adds `ownsNativeCompaction?: boolean` to the backend plugin type
- Propagates it through all 4 backend resolution paths
- In `runCliTurnCompactionLifecycle`, when a backend declares ownership
  but has no harness endpoint, returns a no-op instead of falling
  through to the safeguard
- Sets the flag on claude-cli (first adopter)

Codex's existing native-harness path is unchanged: when
`isNativeHarnessCompactionSession` matches, the harness compaction
endpoint is still called as before.

Generalizes the partial fix in openclaw#87785 (codex-scoped) to a capability
any backend can opt into.
obviyus pushed a commit to anagnorisis2peripeteia/openclaw that referenced this pull request Jun 2, 2026
Add `ownsNativeCompaction` capability to CliBackendPlugin so backends
that manage their own transcript compaction (e.g. Claude Code) can
declare it once and OpenClaw defers instead of fighting or failing.

Today only Codex declares compaction ownership (via the embedded runner
path + agentHarnessId). Claude-cli never reaches that path because it
runs as a CLI subprocess with no harness id set, so the safeguard
summarizer fires and hard-fails the turn.

This PR:
- Adds `ownsNativeCompaction?: boolean` to the backend plugin type
- Propagates it through all 4 backend resolution paths
- In `runCliTurnCompactionLifecycle`, when a backend declares ownership
  but has no harness endpoint, returns a no-op instead of falling
  through to the safeguard
- Sets the flag on claude-cli (first adopter)

Codex's existing native-harness path is unchanged: when
`isNativeHarnessCompactionSession` matches, the harness compaction
endpoint is still called as before.

Generalizes the partial fix in openclaw#87785 (codex-scoped) to a capability
any backend can opt into.
obviyus pushed a commit that referenced this pull request Jun 2, 2026
Add `ownsNativeCompaction` capability to CliBackendPlugin so backends
that manage their own transcript compaction (e.g. Claude Code) can
declare it once and OpenClaw defers instead of fighting or failing.

Today only Codex declares compaction ownership (via the embedded runner
path + agentHarnessId). Claude-cli never reaches that path because it
runs as a CLI subprocess with no harness id set, so the safeguard
summarizer fires and hard-fails the turn.

This PR:
- Adds `ownsNativeCompaction?: boolean` to the backend plugin type
- Propagates it through all 4 backend resolution paths
- In `runCliTurnCompactionLifecycle`, when a backend declares ownership
  but has no harness endpoint, returns a no-op instead of falling
  through to the safeguard
- Sets the flag on claude-cli (first adopter)

Codex's existing native-harness path is unchanged: when
`isNativeHarnessCompactionSession` matches, the harness compaction
endpoint is still called as before.

Generalizes the partial fix in #87785 (codex-scoped) to a capability
any backend can opt into.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 3, 2026
Add `ownsNativeCompaction` capability to CliBackendPlugin so backends
that manage their own transcript compaction (e.g. Claude Code) can
declare it once and OpenClaw defers instead of fighting or failing.

Today only Codex declares compaction ownership (via the embedded runner
path + agentHarnessId). Claude-cli never reaches that path because it
runs as a CLI subprocess with no harness id set, so the safeguard
summarizer fires and hard-fails the turn.

This PR:
- Adds `ownsNativeCompaction?: boolean` to the backend plugin type
- Propagates it through all 4 backend resolution paths
- In `runCliTurnCompactionLifecycle`, when a backend declares ownership
  but has no harness endpoint, returns a no-op instead of falling
  through to the safeguard
- Sets the flag on claude-cli (first adopter)

Codex's existing native-harness path is unchanged: when
`isNativeHarnessCompactionSession` matches, the harness compaction
endpoint is still called as before.

Generalizes the partial fix in openclaw#87785 (codex-scoped) to a capability
any backend can opt into.
SYU8384 pushed a commit to SYU8384/openclaw that referenced this pull request Jun 3, 2026
Add `ownsNativeCompaction` capability to CliBackendPlugin so backends
that manage their own transcript compaction (e.g. Claude Code) can
declare it once and OpenClaw defers instead of fighting or failing.

Today only Codex declares compaction ownership (via the embedded runner
path + agentHarnessId). Claude-cli never reaches that path because it
runs as a CLI subprocess with no harness id set, so the safeguard
summarizer fires and hard-fails the turn.

This PR:
- Adds `ownsNativeCompaction?: boolean` to the backend plugin type
- Propagates it through all 4 backend resolution paths
- In `runCliTurnCompactionLifecycle`, when a backend declares ownership
  but has no harness endpoint, returns a no-op instead of falling
  through to the safeguard
- Sets the flag on claude-cli (first adopter)

Codex's existing native-harness path is unchanged: when
`isNativeHarnessCompactionSession` matches, the harness compaction
endpoint is still called as before.

Generalizes the partial fix in openclaw#87785 (codex-scoped) to a capability
any backend can opt into.
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Add `ownsNativeCompaction` capability to CliBackendPlugin so backends
that manage their own transcript compaction (e.g. Claude Code) can
declare it once and OpenClaw defers instead of fighting or failing.

Today only Codex declares compaction ownership (via the embedded runner
path + agentHarnessId). Claude-cli never reaches that path because it
runs as a CLI subprocess with no harness id set, so the safeguard
summarizer fires and hard-fails the turn.

This PR:
- Adds `ownsNativeCompaction?: boolean` to the backend plugin type
- Propagates it through all 4 backend resolution paths
- In `runCliTurnCompactionLifecycle`, when a backend declares ownership
  but has no harness endpoint, returns a no-op instead of falling
  through to the safeguard
- Sets the flag on claude-cli (first adopter)

Codex's existing native-harness path is unchanged: when
`isNativeHarnessCompactionSession` matches, the harness compaction
endpoint is still called as before.

Generalizes the partial fix in openclaw#87785 (codex-scoped) to a capability
any backend can opt into.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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.

3 participants