mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-30 20:16:33 +00:00
* refactor: extract agent core package Introduce packages/agent-core as the OpenClaw-owned home for reusable agent loop, harness, session, prompt, and runtime dependency contracts. * refactor: extract shared llm runtime Move provider model registries, stream wrappers, OAuth helpers, and LLM utilities into src/llm with plugin-sdk barrels instead of depending on the old embedded runtime layout. * refactor: remove pi runtime internals Rename remaining Pi-shaped agent surfaces to OpenClaw agent runtime names, delete obsolete Pi docs and package graph checks, and add the third-party notice for incorporated code. * refactor: tighten agent session runtime Make agent-core/runtime dependencies explicit, consolidate compaction and session transcript helpers, and move model/session helpers behind OpenClaw-owned contracts. * refactor: remove static model and pi auth paths Drop static model catalogs and Pi auth bridges, move model/provider facts to manifest-owned runtime contracts, and harden internal embedded-agent utilities. * refactor: remove legacy provider compat paths * docs: remove agent parity notes * fix: skip provider wildcard metadata parsing * refactor: share session extension sdk loading * refactor: inline acpx proxy error formatter * refactor: fold edit recovery into edit tool * fix: accept extension batch separator * test: align startup provider plugin expectations * fix: restore provider-scoped release discovery * test: align static asset packaging expectations * fix: run static provider catalogs during scoped discovery * fix: add provider entry catalogs for scoped live discovery * fix: load lightweight provider catalog entries * fix: refresh provider-scoped plugin metadata * fix: keep provider catalog entries on release live path * fix: keep static manifest models in release live checks * fix: harden release model discovery * fix: reduce OpenAI live cache probe reasoning * fix: disable OpenAI cache probe reasoning * ci: extend OpenAI gateway live timeout * fix: extend live gateway model budget * fix: stabilize release validation regressions * fix: honor provider aliases in model rows * fix: stabilize release validation lanes * fix: stabilize release memory qa * ci: stabilize release validation lanes * ci: prefer ipv4 for live docker node calls * fix: restore shared tool-call stream wrapper * ci: remove legacy pi test shard alias * fix: clean up embedded agent test drift * fix: stabilize runtime alias status * fix: clean up embedded agent ci drift * fix: restore release ci invariants * fix: clean up post-rebase runtime drift * fix: restore release ci checks * fix: restore release ci after rebase * fix: remove stale pi runtime path * test: align compaction runtime expectations * test: update plugin prerelease expectations * fix: handle claude live tool approvals * fix: stabilize release validation gates * fix: finish agent runtime import * test: finish post-rebase agent runtime mocks * fix: keep codex compaction native * fix: stabilize codex app-server hook tests * test: isolate codex diagnostic active run * test: remove codex diagnostic completion race # Conflicts: # extensions/codex/src/app-server/run-attempt.test.ts * ci: fix full release manifest performance run id * refactor: narrow llm plugin sdk boundary * chore: drop generated google boundary stamps * fix: repair rebase fallout * fix: clean up rebased runtime references * fix: decode codex jwt payloads as base64url * fix: preserve shipped pi runtime alias * fix: add scoped sdk virtual modules * fix: decode llm codex oauth jwt as base64url * fix: avoid stale vertex adc negative cache * fix: harden tool arg decoding and codeql path * fix: keep vertex adc negative checks live * refactor: consolidate codex jwt and edit helpers * fix: await codex oauth node runtime imports * fix: preserve sdk tool and notice contracts * fix: preserve shipped compat config boundaries * fix: align codex oauth callback host * fix: terminate agent-core loop streams on failure * fix: keep codex oauth callback alive during fallback * ci: include session tools in critical codeql scans * fix: keep Cloudflare Anthropic provider auth header * docs: redirect legacy pi runtime pages * fix: honor bundled web provider compat discovery * fix: protect session output spill files * fix: keep legacy agent dir env blocked * fix: contain auto-discovered skill symlinks * fix: harden agent core sdk proxy surfaces * fix: restore approval reaction sdk compat * fix: keep live docker runs bounded * fix: keep codex oauth redirect host aligned * fix: resolve post-rebase agent runtime drift * fix: redact anthropic oauth parse failures * fix: preserve responses strict tool shaping * fix: repair agent runtime rebase cleanup * docs: redirect retired parity pages * fix: bound auto-discovered resources to roots * fix: repair post-rebase agent test drift * fix: preserve bundled provider allowlist migration * fix: preserve manifest-owned provider aliases * fix: declare photon image dependency * fix: keep provider headers out of proxy body * fix: preserve shipped env aliases * fix: refresh control ui i18n generated state * fix: quote read fallback paths * fix: preview edits through configured backend * test: satisfy core test typecheck * fix: preserve ZAI usage auth fallback * test: repair codex diagnostic test * fix: repair agent runtime rebase drift * test: finish embedded runner import rename * fix: repair agent runtime rebase integrations * test: align compaction oauth fallback expectations * fix: allow sdk-auth session models * fix: update doctor tool schema import * fix: preserve bedrock plugin region * fix: stream harmony-like prose immediately * ci: include session runtime in codeql shards * fix: repair latest rebase integrations * fix: honor explicit codex websocket transport * fix: keep openai-compatible credentials provider-scoped * fix: refresh sdk api baseline after rebase * fix: route cli runtime aliases through openclaw harness * test: rename stale harness mock expectation * test: rename embedded agent overflow calls * test: clean embedded auth test wording * test: use openclaw stream types in deepinfra cache test * fix: refresh sdk api baseline on latest main * fix: honor bundled discovery compat allowlists * fix: refresh sdk api baseline after latest rebase * fix: remove stale rebase imports * test: rename stale model catalog mock * test: mock renamed doctor runtime modules * fix: map canonical kimi env auth * fix: use internal model registry in bench script * fix: migrate deepinfra provider catalog entry * fix: enforce builtin tool suppression * fix: route compaction auth and proxy payloads safely * refactor: prune unused llm registry leftovers * test: update codex hooks session import * test: fix model picker ci coverage * test: align model picker auth mock types
258 lines
22 KiB
Markdown
258 lines
22 KiB
Markdown
---
|
|
summary: "Runtime boundaries, hooks, tools, permissions, and diagnostics for the Codex harness"
|
|
title: "Codex harness runtime"
|
|
read_when:
|
|
- You need the Codex harness runtime support contract
|
|
- You are debugging native Codex tools, hooks, compaction, or feedback upload
|
|
- You are changing plugin behavior across OpenClaw and Codex harness turns
|
|
---
|
|
|
|
This page documents the runtime contract for Codex harness turns. For setup and
|
|
routing, start with [Codex harness](/plugins/codex-harness). For config fields,
|
|
see [Codex harness reference](/plugins/codex-harness-reference).
|
|
|
|
## Overview
|
|
|
|
Codex mode is not OpenClaw with a different model call underneath. Codex owns more of
|
|
the native model loop, and OpenClaw adapts its plugin, tool, session, and
|
|
diagnostic surfaces around that boundary.
|
|
|
|
OpenClaw still owns channel routing, session files, visible message delivery,
|
|
OpenClaw dynamic tools, approvals, media delivery, and a transcript mirror.
|
|
Codex owns the canonical native thread, native model loop, native tool
|
|
continuation, and native compaction.
|
|
|
|
Prompt routing follows the selected runtime, not just the provider string. A
|
|
native Codex turn receives Codex app-server developer instructions, while an
|
|
explicit OpenClaw compatibility route keeps the normal OpenClaw system prompt even
|
|
when it uses Codex-flavored OpenAI auth or transport.
|
|
|
|
Native Codex keeps Codex-owned base/model instructions and project-doc behavior
|
|
according to the active Codex thread config. OpenClaw starts and resumes native
|
|
Codex threads with Codex's built-in personality disabled so workspace
|
|
personality files and OpenClaw agent identity stay authoritative. Lightweight
|
|
OpenClaw runs still preserve their existing project-doc suppression. OpenClaw
|
|
developer instructions cover OpenClaw runtime concerns such as source-channel
|
|
delivery, OpenClaw dynamic tools, ACP delegation, adapter context, and the
|
|
active agent workspace profile files. OpenClaw skill catalogs plus `MEMORY.md`
|
|
and active `BOOTSTRAP.md` content are projected as turn input reference context
|
|
for native Codex.
|
|
|
|
## Thread bindings and model changes
|
|
|
|
When an OpenClaw session is attached to an existing Codex thread, the next turn
|
|
sends the currently selected OpenAI model, approval policy, sandbox, and service
|
|
tier to app-server again. Switching from `openai/gpt-5.5` to
|
|
`openai/gpt-5.2` keeps the thread binding but asks Codex to continue with the
|
|
newly selected model.
|
|
|
|
## Visible replies and heartbeats
|
|
|
|
When a direct/source chat turn runs through the Codex harness, visible replies
|
|
default to automatic final assistant delivery for internal WebChat surfaces.
|
|
This keeps Codex aligned with the Pi harness prompt contract: agents reply
|
|
normally, and OpenClaw posts the final text to the source conversation. Set
|
|
`messages.visibleReplies: "message_tool"` when a direct/source chat should
|
|
intentionally keep final assistant text private unless the agent calls
|
|
`message(action="send")`.
|
|
|
|
Codex heartbeat turns also get `heartbeat_respond` in the searchable OpenClaw
|
|
tool catalog by default, so the agent can record whether the wake should stay
|
|
quiet or notify without encoding that control flow in final text.
|
|
|
|
Heartbeat-specific initiative guidance is sent as a Codex collaboration-mode
|
|
developer instruction on the heartbeat turn itself. Ordinary chat turns restore
|
|
Codex Default mode instead of carrying heartbeat philosophy in their normal
|
|
runtime prompt. When a non-empty `HEARTBEAT.md` exists, the heartbeat
|
|
collaboration-mode instructions point Codex at the file instead of inlining its
|
|
contents.
|
|
|
|
## Hook boundaries
|
|
|
|
The Codex harness has three hook layers:
|
|
|
|
| Layer | Owner | Purpose |
|
|
| ------------------------------------- | ------------------------ | ------------------------------------------------------------------- |
|
|
| OpenClaw plugin hooks | OpenClaw | Product/plugin compatibility across OpenClaw and Codex harnesses. |
|
|
| Codex app-server extension middleware | OpenClaw bundled plugins | Per-turn adapter behavior around OpenClaw dynamic tools. |
|
|
| Codex native hooks | Codex | Low-level Codex lifecycle and native tool policy from Codex config. |
|
|
|
|
OpenClaw does not use project or global Codex `hooks.json` files to route
|
|
OpenClaw plugin behavior. For the supported native tool and permission bridge,
|
|
OpenClaw injects per-thread Codex config for `PreToolUse`, `PostToolUse`,
|
|
`PermissionRequest`, and `Stop`.
|
|
|
|
When Codex app-server approvals are enabled, meaning `approvalPolicy` is not
|
|
`"never"`, the default injected native hook config omits `PermissionRequest` so
|
|
Codex's app-server reviewer and OpenClaw's approval bridge handle real
|
|
escalations after review. Operators can explicitly add `permission_request` to
|
|
`nativeHookRelay.events` when they need the compatibility relay.
|
|
|
|
Other Codex hooks such as `SessionStart` and `UserPromptSubmit` remain
|
|
Codex-level controls. They are not exposed as OpenClaw plugin hooks in the v1
|
|
contract.
|
|
|
|
For OpenClaw dynamic tools, OpenClaw executes the tool after Codex asks for the
|
|
call, so OpenClaw fires the plugin and middleware behavior it owns in the
|
|
harness adapter. For Codex-native tools, Codex owns the canonical tool record.
|
|
OpenClaw can mirror selected events, but it cannot rewrite the native Codex
|
|
thread unless Codex exposes that operation through app-server or native hook
|
|
callbacks.
|
|
|
|
Codex app-server item notifications also provide async `after_tool_call`
|
|
observations for native tool completions that are not already covered by the
|
|
native `PostToolUse` relay. These observations are for telemetry and plugin
|
|
compatibility only; they cannot block, delay, or mutate the native tool call.
|
|
|
|
Compaction and LLM lifecycle projections come from Codex app-server
|
|
notifications and OpenClaw adapter state, not native Codex hook commands.
|
|
OpenClaw's `before_compaction`, `after_compaction`, `llm_input`, and
|
|
`llm_output` events are adapter-level observations, not byte-for-byte captures
|
|
of Codex's internal request or compaction payloads.
|
|
|
|
Codex native `hook/started` and `hook/completed` app-server notifications are
|
|
projected as `codex_app_server.hook` agent events for trajectory and debugging.
|
|
They do not invoke OpenClaw plugin hooks.
|
|
|
|
## V1 support contract
|
|
|
|
Supported in Codex runtime v1:
|
|
|
|
| Surface | Support | Why |
|
|
| --------------------------------------------- | -------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
| OpenAI model loop through Codex | Supported | Codex app-server owns the OpenAI turn, native thread resume, and native tool continuation. |
|
|
| OpenClaw channel routing and delivery | Supported | Telegram, Discord, Slack, WhatsApp, iMessage, and other channels stay outside the model runtime. |
|
|
| OpenClaw dynamic tools | Supported | Codex asks OpenClaw to execute these tools, so OpenClaw stays in the execution path. |
|
|
| Prompt and context plugins | Supported | OpenClaw projects OpenClaw-specific prompt/context into the Codex turn while leaving Codex-owned base, model, and configured project-doc prompts in the native Codex lane. OpenClaw disables Codex's built-in personality for native threads so agent workspace personality files remain authoritative. Native Codex developer instructions accept only command guidance explicitly scoped to `codex_app_server`; legacy global command hints remain for non-Codex prompt surfaces. |
|
|
| Context engine lifecycle | Supported | Assemble, ingest, and after-turn maintenance run around Codex turns. Context engines do not replace native Codex compaction. |
|
|
| Dynamic tool hooks | Supported | `before_tool_call`, `after_tool_call`, and tool-result middleware run around OpenClaw-owned dynamic tools. |
|
|
| Lifecycle hooks | Supported as adapter observations | `llm_input`, `llm_output`, `agent_end`, `before_compaction`, and `after_compaction` fire with honest Codex-mode payloads. |
|
|
| Final-answer revision gate | Supported through native hook relay | Codex `Stop` is relayed to `before_agent_finalize`; `revise` asks Codex for one more model pass before finalization. |
|
|
| Native shell, patch, and MCP block or observe | Supported through native hook relay | Codex `PreToolUse` and `PostToolUse` are relayed for committed native tool surfaces, including MCP payloads on Codex app-server `0.125.0` or newer. Blocking is supported; argument rewriting is not. |
|
|
| Native permission policy | Supported through Codex app-server approvals and compatibility native hook relay | Codex app-server approval requests route through OpenClaw after Codex review. The `PermissionRequest` native hook relay is opt-in for native approval modes because Codex emits it before guardian review. |
|
|
| App-server trajectory capture | Supported | OpenClaw records the request it sent to app-server and the app-server notifications it receives. |
|
|
|
|
Not supported in Codex runtime v1:
|
|
|
|
| Surface | V1 boundary | Future path |
|
|
| --------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
| Native tool argument mutation | Codex native pre-tool hooks can block, but OpenClaw does not rewrite Codex-native tool arguments. | Requires Codex hook/schema support for replacement tool input. |
|
|
| Editable Codex-native transcript history | Codex owns canonical native thread history. OpenClaw owns a mirror and can project future context, but should not mutate unsupported internals. | Add explicit Codex app-server APIs if native thread surgery is needed. |
|
|
| `tool_result_persist` for Codex-native tool records | That hook transforms OpenClaw-owned transcript writes, not Codex-native tool records. | Could mirror transformed records, but canonical rewrite needs Codex support. |
|
|
| Rich native compaction metadata | OpenClaw can request native compaction, but does not receive a stable kept/dropped list, token delta, completion summary, or summary payload. | Needs richer Codex compaction events. |
|
|
| Compaction intervention | OpenClaw does not let plugins or context engines veto, rewrite, or replace native Codex compaction. | Add Codex pre/post compaction hooks if plugins need to veto or rewrite native compaction. |
|
|
| Byte-for-byte model API request capture | OpenClaw can capture app-server requests and notifications, but Codex core builds the final OpenAI API request internally. | Needs a Codex model-request tracing event or debug API. |
|
|
|
|
## Native permissions and MCP elicitations
|
|
|
|
For `PermissionRequest`, OpenClaw only returns explicit allow or deny decisions
|
|
when policy decides. A no-decision result is not an allow. Codex treats it as no
|
|
hook decision and falls through to its own guardian or user approval path.
|
|
|
|
Codex app-server approval modes omit this native hook by default. This behavior
|
|
applies when `permission_request` is explicitly included in
|
|
`nativeHookRelay.events` or a compatibility runtime installs it.
|
|
|
|
When an operator chooses `allow-always` for a Codex native permission request,
|
|
OpenClaw remembers that exact provider/session/tool input/cwd fingerprint for a
|
|
bounded session window. The remembered decision is intentionally exact-match
|
|
only: a changed command, arguments, tool payload, or cwd creates a fresh
|
|
approval.
|
|
|
|
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 fail closed.
|
|
|
|
For the general plugin approval flow that carries these prompts, see
|
|
[Plugin permission requests](/plugins/plugin-permission-requests).
|
|
|
|
## Queue steering
|
|
|
|
Active-run queue steering maps onto Codex app-server `turn/steer`. With the
|
|
default `messages.queue.mode: "steer"`, OpenClaw batches steer-mode chat
|
|
messages for the configured quiet window and sends them as one `turn/steer`
|
|
request in arrival order.
|
|
|
|
Codex review and manual compaction turns can reject same-turn steering. In that
|
|
case, OpenClaw waits for the active run to finish before starting the prompt.
|
|
Use `/queue followup` or `/queue collect` when messages should queue by default
|
|
instead of steering. See [Steering queue](/concepts/queue-steering).
|
|
|
|
## Codex feedback upload
|
|
|
|
When `/diagnostics [note]` is approved for a session using the native Codex
|
|
harness, OpenClaw also calls Codex app-server `feedback/upload` for relevant
|
|
Codex threads. The upload asks app-server to include logs for each listed thread
|
|
and spawned Codex subthreads when available.
|
|
|
|
The upload goes through Codex's normal feedback path to OpenAI servers. If Codex
|
|
feedback is disabled in that app-server, the command returns the app-server
|
|
error. The completed diagnostics reply lists the channels, OpenClaw session ids,
|
|
Codex thread ids, and local `codex resume <thread-id>` commands for the threads
|
|
that were sent.
|
|
|
|
If you deny or ignore the approval, OpenClaw does not print those Codex ids and
|
|
does not send Codex feedback. The upload does not replace the local Gateway
|
|
diagnostics export. See [Diagnostics export](/gateway/diagnostics) for the
|
|
approval, privacy, local bundle, and group-chat behavior.
|
|
|
|
Use `/codex diagnostics [note]` only when you specifically want the Codex
|
|
feedback upload for the currently attached thread without the full Gateway
|
|
diagnostics bundle.
|
|
|
|
## Compaction and transcript mirror
|
|
|
|
When the selected model uses the Codex harness, native thread compaction belongs
|
|
to Codex app-server. OpenClaw does not run preflight compaction for Codex turns,
|
|
does not replace Codex compaction with context-engine compaction, and does not
|
|
fall back to OpenClaw or public OpenAI summarization when native Codex
|
|
compaction cannot be started. OpenClaw keeps a transcript mirror for channel
|
|
history, search, `/new`, `/reset`, and future model or harness switching.
|
|
|
|
Explicit compaction requests, such as `/compact` or a plugin-requested manual
|
|
compact operation, start native Codex compaction with `thread/compact/start`.
|
|
OpenClaw returns after starting that native operation. It does not wait for
|
|
completion, impose a separate OpenClaw timeout, restart the shared Codex
|
|
app-server, or record the operation as an OpenClaw-completed compaction.
|
|
|
|
When a context engine requests Codex thread-bootstrap projection, OpenClaw
|
|
projects tool-call names and ids, input shapes, and redacted tool-result content
|
|
into the fresh Codex thread. It does not copy raw tool-call argument values into
|
|
that projection.
|
|
|
|
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 explicit native compaction start signals when it requests compaction. It
|
|
does not expose a human-readable compaction summary or an auditable list of
|
|
which entries Codex kept after compaction.
|
|
|
|
Because Codex owns the canonical native thread, `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 and delivery
|
|
|
|
OpenClaw continues to own media delivery and media provider selection. Image,
|
|
video, music, PDF, TTS, and media understanding use matching provider/model
|
|
settings such as `agents.defaults.imageGenerationModel`, `videoGenerationModel`,
|
|
`pdfModel`, and `messages.tts`.
|
|
|
|
Text, images, video, music, TTS, approvals, and messaging-tool output continue
|
|
through the normal OpenClaw delivery path. Media generation does not require the legacy runtime.
|
|
When Codex emits a native image-generation item with a `savedPath`, OpenClaw
|
|
forwards that exact file through the normal reply-media path even if the Codex
|
|
turn has no assistant text.
|
|
|
|
## Related
|
|
|
|
- [Codex harness](/plugins/codex-harness)
|
|
- [Codex harness reference](/plugins/codex-harness-reference)
|
|
- [Native Codex plugins](/plugins/codex-native-plugins)
|
|
- [Plugin hooks](/plugins/hooks)
|
|
- [Agent harness plugins](/plugins/sdk-agent-harness)
|
|
- [Diagnostics export](/gateway/diagnostics)
|
|
- [Trajectory export](/tools/trajectory)
|