跳到正文
FunCoding

OpenAI advanced configuration

Prompt contribution, transport, Fast mode, compaction, and route compat

GPT-5 prompt contribution

OpenClaw adds the legacy behavior contract and optional friendly style only to GPT-5 prompts. GPT-6 models, including Astra and Sol, receive the shared OpenClaw instructions without either addition. The same rule applies to bare and provider-qualified model IDs. The OpenAI plugin setting below controls the friendly style on OpenAI-family GPT-5 routes.

Ordinary native Codex threads also use OpenClaw's assembled base instructions. If you supply your own Codex base instructions, OpenClaw keeps them and sends its policy in developer instructions instead. Neither placement changes which models receive the GPT-5 contribution.

The GPT-5 contribution adds a tagged behavior contract for persona persistence, execution safety, tool discipline, output shape, completion checks, and verification on matching OpenClaw-assembled prompts. Channel- specific reply and silent-message behavior stays in the shared OpenClaw system prompt and outbound delivery policy. The friendly interaction-style layer is separate and configurable.

ValueEffect
"friendly" (default)Enable the friendly interaction-style layer
"on"Alias for "friendly"
"off"Disable only the friendly style layer

Config

{
  plugins: {
    entries: {
      openai: {
        config: { personality: "friendly" },
      },
    },
  },
}

CLI

openclaw config set plugins.entries.openai.config.personality off

Values are case-insensitive at runtime, so "Off" and "off" both disable the friendly style layer.

The retired agents.defaults.promptOverlays key is no longer read; config validation rejects it, and openclaw doctor --fix migrates its personality value into plugins.entries.openai.config.personality when that key is unset.

Advanced configuration

The transport and serviceTier examples below are authored embedded-provider request settings, so an otherwise eligible auto route stays on OpenClaw instead of selecting Codex implicitly. Valid fastMode / fast_mode values and valid cutoff keys are typed agent-runtime controls and do not select a runtime. Runtime-specific examples therefore pin agentRuntime.id explicitly. The native Codex app-server harness owns its transport and request settings. Authored embedded-provider settings can therefore select the declared OpenClaw fallback even with explicit agentRuntime.id: "codex"; see Runtime selection.

Transport (WebSocket vs SSE)

Direct API-key requests use SSE by default. Set params.transport when you want Responses WebSocket mode on an eligible official OpenAI endpoint.

ValueBehavior
"sse" (default)Stream each request over SSE
"auto"Prefer a session-cached WebSocket, with pre-dispatch SSE fallback
"websocket-cached"Explicitly use the session-cached WebSocket path, with the same pre-dispatch SSE fallback
"websocket"Use a transient WebSocket for the request, with pre-dispatch SSE fallback

Cached modes keep one eligible connection per session. When the prior request and response still match the current history, OpenClaw sends only the new input and references the prior response with previous_response_id. Otherwise it sends full history without that reference. Idle cached connections expire after five minutes; keeping a connection warm does not retain the completed run's execution context. Only the run that writes the conversation keeps this connection and its continuation. Background runs on the same conversation (session forks such as skill reviews, memory flush, /btw side questions, compaction summaries) share its prompt-cache key but send full history on their own connection, so they never replace the conversation's continuation.

A setup or handshake failure before request dispatch falls back to SSE; it is not retried or reconnected first. After dispatch, failures with an unknown outcome stop without replaying the request. The explicit server rejections previous_response_not_found, websocket_connection_limit_reached, and the Zero Data Retention unsupported_parameter rejection of previous_response_id are safe exceptions: OpenClaw closes the failed socket and retries that turn once over SSE with full history and no rejected previous_response_id.

{
  agents: {
    defaults: {
      models: {
        "openai/gpt-5.5": {
          agentRuntime: { id: "openclaw" },
          params: { transport: "auto" },
        },
      },
    },
  },
}

ChatGPT Responses SSE turns may exceed 16 MiB in total. The parser bounds each buffered event to 16 MiB of bytes before decoding or parsing it, and cancels oversized events, including events without a closing delimiter.

For cached ChatGPT Responses WebSocket requests, an explicit "Rustponses cannot replay" rejection before any response event triggers one retry on a fresh connection with full input instead of the cached response reference. The retry preserves reasoning, compaction, and completed tool results; it does not rerun tools. Rejections of full input and failures after response events remain terminal.

