Skip to content

The agent that grows with you

feat(codex_app_server): accept developer_instructions and send them on thread/start

Momentum965cf6dcddccc5
diff --git a/agent/transports/codex_app_server_session.py b/agent/transports/codex_app_server_session.py
index ede339a8008..5b24077350f 100644
--- a/agent/transports/codex_app_server_session.py
+++ b/agent/transports/codex_app_server_session.py
@@ -156,10 +156,16 @@ class CodexAppServerSession:
on_event: Optional[Callable[[dict], None]] = None,
request_routing: Optional[_ServerRequestRouting] = None,
client_factory: Optional[Callable[..., CodexAppServerClient]] = None,
+ developer_instructions: Optional[str] = None,
) -> None:
self._cwd = cwd or os.getcwd()
self._codex_bin = codex_bin
self._codex_home = codex_home
+ # Hermes' composed system prompt (SOUL.md, memory, channel overrides). Sent ONCE per thread as
+ # ``thread/start.developerInstructions``: codex keeps its own base instructions (tool guidance) and
+ # inserts this as the first developer message of every model request. ``baseInstructions`` would
+ # REPLACE codex's base and ``instructions`` is accepted but ignored (verified against codex 0.147).
+ self._developer_instructions = developer_instructions
self._permission_profile = permission_profile or _HERMES_TO_CODEX_PERMISSION_PROFILE.get(
os.environ.get("HERMES_TERMINAL_SECURITY_MODE", "auto"), "workspace-write"
)
@@ -187,7 +193,10 @@ class CodexAppServerSession:
self._client.initialize(client_name="hermes", client_title="Hermes Agent", client_version=_get_hermes_version())
# Permissions are NOT sent on thread/start: codex gates ``thread/start.permissions``
# behind experimentalApi + a matching ``[permissions]`` table in ~/.codex/config.toml.
- result = self._client.request("thread/start", {"cwd": self._cwd}, timeout=15)
+ params: dict[str, Any] = {"cwd": self._cwd}
+ if self._developer_instructions and self._developer_instructions.strip():
+ params["developerInstructions"] = self._developer_instructions
+ result = self._client.request("thread/start", params, timeout=15)
# Different codex versions serialize the id under thread.id / sessionId / threadId.
thread_obj = result.get("thread") or {}
thread_id = thread_obj.get("id") or thread_obj.get("sessionId") or result.get("sessionId") or result.get("threadId")