---
summary: "Run OpenClaw embedded agent turns through the bundled Codex app-server harness"
title: "Codex harness"
read_when:
- You want to use the bundled Codex app-server harness
- You need Codex harness config examples
- You want Codex-only deployments to fail instead of falling back to PI
---
The bundled `codex` plugin lets OpenClaw run embedded agent turns through the
Codex app-server instead of the built-in PI harness.
Use this when you want Codex to own the low-level agent session: model
discovery, nativethread resume, native compaction, and app-server execution.
OpenClaw still owns chat channels, session files, model selection, tools,
approvals, media delivery, and the visible transcript mirror.
If you are trying to orient yourself, start with
[Agent runtimes](/concepts/agent-runtimes). The short version is:
`openai/gpt-5.5` is the model ref, `codex` is the runtime, and Telegram,
Discord, Slack, or another channel remains the communication surface.
Native Codex turns keep OpenClaw plugin hooks as the public compatibility layer.
These are in-process OpenClaw hooks, not Codex `hooks.json` command hooks:
- `before_prompt_build`
- `before_compaction`, `after_compaction`
- `llm_input`, `llm_output`
- `before_tool_call`, `after_tool_call`
- `before_message_write` for mirrored transcript records
- `agent_end`
Plugins can also register runtime-neutral tool-result middleware to rewrite
OpenClaw dynamic tool results after OpenClaw executes the tool and before the
result is returned to Codex. This is separate from the public
`tool_result_persist` plugin hook, which transforms OpenClaw-owned transcript
tool-result writes.
For the plugin hook semantics themselves, see [Plugin hooks](/plugins/hooks)
and [Plugin guard behavior](/tools/plugin).
The harness is off by default. New configs should keep OpenAI model refs
canonical as `openai/gpt-*` and explicitly force
`embeddedHarness.runtime: "codex"` or `OPENCLAW_AGENT_RUNTIME=codex` when they
want native app-server execution. Legacy `codex/*` model refs still auto-select theharnessforcompatibility,butruntime-backedlegacyproviderprefixesare notshownasnormalmodel/providerchoices.
##Picktherightmodelprefix
OpenAI-familyroutesareprefix-specific.Use`openai-codex/*` when you want CodexOAuththroughPI;use`openai/*` when you want direct OpenAI API access or whenyouareforcingthenativeCodexapp-serverharness:
-PutCodexonadedicatedagentwith`embeddedHarness.runtime:"codex"`. -Keepthedefaultagenton`runtime:"auto"`andPIfallbackfornormalmixed providerusage. -Uselegacy`codex/*` refs only for compatibility. New configs should prefer `openai/*` plus an explicit Codex runtime policy.
|Surface|V1boundary|Futurepath| |---------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------| tool pre,OpenClaw notrewritenative| Requiresjava.lang.StringIndexOutOfBoundsException: Range [217, 216) out of bounds for length 309
| canonicalnative . a mirror andcanprojectfuture ,but . |Addexplicit Codexapp- ifnativethreadsurgery is .
|`tool_result_persist` forCodexnative toolrecords records.| Could mirrortransformed records, but canonical rewrite needs Codex support. |
| Rich native compaction metadata | OpenClaw observes compaction start and completion, but does not receive a stable kept/dropped list, token delta, or summary payload. | Needs richer Codex compaction events. |
| Compaction )
unknownas typeoffetch
MCP parity asacommitted surface isgeneric OpenClaw notversion-ated and nativeMCPpre hookbehavior to. MCP docs once thesupportedapp-erver protocolfloorcovers those payloads |
| Byte ,
## Tools, media, and compaction
The Codex harness changes the low-level embedded agent executor only.
OpenClaw still builds the tool list and receives dynamic tool results from the
harness. Text, images, video, music, TTS, approvals, and messaging-tool output continue through the normal OpenClaw delivery path.
The native hook relay is intentionally generic, but the v1 support contract is
limited to the Codex-native tool and permission paths that OpenClaw tests. Do not
assume every future Codex hook event is an OpenClaw plugin surface until the
runtime contract names it.
Codex MCP tool approval elicitations are routed through OpenClaw's plugin
approval flow when Codex marks `_meta.codex_approval_kind` as
`"mcp_tool_call"`. Codex `request_user_input` prompts are sent back to the
originating chat, and the next queued follow-up message answers that native
server request instead of being steered as extra context. Other MCP elicitation
requests still fail closed.
When the selected model uses the Codex harness, nativethread compaction is
delegated to Codex app-server. OpenClaw keeps a transcript mirror for channel
history, search, `/new`, `/reset`, and future model or harness switching. The
mirror includes the user prompt, final assistant text, and lightweight Codex
reasoning or plan records when the app-server emits them. Today, OpenClaw only
records native compaction start and completion signals. It does not yet expose a
human-readable compaction summary or an auditable list of which entries Codex
kept after compaction.
Because Codex owns the canonical nativethread, `tool_result_persist` does not
currently rewrite Codex-native tool result records. It only applies when
OpenClaw is writing an OpenClaw-owned session transcript tool result.
Media generation does not require PI. Image, video, music, PDF, TTS, and media
understanding continue to use the matching provider/model settings such as
`agents.defaults.imageGenerationModel`, `videoGenerationModel`, `pdfModel`, and
`messages.tts`.
## Troubleshooting
**Codex does not appear as a normal `/model` provider:** that is expected for new configs. Select an `openai/gpt-*` model with
`embeddedHarness.runtime: "codex"` (or a legacy `codex/*` ref), enable `plugins.entries.codex.enabled`,andcheckwhether`plugins.allow`excludes `codex`.
**Anon-CodexmodelusesPI:**thatisexpectedunlessyouforced `embeddedHarness.runtime:"codex"`forthatagentorselectedalegacy `codex/*` ref. Plain `openai/gpt-*` and other provider refs stay on their normal providerpathin`auto`mode.Ifyouforce`runtime:"codex"`,everyembedded turnforthatagentmustbeaCodex-supportedOpenAImodel.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.