feat(streaming): surface native web-search activity per chunk#290
Merged
Conversation
Add a live tool_activity signal on TextChunk so consumers can render web-search progress while it happens, instead of only seeing the final grounding on the output. - types: ToolActivity model + ToolActivityStatus (started/completed) - TextChunk gains tool_activity; base Stream._parse_chunk parses and threads it like reasoning, and keeps activity-only chunks - OpenResponses (OpenAI + xAI): web_search_call.in_progress -> started, .completed -> completed - Anthropic: server_tool_use(web_search) -> started, web_search_tool_result -> completed Streaming-only by design: final results already live on TextOutput.grounding. Gemini has no in-stream signal (terminal-only).
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
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.
Adds a per-chunk
tool_activitysignal so consumers can render native web-search progress while it happens, instead of only seeing the finalGroundingon the output. Mirrors exactly howreasoningis threaded ontoTextChunk(base stub + per-provider overrides + kwargs threading).What
types.py:ToolActivity(BaseModel){tool_name, status}+ToolActivityStatus(StrEnum){started, completed}.TextChunkgainstool_activity: ToolActivity | None.Stream._parse_chunkparses + threads it, keeping activity-only chunks (added to the all-None guard).response.web_search_call.in_progress→ started,.completed→ completed.server_tool_use(web_search) → started,web_search_tool_result→ completed.Streaming-only by design — final results already live on
TextOutput.grounding, so no output aggregation.Scope / excluded (with reason)
$web_searchis a client round-trip, DeepSeek/Mistral have no native API search, Groq's streaming emission is undocumented, Perplexity-reasoning is bespoke. Per-provider follow-ups if needed.Note
Touches streaming/typing semantics — flagging per
CONTRIBUTING.md(maintainer approval).Verification
ruff+ruff format+mypyclean; full unit suite passes with coverage ≥80% (pre-push hook). No dedicated tests added — the new parsers follow the existingreasoning_parse_chunk_*pattern.