Propagate schema through the chain #1297
Open
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.
This is intended to close #1222.
However, I think this raises some questions regarding the correct/expected behavior, so I'm a bit stuck regarding how to test this.
Here is my understanding of the correct behavior: If both a schema and a tool(s) are provided, we will always have a chain of
When a structured output is desired, I have the following assumptions about the correct behavior:
The initial LLM call
The expected response is one or more tool calls, not a structured output (this is expected in a subsequent response after we send the tool call results back to the LLM). Therefore, I wonder should the schema be excluded from this initial request?
Even if we do include the schema in all requests, I think it will work just fine. At least, that is what I have observed so far with gpt-5. However, for explicit clarity, I wonder if it would be better not to send the schema with the first request.
Here are two examples to illustrate.
Send the schema with the initial and subsequent requests
Exclude the schema from the initial requests
As you can see, the final result is nearly the same. But if we include the schema in the first call, we are trusting the LLM to make the right decision: ignore the schema and simply respond with a tool call.