fix: keep the system prompt identical across plain and guided turns - #29
Merged
Merged
Conversation
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.
meorphis-anthropic
approved these changes
Sep 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Keeps
systemidentical 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.formatis set, the API shows the model the schema itself.includeSchemaInPromptno longer changes the request, for the same reason.Test plan
RequestBuilderTestscase: guided and plain requests over one transcript send the same system, tools, and messages.claude-opus-5andclaude-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.xcodebuildon 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-backedAppAttestStoreTests, which skip by design under this runner.