openclaw - 💡(How to fix) Fix PI harness ignores `cliBackends` configuration, splitting subagent execution and chat path onto different transports for the same OAuth credential [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#73097Fetched 2026-04-28 06:27:32
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Anthropic's Claude CLI binary is exempt from the "third-party apps now draw from your extra usage, not your plan limits" filter, but Anthropic's direct API treats OAuth-credential-as-bearer requests as "third-party app" usage. OpenClaw chat goes through cli-backend (subprocess invocation of the claude binary) which gets the exemption. OpenClaw subagent execution falls through to the PI harness, which dispatches via direct API on the same OAuth token — and bills against extra-usage credits.

The two paths bifurcate on the same credential, with very different cost properties.

Root Cause

So a config that defines cliBackends.claude-cli AND uses PI harness will use the cliBackend for chat (because chat calls cliBackend directly) but the direct-API path for everything else (because PI doesn't know about cliBackends).

Fix Action

Fix / Workaround

Anthropic's Claude CLI binary is exempt from the "third-party apps now draw from your extra usage, not your plan limits" filter, but Anthropic's direct API treats OAuth-credential-as-bearer requests as "third-party app" usage. OpenClaw chat goes through cli-backend (subprocess invocation of the claude binary) which gets the exemption. OpenClaw subagent execution falls through to the PI harness, which dispatches via direct API on the same OAuth token — and bills against extra-usage credits.

The PI harness (built-in default) dispatches model calls through provider plugins (e.g., anthropic) which use the credential to make HTTP calls against api.anthropic.com. cliBackends is a separate abstraction: when explicitly invoked (e.g., by webchat's chat code), it spawns the claude binary as a subprocess. PI doesn't consult cliBackends.

When PI's anthropic provider dispatches and detects:

RAW_BUFFERClick to expand / collapse

Affected version

OpenClaw 2026.4.24 (build cbcfdf6).

Summary

Anthropic's Claude CLI binary is exempt from the "third-party apps now draw from your extra usage, not your plan limits" filter, but Anthropic's direct API treats OAuth-credential-as-bearer requests as "third-party app" usage. OpenClaw chat goes through cli-backend (subprocess invocation of the claude binary) which gets the exemption. OpenClaw subagent execution falls through to the PI harness, which dispatches via direct API on the same OAuth token — and bills against extra-usage credits.

The two paths bifurcate on the same credential, with very different cost properties.

Why it matters

For users on the sanctioned claude-cli cliBackend setup (Max plan + OAuth, no API key):

PathTransportBilling
Webchat / Telegram / /new sessioncli-backend (spawns claude binary)Max plan limits — exempt
mcp__openclaw__sessions_spawn executionPI harness → direct APIExtra-usage credits — billed
Channel boot, infer model run --gateway, model-fallback chainPI harness → direct APIExtra-usage credits — billed

The asymmetry is invisible to the user until they exercise sessions_spawn. The first time they do, they discover their Path B subagents bill differently than their chat does — using the same credential.

Architectural cause

The PI harness (built-in default) dispatches model calls through provider plugins (e.g., anthropic) which use the credential to make HTTP calls against api.anthropic.com. cliBackends is a separate abstraction: when explicitly invoked (e.g., by webchat's chat code), it spawns the claude binary as a subprocess. PI doesn't consult cliBackends.

So a config that defines cliBackends.claude-cli AND uses PI harness will use the cliBackend for chat (because chat calls cliBackend directly) but the direct-API path for everything else (because PI doesn't know about cliBackends).

What "consult cliBackends" might look like

When PI's anthropic provider dispatches and detects:

  1. The current auth.profiles.<provider-key> is in mode: "oauth" AND provider: "claude-cli" (or equivalent CLI-backed credential type), AND
  2. agents.defaults.cliBackends.<backend-id> is configured for the routed model's provider,

then route the dispatch through the cliBackend (spawn the binary) instead of the direct-API path. That would make subagent execution match chat's billing characteristics for users who've explicitly configured the cliBackend.

A coarser version: a config flag like agents.defaults.embeddedHarness.preferCliBackend: true that explicitly opts the PI harness into cliBackend dispatch when available.

Adjacent

  • #33587 — Codex embedded runner should auto-route through CLI backend when configured (same architectural shape, Codex side)
  • #63316 — openclaw-claude-proxy mode: CLI delegation & community proxy support (maintainer-tracked meta-issue on post-Anthropic-policy routing)
  • #16365 — Extend Pro/Max Subscription Auth to OpenClaw (canonical billing-policy thread)

Empirical impact (one user's data)

After landing local patches for the two related bugs (prepareContextEngineSubagentSpawn init + resolvePinnedAgentHarnessPolicy fallback), a successful end-to-end mcp__openclaw__sessions_spawn test (verified by model.completed event with non-zero lastCallUsage.total in the trajectory file) was achieved only after manually enabling extra-billing on the user's Claude account. Without extra-billing enabled, the same patches let the spawn proceed to the model-call step but fail with the "Third-party apps now draw from your extra usage" 400.

The architectural fix (PI consults cliBackends) would let this user, and any user on the same Max-plan-only setup, run subagents end-to-end without paying extra-usage — matching the behavior they get from chat today.

Mitigation users can apply locally

  • Add a real Anthropic API key as a second auth.profiles entry so PI failover has a non-OAuth credential to land on
  • Or constrain subagents to non-Anthropic providers (MinMax, OpenAI, Ollama, etc.) which don't trigger the third-party-apps filter

Neither is a substitute for fixing the asymmetry at source.

extent analysis

TL;DR

To fix the billing asymmetry issue, modify the PI harness to consult cliBackends and route dispatches through the cliBackend when available, ensuring consistent billing characteristics for chat and subagent execution.

Guidance

  • Identify users affected by the sanctioned claude-cli cliBackend setup and inform them about the billing discrepancy.
  • Consider adding a config flag like agents.defaults.embeddedHarness.preferCliBackend: true to opt the PI harness into cliBackend dispatch when available.
  • As a temporary mitigation, users can add a real Anthropic API key as a second auth.profiles entry or constrain subagents to non-Anthropic providers.
  • Review related issues (#33587, #63316, #16365) for additional context and potential solutions.

Example

No code snippet is provided as the issue requires architectural changes rather than a simple code fix.

Notes

The proposed solution requires modifications to the PI harness and may involve additional development and testing efforts. The mitigation strategies provided can help affected users in the short term but do not address the underlying issue.

Recommendation

Apply the workaround by adding a config flag to prefer cliBackend dispatch when available, as this can help alleviate the billing asymmetry issue for affected users.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix PI harness ignores `cliBackends` configuration, splitting subagent execution and chat path onto different transports for the same OAuth credential [1 participants]