feat(studio): add structured-output prefill generation - #393
Merged
Conversation
Add a prefillStyle toggle to functionPrefill blocks. When set to 'structured', the block emits a strict JSON schema (response_format on the OpenAI wire, responseMimeType/responseSchema on native Gemini) instead of a synthetic tool_call. Gemini 3.8 rejects the legacy tool-call prefill with a missing thought_signature; structured output carries no such requirement, so the prefill keeps working. Default stays 'tool' — nothing changes unless a preset opts in.
Add a 'two-pass' prefill style. Instead of a synthetic tool call or a JSON response schema, the final generator runs twice: a quiet first pass produces the internal <thinking> block, then a second pass writes the visible reply seeded by that block. The reasoning is surfaced via AgentRunResult.reasoning. Survives Gemini 3.8's thought_signature requirement without tool_calls or a fragile schema.
The quiet thinking pass ran with isFinalResponse:false, which resolves the pre-gen controller model and its reasoning settings instead of the final model. Run it with isFinalResponse:true so both passes hit the final model + final reasoning config.
…plies The two-pass generator runs its final pass with stream=false, so the incoming <audit> reasoning block was never parsed out of the reply text and the model's second reasoning block leaked into content. Route the full non-streaming response through StreamAccumulator and preserve both reasoning blocks on the result.
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
Verification
flutter analyze --no-fatal-infos --no-fatal-warnings(no errors; 9 pre-existing warnings/info)flutter test --reporter expanded: 3840 passed, 3 failed in 4m52stest/chat_input_bar_test.dartintroduced by upstream feat(chat): attach pasted images, up to four per message #389 (find.byType(Image)finds no thumbnail)