Skip to content

feat(claude): add an opt-in relaxed system-prompt layout - #8525

Open
rdself wants to merge 1 commit into
router-for-me:devfrom
rdself:coder/claude-relaxed-system-prompt-v8
Open

rdself wants to merge 1 commit into
router-for-me:devfrom
rdself:coder/claude-relaxed-system-prompt-v8

Conversation

@rdself

@rdself rdself commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Add an opt-in relaxed system-prompt layout for Claude Messages generation requests. Keep caller instructions in the top-level system array after the required Claude Code billing and identity blocks and any configured system-prompt prefix, using the existing configuration lookup and request pipeline.

Behavior

  • cloak.relaxed-system-prompt: true keeps billing and identity first, follows with any configured system-prompt prefix, and then appends nonempty caller text blocks in their original order with their supplied fields. Duplicate injected attribution blocks are omitted.
  • The system-prompt policy preserves caller message placement and adds neither a generated current-date reminder nor Fable reporting guidance in relaxed mode. Translation, configured payload rules, sensitive-word obfuscation and literal replacements, request sanitization, credential matching, token-count requests and returned fields, signing, and transport retain the upstream pipeline.
  • Relaxed mode is disabled by default. strict-mode takes precedence, and shared upstream defaults still govern whether cloaking runs. Confirmed native Claude Code requests retain upstream passthrough behavior, including explicit never / uncloak handling on non-CLI credentials; relaxed mode does not restore attribution removed by that policy. An explicit credential mode can override the shared default.

Configuration

The optional boolean preserves omitted, false, and true through YAML loading/saving, runtime cloning, management edits, and configuration change detection.

api-keys:
  claude:
    - name: primary
      keys:
        - api-key: "..."
          cloak:
            relaxed-system-prompt: true

The option follows the existing authoritative cloak lookup. In Home mode, a present credential_options.cloak object supplies the credential's cloak configuration; otherwise the matching local Claude key supplies it. An explicit relaxed value in that resolved configuration overrides executor attributes and top-level credential metadata, including false. An omitted value falls back to those attributes/metadata. Standalone mode ignores the Home-only object.

Home credentials can supply the boolean as credential_options.cloak.relaxed-system-prompt. File credentials can use cloak_relaxed_system_prompt as a JSON boolean or string. Metadata reads use the existing credential metadata lock, including the structured Home read; the new option does not add a separate configuration path.

The Home server uses its CPA SDK to build credential options from its configuration. Its SDK must include this field to emit it from Home-managed YAML.

Follow-up to #6410

This revision is based on dev at a15c8f2. It retains the turn-aware system builder and the upstream cloak.cache-ttl option. The relaxed layout and the cache TTL are resolved independently, with caller message placement, strict-mode precedence, explicit cache control, and the final payload rules preserved. The management test exercises the registered v8 routes. Closing review

Validation

  • Built ./cmd/server on Linux amd64 with Go 1.26.10 and CGO enabled.
  • Tested v8 YAML and management round trips, relaxed layout and configuration precedence, cache TTL coexistence, and the final payload boundary.
  • Passed focused Claude executor, config, identity, watcher, thinking, API, and Responses WebSocket tests.
  • gofmt and git diff --check passed.

Copilot AI balanced review requested due to automatic review settings November 26, 2026 18:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T09:15:08.063364Z d585c66 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@atahan150

Copy link
Copy Markdown

+1 from the #8647 side, with a fresh measurement showing what this layout would match.

I captured real Claude Code 2.1.331 locally against a dummy endpoint, running claude -p "…" --system-prompt "<caller text>" --tools "". That is the usual Agent SDK pattern with a custom system prompt. The system array it sent was:

  1. x-anthropic-billing-header: cc_version=2.1.331.527; cc_entrypoint=sdk-cli;
  2. You are a Claude agent, built on Anthropic's Claude Agent SDK.
  3. <caller text>, as its own top-level block

No tools, and no role: system turn in messages.

I sent the same caller request through v8.1.12 (and v8.1.11) with cloak.entrypoint: sdk-cli and no prefix. The output matches 1 and 2, but the caller text is moved into messages as a role: system turn. That placement is the only remaining difference from the real claude -p --system-prompt shape, and this opt-in layout removes it. With this layout on, a non-CC client with a system prompt becomes indistinguishable in shape from an Agent SDK app with a custom prompt, and nobody has to ship the default CLI prompt text.

We'd turn it on as soon as it lands.

@atahan150

Copy link
Copy Markdown

Correction to my measurement above: I only inspected the top-level system array. Real claude -p --system-prompt (2.1.321 and 2.1.331) also sends a role: system turn in messages, carrying its environment context (cwd, platform, OS). So the caller text is top-level and an environment note is mid-conversation. The relaxed layout would still match where the caller's text lives, but my "no role: system turn" statement was wrong. Sorry for the noise.

@rdself
rdself force-pushed the coder/claude-relaxed-system-prompt-v8 branch from 438bb26 to cb8fbab Compare December 3, 2026 11:03
@rdself
rdself force-pushed the coder/claude-relaxed-system-prompt-v8 branch from cb8fbab to d585c66 Compare December 4, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants