docs: cover Anthropic beta header suppression and claude-cli fallback prelude

- docs/concepts/model-providers.md: add proxy-route shaping rule for the
  09ec5d2c4d fix that suppresses implicit Anthropic beta headers
  (`claude-code-20250219`, `interleaved-thinking-2025-05-14`, OAuth markers)
  on non-direct endpoints, parallel to the existing OpenAI
  `compat.supportsDeveloperRole` rule.
- docs/gateway/cli-backends.md: add a "Fallback prelude from claude-cli
  sessions" section for a96f1fa5ef so users know that non-CLI fallback
  candidates after a claude-cli failure are now seeded with a context prelude
  harvested from Claude Code's `~/.claude/projects/` JSONL (preferring the
  latest `/compact` summary, coalescing tool blocks, skipping same-provider
  `--resume` fallbacks).
This commit is contained in:
Vincent Koc
2026-04-28 01:42:06 -07:00
parent 8a98c08c8a
commit fe7865aad6
2 changed files with 22 additions and 0 deletions

View File

@@ -674,6 +674,7 @@ Example (OpenAIcompatible):
- For slow local models or remote LAN/tailnet hosts, set `models.providers.<id>.timeoutSeconds`. This extends provider model HTTP request handling, including connect, headers, body streaming, and the total guarded-fetch abort, without increasing the whole agent runtime timeout.
- If `baseUrl` is empty/omitted, OpenClaw keeps the default OpenAI behavior (which resolves to `api.openai.com`).
- For safety, an explicit `compat.supportsDeveloperRole: true` is still overridden on non-native `openai-completions` endpoints.
- For `api: "anthropic-messages"` on non-direct endpoints (any provider other than canonical `anthropic`, or a custom `models.providers.anthropic.baseUrl` whose host is not a public `api.anthropic.com` endpoint), OpenClaw suppresses implicit Anthropic beta headers such as `claude-code-20250219`, `interleaved-thinking-2025-05-14`, and OAuth markers, so custom Anthropic-compatible proxies do not reject unsupported beta flags. Set `models.providers.<id>.headers["anthropic-beta"]` explicitly if your proxy needs specific beta features.
</Accordion>
</AccordionGroup>

View File

@@ -224,6 +224,27 @@ Serialization notes:
rotation does not cut the stored CLI session. If a CLI does not expose a
stable OAuth account id, OpenClaw lets that CLI enforce resume permissions.
## Fallback prelude from claude-cli sessions
When a `claude-cli` attempt fails over to a non-CLI candidate in
[`agents.defaults.model.fallbacks`](/concepts/model-failover), OpenClaw seeds
the next attempt with a context prelude harvested from Claude Code's local
JSONL transcript at `~/.claude/projects/`. Without this seed, the fallback
provider would start cold because OpenClaw's own session transcript is empty
for `claude-cli` runs.
- The prelude prefers the latest `/compact` summary or `compact_boundary`
marker, then appends the most recent post-boundary turns up to a char
budget. Pre-boundary turns are dropped because the summary already represents
them.
- Tool blocks are coalesced to compact `(tool call: name)` and
`(tool result: …)` hints to keep the prompt budget honest. The summary is
labeled `(truncated)` if it overflows.
- Same-provider `claude-cli` to `claude-cli` fallbacks rely on Claude's own
`--resume` and skip the prelude.
- The seed reuses the existing Claude session-file path validation, so
arbitrary paths cannot be read.
## Images (pass-through)
If your CLI accepts image paths, set `imageArg`: