Skip to content

Streaming bugs#466

Merged
josephjclark merged 5 commits intorelease/nextfrom
streaming-bugs
Apr 21, 2026
Merged

Streaming bugs#466
josephjclark merged 5 commits intorelease/nextfrom
streaming-bugs

Conversation

@hanna-paasivirta
Copy link
Copy Markdown
Contributor

@hanna-paasivirta hanna-paasivirta commented Apr 20, 2026

Short Description

Fixes streaming bugs introduced with the switch to structured outputs that led to job code/YAML not being streamed before the text answers.

Fixes #461

Implementation Details

EVENT:changes wasn't firing in workflow_chat

When we switched to structured outputs and dropped answer prefills, the buffered content became a fragment of an unclosed object like {"yaml": "...", — which always fails to parse, so send_changes was silently skipped and yaml/code only arrived in the final complete payload. Now, we strip the trailing comma + whitespace, append } to make it valid JSON, and extract the field by key. job_chat does this already (but this PR adjusts it slightly to clean up dead code and match the approach in the two services).

The field-boundary delimiter was too literal

The code matched the exact string '"text": "' / '"text_answer": "' with a hardcoded space. Anthropic's structured outputs emits JSON with inconsistent whitespace . workflow_chat happened to come back pretty-printed, but job_chat comes back compact ("text_answer":"). job_chat's delimiter never matched, so text never streamed at all and everything appeared at once. We've now replaced the literal match with regex r'"text"\s*:\s*"' so whitespace doesn't matter.

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to know!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

Copy link
Copy Markdown
Collaborator

@josephjclark josephjclark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great, thanks @hanna-paasivirta

@josephjclark josephjclark changed the base branch from main to release/next April 21, 2026 09:23
@josephjclark josephjclark merged commit a8b3c27 into release/next Apr 21, 2026
@josephjclark josephjclark deleted the streaming-bugs branch April 21, 2026 09:24
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.

Order of streamed artefacts doesn't seem right

2 participants