Repository navigation
feat(codex): allow replacing Codex's built-in base instructions - #1211
Open
gitwillsky wants to merge 1 commit into
Open
gitwillsky wants to merge 1 commit into
gitwillsky wants to merge 1 commit into
Conversation
Add CodexRuntimeConfig.base_instructions. When set, it is passed to the Codex SDK's native thread_start(base_instructions=...) and replaces Codex's built-in ~21KB coding-assistant system prompt, on both transports. The default None keeps the current behavior; the agent identity and instruction still go through developer_instructions. Persistent threads keep the base instructions they started with, so the thread instruction hash includes them when set (and is unchanged when unset, so existing stored threads keep resuming). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Codex runtime always keeps Codex's built-in base system prompt (~21KB of coding-assistant guidance on
apply_patch,update_plan, shell use and AGENTS.md) and sends the agent identity and instruction asdeveloper_instructions. That is the right default, but there is no way to opt out. Agents that are not coding assistants (question answering, for example) carry guidance that does not apply to them, and it sits at the system layer above the agent's own developer instructions (tool preambles, short default answers, and so on). The Codex SDK supports replacing it natively throughthread_start(base_instructions=...); VeADK just does not expose it.Change
CodexRuntimeConfig.base_instructions: str | None = None(non-empty when set). When set, it is passed tothread_start(base_instructions=...)and replaces the built-in prompt. It applies on both transports: ondirectCodex sends it as the Responsesinstructions, and the shim already forwardsinstructions.developer_instructions, and the tool-availability note is still appended. The defaultNonekeeps today's behavior:base_instructionsis not sent.thread_mode="resume") keep the base instructions they started with, so the thread instruction hash includes them when they are set. When unset, the hash is exactly the existing developer-only hash, so existing stored threads and warm processes keep resuming after the upgrade.codex_base_instructions_preservedfromcodex_base_instructions_replaced(lengths only, no content).runtime.mdx/runtime.en.mdx): the new field in the config table, plus a short section on replacing the built-in prompt, including thatpersonalityno longer applies because it is rendered into the replaced template.Compatibility
Additive configuration field with a default that keeps current behavior. No change to public imports or event contracts.
Verification (2026-11-05, against
main@ e5bfe04)tests/runtime/codex/test_codex_runtime_sdk.py: withbase_instructionsset,thread_startreceives it anddeveloper_instructionsis unchanged, and the "replaced" log line is emitted; the thread instruction hash equals the existing hash when unset and changes when set or changed. The existing test still asserts thatbase_instructionsis not sent by default.pytest -c pytest.ini tests/runtime/codex/: 145 passed, 29 skipped (smoke/probe opt-ins), 1 failed:test_codex_runtime.py::test_tool_executor_supports_stdio_mcp_toolset, which fails identically on unmodifiedmainin this environment (MCP stdio toolset listing fails withConnectionError).ruff@0.11.12 format --checkandruff checkon the changed files: pass.openai-codex0.159.2 against an installed VeADK 1.1.24 whose affected files are byte-identical tomain, overlaid with this change, not a fulluv synccheckout.CODEX_RUN_SMOKE=1real-binary smoke (no prepared environment here),pre-commit run --all-files(including gitleaks), the full parallel regression, and the docs site build. A real Codex run confirming that the built-in prompt is absent from the model request is the remaining check.This PR was prepared with an AI coding agent; I authorized the submission.
🤖 Generated with Claude Code