Repository navigation
fix(harness): route CLI runtime aliases (claude-cli, google-gemini-cli) through PI harness - #83552
SkyWolfDreamer wants to merge 2 commits into
Conversation
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: the reported CLI-runtime harness bug is valid, but #85631 now owns the safer landing path with provider-owned alias validation and focused regression tests, while this branch would broadly route any known CLI alias through PI. Canonical path: Use #85631 as the canonical fix, and preserve this PR's live repro logs as supporting evidence there. So I’m closing this here and keeping the remaining discussion on #85631. Review detailsBest possible solution: Use #85631 as the canonical fix, and preserve this PR's live repro logs as supporting evidence there. Do we have a high-confidence way to reproduce the issue? Yes. Current main source shows the explicit-runtime Is this the best way to solve the issue? No. The central direction is right for valid CLI aliases, but this branch is not the best landing candidate because it lacks provider validation and tests; the superseding PR is narrower and safer. Security review: Security review cleared: No new dependency, secret handling, permissions, or supply-chain surface was added; the auth-provider concern is a functional routing compatibility risk. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 0d7d99befab4. |
When agentRuntime.id is set to a CLI runtime alias like "claude-cli", selectAgentHarnessDecision was throwing MissingAgentHarnessError because CLI aliases are not registered as plugin harnesses — they are dispatched internally via the cli-backend. Add a special case (parallel to the existing codex implicit fallback) that routes CLI runtime aliases to the PI harness, which then dispatches the run through the appropriate cli-backend. This fixes compaction and other harness-selection paths that would break when context exceeded the limit for sessions using claude-cli as agentRuntime. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
Confirming repro on v2026.5.18 stable (Linux, Node 24.15) — applied this PR's fix locally and it resolved the issue. Config:
Symptom: Every Telegram inbound message immediately failed with: Key asymmetry: Cron-triggered runs worked fine — agent-runner-execution.ts's isCliProvider(cliExecutionProvider, Fix verified: Patched selectAgentHarnessDecision to fall back to PI for isCliRuntimeAlias(runtime) (parallel to the Happy to share more diagnostic detail if useful for the merge-risk review. |
|
ClawSweeper PR egg 🥚 Incubating: this PR egg is tucked into the review nest. Hatch commandComment Hatchability rules:
What is this egg doing here?
|
|
ClawSweeper applied the proposed close for this PR.
|
Summary
agentRuntime.idis set to a CLI runtime alias (claude-cli,google-gemini-cli),selectAgentHarnessDecisionthrowsMissingAgentHarnessErrorbecause CLI aliases are not registered as plugin harnesses — they are dispatched internally via the cli-backend.claude-cliasagentRuntimecrashes on compaction (context overflow) and on any other code path that callsselectAgentHarnessdirectly. Sessions become permanently unrecoverable once context exceeds the limit.selectAgentHarnessDecisionthat detects CLI runtime aliases viaisCliRuntimeAlias()and routes them to the PI harness (which dispatches through the cli-backend), parallel to the existing implicit-codex fallback.pi/autorouting, codex implicit fallback, and the cli-backend dispatch path are all untouched.Change Type
Scope
Linked Issue/PR
Real behavior proof
agentRuntime: { id: "claude-cli" }crash on compaction withMissingAgentHarnessError: Requested agent harness "claude-cli" is not registered.and the session becomes permanently unrecoverable once it exceeds its context window.claude-sonnet-4-6andclaude-opus-4-7). A pre-existing session at 143 % of its context window (1.5 m / 1.0 m tokens) that had been failing every compaction attempt was used as the reproduction target.UNAVAILABLE; the session could not recover and could not be reused.MissingAgentHarnessErroris emitted; the compaction completes and the next turn streams normally.OKonsessions.compact, and the session continued to accept turns. The harness-selection path now routesagentRuntime.id = "claude-cli"to the PI harness instead of throwing.claude-cliCLI aliases other than the existinggoogle-gemini-cli(the guard is keyed off the existingisCliRuntimeAlias()helper, so any alias it already recognises is covered, but I did not separately rebuild and reproduce against a Gemini-pinned session); behaviour under explicitagentRuntime.id: "pi"or"auto"(unchanged code path, not re-exercised after the patch).Root Cause
selectAgentHarnessDecisionhas a special case for implicitcodexbut no equivalent for CLI runtime aliases. CLI aliases are not plugin harnesses — they are backend aliases dispatched by PI's cli-backend. The utilityisCliRuntimeAlias()already existed inmodel-runtime-aliases.tsbut was never called in the harness-selection path, so any caller that hitselectAgentHarness("claude-cli")(compaction, several other code paths) threwMissingAgentHarnessError. Any config usingagentRuntime: { id: "claude-cli" }— the documented way to pin Claude models to Claude Code — therefore broke on the first context overflow.Regression Test Plan
The fix is a 14-line guard in
selectAgentHarnessDecisionthat mirrors the existing implicit-codexfallback. The smallest reliable test is a unit test againstselectAgentHarnessDecisionasserting that{ id: "claude-cli" }(and{ id: "google-gemini-cli" }) resolves to the PI harness. Happy to add it on request if the maintainers prefer it in this PR; flagging it explicitly rather than skipping it silently.User-visible / Behavior Changes
None — restores the documented behaviour. Sessions pinned to
claude-clino longer die on compaction.Diagram
Security Impact
Repro + Verification
agentRuntime: { id: "claude-cli" }in agent config, a long-running session that approaches its context window.sessions.compact.MissingAgentHarnessErroron every compaction attempt; the session permanently fails further turns.Evidence
Human Verification
I rebuilt OpenClaw from the patched source on the affected WSL box, restarted the local gateway onto the new build, and resumed the same previously stuck session. The session compacted on the first attempt and continued; no
MissingAgentHarnessErrorappears in the gateway log on or after the patched build. NOT verified: explicit-pi/ explicit-autopaths (unchanged), Gemini-pinned sessions (alias covered by the same guard but not separately re-exercised), and the documented test (would be aselectAgentHarnessDecisionunit covering both aliases — happy to add if maintainers want it landed in this PR).Review Conversations
Compatibility / Migration
Backward compatible. No config or migration. The guard only affects callers that previously threw
MissingAgentHarnessError; existing callers that resolved successfully are unchanged.Risks and Mitigations
claude-cliruntime policy may behave differently in edge cases.Mitigation: PI already dispatches
claude-cliprovider sessions through cli-backend (confirmed by the patched-build gateway logs above). This patch aligns the compaction path with what the main session path already does.isCliRuntimeAlias()but not actually dispatchable by the PI harness would silently fall into this path.Mitigation:
isCliRuntimeAlias()is currently exhaustive for the registered CLI backends (claude-cli,google-gemini-cli); future additions to that helper should land alongside their PI-harness dispatch wiring.