Related OpenAI docs:

Fast mode

OpenClaw exposes a shared fast-mode toggle for openai/*:

  • Chat/UI: /fast status|auto|on|off|ultrafast|default
  • Config: agents.defaults.models["<provider>/<model>"].params.fastMode

Valid params.fastMode / params.fast_mode values and valid cutoff keys are typed runtime controls. They do not count as authored provider request params and do not select OpenClaw or Codex. The example below pins embedded OpenClaw because it describes a direct provider request.

When enabled on the embedded runtime, OpenClaw maps fast mode to OpenAI API Fast mode (formerly Priority processing) and sends service_tier = "priority". Explicit /fast ultrafast or params.fastMode: "ultrafast" sends service_tier = "ultrafast" instead. While Ultrafast is requested, OpenClaw caps the embedded runtime's context budget and Responses server-compaction threshold at 260,000 tokens. This leaves headroom below the tier's serving boundary for output and tool rounds. Smaller configured budgets or responsesCompactThreshold values still win; larger thresholds are capped for Ultrafast. Fast, Standard, and other explicit service tiers keep their configured budgets. Client-side compaction uses the same capped budget even when responsesServerCompaction: false; its reserve can make it run earlier. This helps long conversations stay on Ultrafast, though the provider still chooses the served tier.

The selected account and model must support that tier; the provider can reject it or return a different effective tier. Fast mode does not rewrite reasoning or text.verbosity. fastMode: "auto" starts new model calls fast until the auto cutoff, then starts later retry, fallback, tool-result, or continuation calls without fast mode. The cutoff defaults to 60 seconds; set params.fastAutoOnSeconds on the active model to change it.

For the embedded OpenClaw runtime, the Control UI uses provider model and route limits when offering Standard, Fast, and Ultrafast. This works for auth profiles, environment keys, and provider config (including SecretRefs). With an OpenAI API key, OpenClaw also reads each model's tiers from the same account model listing Codex uses for that key, and offers only those: for example, GPT-6 Cyber advertises no Fast or Ultrafast tier, so the picker shows Standard only. When that listing is unavailable, every tier stays offered. Models limited to Standard or Fast keep those restrictions. Custom endpoints and ChatGPT account catalogs retain their own tier policy.

If a response to an Ultrafast request echoes a different service_tier, OpenClaw records a temporary observation for that credential, model, and route. Ultrafast stays selectable, and the composer's Speed tooltip shows the requested and served tiers. Later calls keep requesting the selected tier unless repeated explicit rejections trigger the run-local cooldown below. The hint clears one minute after the latest downgrade. Responses honoring the requested tier do not clear it early, so intermittent capacity changes do not repeatedly refresh the model catalog.

If the native OpenAI API explicitly rejects service_tier before output, tool activity, or active-response steering, OpenClaw automatically retries that request at a slower tier: Ultrafast → Fast → Standard. The hint records that recovery without changing saved preferences. After two consecutive Ultrafast rejections for the same account/model route, later model requests on that route, including later turns and runs, use Fast directly for ten minutes or twenty model requests, whichever ends first. The next Ultrafast request probes the tier again: a rejection renews the cooldown, while a successful Ultrafast request resets the rejection count. The cooldown is kept in memory and starts fresh after a Gateway restart. A successful response served at a different tier does not itself trigger a cooldown.

The cooldown also applies to explicit Ultrafast request overrides; other tiers remain as configured. OpenClaw does not retry tier errors after cancellation or an ambiguous connection failure.

Observations also clear on credential replacement, profile discovery refresh, or retirement of the prepared runtime, and are not persisted across restarts. ChatGPT-account availability remains based on authenticated account catalog discovery.

{
  agents: {
    defaults: {
      models: {
        "openai/gpt-5.5": {
          agentRuntime: { id: "openclaw" },
          params: { fastMode: "auto", fastAutoOnSeconds: 30 },
        },
      },
    },
  },
}

The full precedence is inline message, stored session, per-agent default, global default, per-model params.fastMode, then off. /fast default clears only the session layer. /status reports the resolved OpenClaw policy and runtime, not the upstream service tier actually honored or returned. See Thinking levels and Codex harness.

Fast mode is premium-priced and model-specific. GPT-5.6 Sol API Fast mode currently costs 2× Standard token pricing, with long-context multipliers stacking as described in context window defaults and long-context opt-in. ChatGPT/Codex-credit Fast mode is a separate billing system: GPT-5.6 and GPT-5.5 currently consume 2.5× Standard credits, while API-key Codex runs use API token pricing. See Fast mode, API pricing, and Codex speed.

OpenAI API Fast mode with service_tier

OpenAI now calls this API product Fast mode; it was formerly Priority processing. OpenClaw sends the wire value service_tier = "priority". Set an explicit tier per model on the embedded OpenClaw runtime:

{
  agents: {
    defaults: {
      models: {
        "openai/gpt-5.5": {
          agentRuntime: { id: "openclaw" },
          params: { serviceTier: "priority" },
        },
      },
    },
  },
}

Supported values: auto, default, flex, priority, ultrafast. Availability depends on the selected provider route, account, and model. serviceTier and service_tier set an inherited default, not a lock. A session or per-message speed selection takes precedence: Standard sends default, Fast sends priority, and Ultrafast sends ultrafast when supported. Without a speed override, configured tiers such as flex and auto remain unchanged. /fast default clears the session override.

Speed controls remain editable while a response runs. Changes apply to later requests; they do not interrupt or rewrite a request already in flight.

params.serviceTier is an authored embedded-provider setting, not native Codex app-server configuration. It is forwarded only by the embedded runtime on OpenAI Responses routes, including compatible base URLs, and native ChatGPT endpoints (chatgpt.com/backend-api). Compatible endpoints must honor the requested tier; a saved preference does not guarantee fulfillment. Configure the native harness separately with plugins.entries.codex.config.appServer.serviceTier; the shared Fast-mode run control can supersede that value.

Server-side compaction (Responses API)

With the built-in legacy context engine, the OpenAI plugin's OpenClaw stream wrapper auto-enables server-side compaction for store-capable direct OpenAI Responses models (openai/* resolved to api.openai.com):

  • Uses store: true until input contains a compaction checkpoint, then uses store: false for replay (unless model compat sets supportsStore: false)
  • Injects context_management: [{ type: "compaction", compact_threshold: ... }]
  • Default compact_threshold: 85% of contextWindow (or 80000 when unavailable), the same fraction as client compaction

The same resolved route and effective threshold gate the client preflight, so OpenClaw does not delay local compaction unless the transport will inject context_management. This automatic-inline policy excludes ChatGPT OAuth, custom proxies, and routes with compat.supportsStore: false. It applies to the built-in OpenClaw runtime and embedded OpenAI provider hooks. The native Codex app-server harness continues to own its own compaction.

On direct API-key openai-responses routes, defaults, explicit opt-in, and stored checkpoint replay follow context-engine compaction ownership.

Checkpoint replay is stateless: OpenAI can reject repeated stored checkpoint input with item_conflict, even when item IDs are removed. OpenClaw preserves the checkpoint and retained context and sends store: false, without a stored previous_response_id. This also lets an already-affected session recover on its next turn without editing its history. Requests without checkpoints retain stored continuation. The transport enforces stateless checkpoint replay after payload hooks, so a hook cannot re-enable storage or retain a stale previous_response_id for that input. This prevents a conflict without replaying a request after output or tool work has started. Azure and custom endpoint storage policies are unchanged.

On the native OpenAI endpoint, replayed reasoning that carries encrypted content is sent without its item ID, and the message and tool-call IDs that depend on it are omitted too. A turn sent with store: false (for example, one that carries a compaction checkpoint) returns item IDs that name no stored record. A later stored request records that reasoning under its ID, and the next stored request fails with item_conflict after output has started. Prompt caching is unchanged.

If the server rejects saved items with item_conflict before output starts, OpenClaw automatically retries once using saved conversation text and tool results, without the rejected item IDs, reasoning, or compaction checkpoint. Opening a stream, reporting compaction progress, or receiving an un-emitted text/reasoning snapshot inside a failed response does not count as output. Tool calls and results receive matching replacement IDs. The recovery is recorded in the transcript so later turns and reloads retain the repair. Completed tool calls retain their original argument JSON for exact replay after a restart, including whitespace and large integers. Intentional argument edits use the edited value. Older transcripts without those bytes use the recovery above when rejected. Unaffected sessions keep their prompt prefix and continuation. Gateway logs record item_conflict_recovery, a session hash, and the outcome (started, recovered, failed, or deferred). If recovery fails, the reply offers retry, /compact, and model-switch guidance. After output starts, the transport saves the repair for the next request (deferred). The active runtime retries once in the same turn only when its execution evidence proves the entire run is replay-safe, with no potential tool side effects and no pending or committed delivery. Otherwise the visible failure remains, and the saved repair applies to a later request, including a new run or an internal session-effects fork of that history. Successful requests that apply a saved repair also log recovered. Subagent completion deliveries with a deferred repair retry automatically, up to three delivery attempts, without waiting for another user message. Encrypted checkpoints remain bound to their original session.

On the native ChatGPT sign-in route, the built-in runtime instead uses Codex V2 compaction by default for context-budget pressure before a model request, including between completed tool rounds. It sends the normal request with a trailing compaction_trigger, using the same instructions, tools, payload hooks, and cache key, with store: false. Only a successfully completed stream with one opaque checkpoint can replace the covered context. Retained human messages remain eligible across subsequent compactions. The saved checkpoint remains active on later tool rounds and user turns, including after the session is restored.

V2 starts when the known or projected request occupancy reaches min(context window - effective reserve, floor(0.85 × context window)), the same trigger as client maintenance on every other route. With a 500,000-token window and 20,000-token reserve, this is 425,000 tokens. It uses completed-request usage when available and prices pending content at the next normal request boundary. This earlier trigger leaves room for tool output and the compaction request; it does not lower the model's physical context limit or change the public API-key route's 85% inline threshold.

The entire outgoing request must still fit that physical window. If one pending message or tool result crosses it before V2 can run, OpenClaw falls back to client compaction. It does not checkpoint only the old prefix and silently discard the pending suffix.

params.responsesServerCompaction: false or params.responsesCompactEndpoint: false disables this V2 path. Disabling automatic compaction also disables V2. On this route, manual /compact (with or without focus instructions) and provider-confirmed overflow use client-side compaction, not V2. If V2 is unavailable or fails before persistence while the request still fits the reserve-based budget, OpenClaw sends the normal request without compacting and does not retry a failed V2 attempt in the same run. Once that budget is exceeded, the existing client compactor handles the fallback and logs its reason; explicit compact-endpoint opt-ins still apply there. Cancellation does not start a fallback, and a committed checkpoint is not compacted again because a later observer fails. Context engines that own compaction retain their existing behavior, as do explicitly configured compaction models or summarization providers.

OpenAI emits the compacted state as an encrypted compaction output item. Keep that item opaque. For stateless continuation, carry the newest item forward and drop the earlier input prefix it replaces. OpenClaw does this automatically: it persists and replays the item only for the matching route, session, and auth identity, preserves it across worker transcript commits, and filters it from user-visible history and diagnostics. Never display or log the encrypted content.

For API-key requests to /responses/compact, OpenClaw saves the complete returned window: retained user, developer, system, or assistant messages followed by one encrypted checkpoint. The endpoint may retain fewer user messages than it received. Retained content, including assistant output_text, is replayed after a restart without pruning messages or rewriting content. Retained assistant item IDs are omitted on replay because their original reasoning items have been absorbed by the checkpoint. Invalid windows, windows that require transcript redaction, and windows that exceed the next request's budget fall back to client-side compaction.

The next foreground turn waits for any pending local transcript projection rebuild before reading the checkpoint. Request token counts need not fall below the compaction threshold: instructions and tools are sent again, and tool results or reasoning produced after the checkpoint remain in context. To check replay, inspect item types rather than token totals: the newest compaction item replaces the covered prefix, followed only by later items.

Enable explicitly

Useful for store-capable endpoints like Azure OpenAI Responses. Setting this to true does not override endpoint or supportsStore capability:

{
  agents: {
    defaults: {
      models: {
        "azure-openai-responses/gpt-5.5": {
          params: { responsesServerCompaction: true },
        },
      },
    },
  },
}

Custom threshold

{
  agents: {
    defaults: {
      models: {
        "openai/gpt-5.5": {
          params: {
            responsesServerCompaction: true,
            responsesCompactThreshold: 120000,
          },
        },
      },
    },
  },
}

Disable

{
  agents: {
    defaults: {
      models: {
        "openai/gpt-5.5": {
          params: { responsesServerCompaction: false },
        },
      },
    },
  },
}

On the public OpenAI Responses route, responsesServerCompaction only controls context_management injection; on the native ChatGPT sign-in route, setting it to false also disables V2 compaction as described above. The public OpenAI Responses API also uses /responses/compact by default for budget-triggered compaction and for /compact without focus instructions. Set params.responsesCompactEndpoint: false to disable this separate endpoint. /compact <focus>, provider-confirmed overflow, and endpoint failures use client-side summarization.

Direct OpenAI Responses models use store: false when replaying a compaction checkpoint, as described above.

Strict-agentic GPT mode

For openai provider GPT-5-family models run through OpenClaw's embedded runtime, OpenClaw already defaults to a stricter execution contract called strict-agentic. It auto-activates whenever the resolved provider is openai and the model id matches the GPT-5 family, unless config explicitly opts back out:

{
  agents: {
    defaults: {
      embeddedAgent: { executionContract: "default" },
    },
  },
}

Setting "strict-agentic" explicitly is a no-op on a supported lane (it is already the default) and inert on unsupported provider/model pairs.

With strict-agentic active, OpenClaw:

  • Makes progress_card available for substantial work unless tools.updatePlan disables it
  • Retries structurally empty or reasoning-only turns with a visible-answer continuation
  • Uses explicit harness plan events when the selected harness provides them

OpenClaw does not classify assistant prose to decide whether a turn is a plan, progress update, or final answer.

This contract lives entirely in OpenClaw's embedded agent runner. It does not apply to the native Codex app-server harness, which manages its own turn and plan behavior; the harness selection matters more than the execution-contract setting for native Codex runs.

Native vs OpenAI-compatible routes

OpenClaw treats direct OpenAI, Codex, and Azure OpenAI endpoints differently from generic OpenAI-compatible /v1 proxies:

Native routes (openai/*, Azure OpenAI):

  • Keep reasoning: { effort: "none" } only for models that support the OpenAI none effort
  • Omit disabled reasoning for models or proxies that reject reasoning.effort: "none"
  • Default tool schemas to strict mode
  • Attach hidden attribution headers on verified native hosts only (Azure OpenAI does not get these headers, even though it is a native route)
  • Keep OpenAI-only request shaping (service_tier, store, reasoning-compat, prompt-cache hints)
  • Send tool-bearing turns for reasoning models configured with openai-completions on api.openai.com to /v1/responses, because Chat Completions rejects function tools with reasoning for current GPT models. Credentials, endpoint host, and proxy routes are unchanged.

Proxy/compatible routes:

  • Use looser compat behavior
  • Strip Completions store from non-native openai-completions payloads
  • Accept advanced params.extra_body/params.extraBody pass-through JSON for OpenAI-compatible Completions proxies
  • Accept params.chat_template_kwargs for OpenAI-compatible Completions proxies such as vLLM
  • Do not force strict tool schemas or native-only headers

Both native OpenAI and compatible openai-completions routes accept params.extraBody (alias extra_body). For example, to send an explicit OpenAI safety identifier, configure a model with api: "openai-completions" and set its per-model params:

{ extraBody: { safety_identifier: "<stable-user-id-hash>" } }

Supply a stable, non-PII hash yourself; OpenClaw does not derive this value from channel senders or other user identity. A shared static value identifies the shared scope, not each person using it. This passthrough belongs to the embedded OpenClaw runtime; it does not apply to models configured directly with api: "openai-responses" or to the native Codex runtime.

If a usable tool schema is incompatible with requested strict mode, the request uses strict: false. Debug logs report the downgrade under openai-transport, with a bounded sample of incompatible tools. Built-in and managed Responses requests share duplicate suppression for the same model and schemas. Compatibility checks inspect schema constraints, not literal names in schema maps or annotation data such as examples and defaults.