feat: real-time tool call streaming indicator with blinking UI

- Add ToolParsingHint enum (Detected/Active/Complete) for UI feedback
- New UiWriter methods: print_tool_streaming_hint(), print_tool_streaming_active()
- Refactor ConsoleUiWriter state to use atomics in ParsingHintState
- Add tool_call_streaming field to CompletionChunk for provider hints
- Anthropic provider sends streaming hints when tool name detected
- New streaming helpers: make_tool_streaming_hint(), make_tool_streaming_active()

Parser improvements:
- Add is_json_invalidated() to detect false positive tool patterns
- Fix tool result poisoning when file contents contain partial JSON
- Unescaped newlines in strings or prose after JSON invalidates detection

User sees ' ● tool_name |' immediately when tool call starts streaming,
with blinking indicator while args are received.
This commit is contained in:
Dhanji R. Prasanna
2026-01-15 12:11:44 +05:30
parent d68f059acf
commit 0ae1a13cdb
18 changed files with 271 additions and 42 deletions

View File

@@ -1959,6 +1959,17 @@ Skip if nothing new. Be brief."#;
);
}
// Handle tool call streaming hint (show UI indicator immediately)
if let Some(ref tool_name) = chunk.tool_call_streaming {
if tool_name.is_empty() {
// Empty string = "active" hint for blinking
self.ui_writer.print_tool_streaming_active();
} else {
// Non-empty = "detected" hint with tool name
self.ui_writer.print_tool_streaming_hint(tool_name);
}
}
// Store raw chunk for debugging (limit to first 20 and last 5)
if chunks_received < 20 || chunk.finished {
raw_chunks.push(format!(