streaming tool call attempt 1

This commit is contained in:
Dhanji Prasanna
2025-10-13 20:25:12 +11:00
parent b43b693b60
commit 627fdcd9bf
8 changed files with 134 additions and 31 deletions

View File

@@ -1442,6 +1442,7 @@ The tool will execute immediately and you'll receive the result (success or erro
};
if !new_content.trim().is_empty() {
#[allow(unused_assignments)]
if !response_started {
self.ui_writer.print_agent_prompt();
response_started = true;
@@ -1968,7 +1969,23 @@ The tool will execute immediately and you'll receive the result (success or erro
let escaped_command = shell_escape_command(command_str);
let executor = CodeExecutor::new();
match executor.execute_code("bash", &escaped_command).await {
// Create a receiver for streaming output
struct ToolOutputReceiver<'a, W: UiWriter> {
ui_writer: &'a W,
}
impl<'a, W: UiWriter> g3_execution::OutputReceiver for ToolOutputReceiver<'a, W> {
fn on_output_line(&self, line: &str) {
self.ui_writer.update_tool_output_line(line);
}
}
let receiver = ToolOutputReceiver {
ui_writer: &self.ui_writer,
};
match executor.execute_bash_streaming(&escaped_command, &receiver).await {
Ok(result) => {
if result.success {
Ok(if result.stdout.is_empty() {

View File

@@ -245,32 +245,3 @@ fn test_concurrent_access() {
}
}
fn main() {
println!("Running TaskResult comprehensive tests...");
test_task_result_basic_functionality();
println!("✅ Basic functionality test passed");
test_extract_last_block_various_formats();
println!("✅ Extract last block test passed");
test_is_approved_detection();
println!("✅ Approval detection test passed");
test_context_window_preservation();
println!("✅ Context window preservation test passed");
test_coach_feedback_extraction_scenarios();
println!("✅ Coach feedback extraction test passed");
test_edge_cases_and_special_characters();
println!("✅ Edge cases test passed");
test_large_response_handling();
println!("✅ Large response handling test passed");
test_concurrent_access();
println!("✅ Concurrent access test passed");
println!("\n🎉 All TaskResult tests passed successfully!");
}

View File

@@ -26,6 +26,9 @@ pub trait UiWriter: Send + Sync {
/// Print tool output header
fn print_tool_output_header(&self);
/// Update the current tool output line (replaces previous line)
fn update_tool_output_line(&self, line: &str);
/// Print a tool output line
fn print_tool_output_line(&self, line: &str);
@@ -60,6 +63,7 @@ impl UiWriter for NullUiWriter {
fn print_tool_header(&self, _tool_name: &str) {}
fn print_tool_arg(&self, _key: &str, _value: &str) {}
fn print_tool_output_header(&self) {}
fn update_tool_output_line(&self, _line: &str) {}
fn print_tool_output_line(&self, _line: &str) {}
fn print_tool_output_summary(&self, _hidden_count: usize) {}
fn print_tool_timing(&self, _duration_str: &str) {}