Skip to content

fix: keep the system prompt identical across plain and guided turns - #29

Merged
sophie-ant merged 1 commit into
mainfrom
sdownward/stable-system-prompt
Sep 8, 2026
Merged

sophie-ant merged 1 commit into
mainfrom
sdownward/stable-system-prompt

Conversation

@sophie-ant

@sophie-ant sophie-ant commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Keeps system identical across a session's plain and guided requests.

Guided generation used to append "Respond with a single JSON object matching the required schema." to system. So a session's guided and plain requests sent different system prompts, while they replayed the same earlier turns. The API can reject a replayed thinking block once the conversation before it has changed, and the system prompt is part of that conversation.

The hint is dropped rather than moved. Whenever output_config.format is set, the API shows the model the schema itself. includeSchemaInPrompt no longer changes the request, for the same reason.

Test plan

  • New RequestBuilderTests case: guided and plain requests over one transcript send the same system, tools, and messages.
  • Live, on claude-opus-5 and claude-fable-5: a plain turn, then a guided turn that replays the first turn's thinking with the system prompt unchanged. Both return schema-conforming JSON.
  • The full test suite at dac9f07, via xcodebuild on macOS 26.6 with Xcode 27.0 beta 6 (27A5252f) and the iOS 27.0 simulator: ** TEST SUCCEEDED **, 221 tests, 218 passed, 0 failed, 3 skipped. The 3 skips are the keychain-backed AppAttestStoreTests, which skip by design under this runner.

Guided generation used to append "Respond with a single JSON object
matching the required schema." to `system`. So a session's guided and
plain requests sent different system prompts, while they replayed the
same earlier turns. The API can reject a replayed thinking block once
the conversation before it has changed, and the system prompt is part
of that conversation.

The hint is dropped rather than moved. Whenever `output_config.format`
is set, the API shows the model the schema itself, so nothing is lost.
`system` is now exactly the session's instructions on every request.
`includeSchemaInPrompt` no longer changes the request, for the same
reason. A test pins that a guided request's system, tools, and messages
match the plain request over the same transcript.
@sophie-ant
sophie-ant merged commit 5fa5a8b into main Sep 8, 2026
1 check passed
@sophie-ant
sophie-ant deleted the sdownward/stable-system-prompt branch September 8, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants