Repository navigation
Stream the buddy agent turn live from the AI service - #219
Merged
Merged
Conversation
- Turn the agent loop into a generator that streams reasoning, tokens and search announcements per hop - Add POST /onboarding/buddy/agent/stream; the sync endpoint drains the same generator - Hold back text that a filter override could replace, and join hop texts with a blank line
- Add reasoning and reasoning_details to the buddy agent wire message and map them both ways - Fix the resume hop after a backend tool, which a thinking-enabled provider rejected with a 400 - Replace the test that pinned reasoning out of messages with carry and resume tests
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 summary
Streams the agentic buddy turn live from the AI service and carries the model's reasoning through backend tool round trips.
Streaming the agent turn
onboarding/buddy_agent.py: the agent loop is now the generatorstream_agent_turn. It yieldsAgentReasoningandAgentTokenfragments as the model produces them, anAgentToolUsebefore each local search (search_docs,grep) and finally theAgentTurnResult.run_agent_turnnow just runs that generator to the end and returns the result, so the sync behaviour stays the same.llm.chat_stream, and the forced final answer (when the step budget is used up) usesllm.streaminstead ofllm.generate. That means reasoning from the forced hop now shows up inreasoningtoo.NO_FILTERED_RESULTS_MESSAGE, the hop's text is held back. It goes out if the hop then searches, or the message replaces it if the hop turns out to be the answer, so the reader never sees an answer the filter message is about to replace.POST /onboarding/buddy/agent/stream(SSE). It takes the same request body as/onboarding/buddy/agentand emitsreasoning,token,tool_useand one closingresultevent that has the same fields asBuddyAgentResponse. If the model is unavailable or something fails mid-turn, the stream ends with anerrorevent.api/routes/buddy.py: the response building and the vocabulary mapping moved into shared helpers (_agent_response,_vocabulary) that both endpoints use.Reasoning through backend tool round trips
BuddyAgentMessageSchemahas two new optional fields,reasoningandreasoning_details, and_to_message/_from_messagemap them in both directions.Tests
tests/onboarding/test_buddy_agent_stream.pycovers event order, held text under a filter, the hop separator and the forced final answer.tests/api/test_buddy.pycovers the stream endpoint (events, result payload, error events) and checks that reasoning makes it through a backend tool round trip.Checks