Documentation
¶
Overview ¶
Command fakecodex is a test-only stand-in for `codex app-server` at Codex 0.156.1, the version pyrycode targets. It speaks the app-server's wire — line-delimited JSON-RPC on stdin/stdout with no `jsonrpc` field — and answers the subset of the protocol pyrycode drives:
initialize {codexHome, platformFamily, platformOs, userAgent}
initialized notification, accepted silently
thread/start a thread whose id the fake mints
thread/resume the thread whose id was given (excludeTurns accepted)
turn/start {turn}, then the turn streams turn/started, one
agent-message item (item/started,
item/agentMessage/delta, item/completed) and
turn/completed with status "completed"
turn/interrupt {}, and the named running turn ends with
turn/completed status "interrupted"
account/read a signed-in ChatGPT account, or {account: null,
requiresOpenaiAuth: true} when signed out
model/list the models in models.json, modelListPage per page
(or the request's limit), the cursor the decimal
offset of the next page
Any request other than initialize before initialize is refused, as the real server does. The fake exits 0 on stdin EOF. Field shapes follow the committed schema, internal/codexsup/codex_app_server_protocol.schemas.json.
Configuration is env-only:
CODEX_HOME echoed as initialize's codexHome. Default
$HOME/.codex, the real server's default.
FAKECODEX_VERSION the version reported in initialize's userAgent
and each thread's cliVersion. Default 0.156.1.
FAKECODEX_SIGNED_OUT non-empty: account/read reports no sign-in.
FAKECODEX_MODEL_LIST_FAIL non-empty: model/list answers an error.
FAKECODEX_TURN_LOG a file path: each turn/start's params are
appended to it as one line, before the response,
so a test can read the overrides a turn carried;
question markers also append the response they
received as a questionResponse line.
FAKECODEX_THREAD_LOG a file path: each thread/start and thread/resume
is appended to it as one line
{"method":<method>,"params":<params>}, before the
response, so a test can read the developer
instructions a thread was opened with.
Per-turn behaviour is selected by a marker anywhere in the text of a turn's input, so one process serves every kind of turn:
[fakecodex:approval] before the agent message, the turn starts a
commandExecution item and sends one
item/commandExecution/requestApproval server
request. After the client's response it sends
serverRequest/resolved and completes the item:
"accept" or "acceptForSession" completes it as run
(status "completed", exitCode 0), any other
decision as "declined".
[fakecodex:withdraw] like approval, but the fake sends
serverRequest/resolved at once, before any
answer, and completes the item as "declined". A
response the client sends later for that request
is appended to FAKECODEX_TURN_LOG as
{"lateResponse":<id>}.
[fakecodex:question] sends one requestUserInput batch with two
single-select questions. Its response is appended
to FAKECODEX_TURN_LOG as {"questionResponse":...}.
[fakecodex:question-withdraw] sends the same batch, then resolves it
before an answer. A late response is logged like
the approval withdrawal marker.
[fakecodex:hold] after turn/started the turn waits until
turn/interrupt names it, so a test has a running
turn to interrupt.
[fakecodex:usage] before the agent message, the turn sends one
thread/tokenUsage/updated with a context window,
so the turn's end reports the model it ran on.
A turn without a marker never sends a server request.