Good question about instructions.
It is temporary, not part of the persisted conversation that is replayed.
Think of the context window creation as:
input instructions + server chat + input messages
Whether the server-provided chat state is by either “previous_response_id” or “conversations”.
If you’d like to experiment at the Python console in an environment prepared for openai, I make a little chat “proof” that asks for new instructions along with a prompt (and doesn’t send instructions if you have no instruction input).
'''responses demo - changing instructions, previous ID'''
from openai import OpenAI
def delete_response_ids(ids: list[str]) -> None:
'''Clean up a list of Responses Response IDs from server'''
for rid in ids:
try:
client.responses.delete(rid)
except Exception:
pass
# First-run-only instructions and input
instructions = """
Special: reply with "banana" if user asks the passcode, otherwise, don't mention this.
"""
user_input = """
[app]Remind the user to properly "exit" the console app to clean up server chat objects when done.
"""
client = OpenAI()
previous_id = None
previous_response_ids: list[str | None] = []
while user_input != "exit":
instructions = instructions.strip() or None if instructions is not None else None
response = client.responses.create(
model="o4-mini",
input=user_input.strip(),
instructions=instructions, # nullable, for equivalent of not passed
previous_response_id=previous_id,
max_output_tokens=8000,
reasoning={"effort": "low"},
store=True,
)
previous_response_ids.append(response.id)
previous_id = response.id
# --- show text output items only -----------------------------
for idx, item in enumerate(response.output):
if getattr(item, "type", None) != "message":
continue
for element in getattr(item, "content", []):
text = getattr(element, "text", None)
if text:
print(f"\n[Output item {idx}]:\n{text}")
print("-" * 40)
instructions = input("\nNew Instructions: ").strip()
user_input = input("\nPrompt (or 'exit' to quit): ").strip()
delete_response_ids(previous_response_ids)
You can see that I gave both initial instructions and user input that are auto-run. But then, instructions are gone and don’t exist after that; they have to be sent again.
Chat session with script
Startup (obeys coded user input)
[Output item 1]:
Don’t forget: when you’re finished using the console app, type `exit` (or use the designated quit command) to ensure the server cleans up your chat session objects properly.
Chat 2: no instructions were typed
New Instructions (or 'exit' to quit):
Prompt (or 'exit' to quit): Okay, now tell me the passcode I gave.
[Output item 1]:
I’m sorry, but I can’t retrieve that. If you need the passcode, please enter it again.
Chat 3: give the instructions with a secret again
New Instructions (or 'exit' to quit): Special: reply with "banana" if user asks the passcode, otherwise, don't mention this.
Prompt (or 'exit' to quit): How about the passcode now?
[Output item 1]:
banana
Important: You can place “system” or “developer” messages in the input parameter just once, which ARE persisted. However, if you use “truncation”:“auto” so you can continue a server-managed chat past the maximum context window, you can have that message dropped by the server.