Open
Conversation
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.
Short Description
Fix conversational answer handling bugs + upgrade to Sonnet 4.6 with structured outputs and adaptive thinking in
workflow_chat,job_chat,global_chatto make structured outputs more consistent.Fixes #442 #310 #449
Implementation Details
Problem
Conversational answers (no generated code/YAML) were broken in both workflow_chat and job_chat:
response: "").changesSSE event was sent even whencode_editswas empty ([]), causing the "apply changes" button to appear with no code.The root cause for workflow_chat was the old prefill-based approach (
{"yaml": ") the model struggled to output an empty string as its first token. A bug insplit_format_yamlthen let backticks leak through: whenyaml.safe_loadthrew on bad content, the broadexceptcaught it but never resetoutput_yaml, so the raw string (e.g.,'```\n```') was returned asresponse_yaml.What changed
Model upgrade:
claude-sonnet-4-6(centrally inmodels.py).Structured outputs replace prefilling across all three chat services. Instead of prefilling the assistant message and hoping the model produces valid JSON, we now pass a JSON schema via
output_configthat guarantees schema-compliant responses through constrained decoding. This eliminates all JSON parsing failures, so we no longer have retries for these structural issues.Adaptive thinking (
thinking: {"type": "adaptive"}) added to all Sonnet API calls in workflow_chat, job_chat, and global_chat's planner. The effort level is lowered to "medium" in all services except the planner to account for simple conversation turns that need answers fast. This lets the model dynamically decide when to use extended thinking, improving quality on tasks like comprehensive code renames. Just switching from 4-5 to 4-6 caused tests involving multiple changes to the code to fail far more often than before, as if the new model was not being as thorough, but adaptive thinking solved this. This also means the model streams thinking statuses in the background, but I've blocked those from being shown in the front-end for now before I move onto streaming fixes because they can be unsettling ("the user just said hello instead of asking about a workflow...I think I'll answer with a brief greeting...") and they're a bit long in the front-end space currently allocated for status updates.Specific fixes:
split_format_yaml: Separated YAML parsing into its own innertry/exceptso bad yaml can never leak through to the response. Ifyaml.safe_loadfails,output_yamlis explicitly set to"".changesSSE event. Previously any non-empty yaml string triggered the event."") tonull, added a conversational example showing"yaml": nullelsetoelif code_edits:so thechangesevent only fires when there are actual edits. This avoids the "apply changes" button appearing in the front-end when there are no changes."}) from the text stream flush, since text is now the last field in the JSON.AI Usage
Please disclose how you've used AI in this work (it's cool, we just want to know!):
You can read more details in our Responsible AI Policy