instructions: str = Field(default=DEFAULT_INSTRUCTIONS)System prompt sent in the Responses-API instructions field.
instructions is a top-level field of the Responses API request — it
is not a chat message. The Codex backend rejects any request where this
field is missing or empty (400 Instructions are required) and
rejects any SystemMessage entry in the input list
(400 System messages are not allowed). To bridge those constraints
transparently, _ChatOpenAICodex resolves instructions per call with
this precedence (highest wins):
instructions= kwarg on invoke / stream.SystemMessage entries in the input
list — joined with "\n\n" and stripped from the input before
sending. Set the explicit kwarg in (1) to override.The Codex backend is stateless for this client (store=False is
forced), so instructions is sent on every request and can be changed
between calls — useful for switching persona / tooling mid-conversation:
model = _ChatOpenAICodex(
model="gpt-5.5",
instructions="You are a senior Python reviewer. Be terse.",
)
model.invoke("review this diff…")
model.invoke(
"now translate the review to French",
instructions="You are a translator.",
)
SystemMessage content that uses list-of-content-blocks form is
accepted only if every block is {"type": "text", ...}; any other
block type raises ValueError since it cannot be flattened into the
string-typed instructions field.