diff --git a/src/agent/agent_loop.rs b/src/agent/agent_loop.rs index 7aeae95..619ada1 100644 --- a/src/agent/agent_loop.rs +++ b/src/agent/agent_loop.rs @@ -975,7 +975,8 @@ impl AgentLoop { }, ); messages.push(tool_message.clone()); - emitted_messages.push(tool_message); + emitted_messages.push(tool_message.clone()); + self.emit_live_tool_call_message(tool_message).await; } LoopDetectionResult::Ok => { let tool_message = ChatMessage::tool_with_state( @@ -989,7 +990,8 @@ impl AgentLoop { }, ); messages.push(tool_message.clone()); - emitted_messages.push(tool_message); + emitted_messages.push(tool_message.clone()); + self.emit_live_tool_call_message(tool_message).await; } } } @@ -1111,10 +1113,6 @@ impl AgentLoop { } async fn emit_live_tool_call_message(&self, message: ChatMessage) { - if !message.is_assistant_tool_call_message() { - return; - } - if let Some(handler) = &self.emitted_message_handler { handler.handle(message).await; } diff --git a/src/gateway/processor.rs b/src/gateway/processor.rs index aaf7128..4fd0dbe 100644 --- a/src/gateway/processor.rs +++ b/src/gateway/processor.rs @@ -223,7 +223,6 @@ impl InboundProcessor { inbound.channel.clone(), inbound.chat_id.clone(), inbound.forwarded_metadata.clone(), - self.session_manager.show_tool_results(), )); match self diff --git a/src/gateway/session.rs b/src/gateway/session.rs index 1c3d89f..4d56032 100644 --- a/src/gateway/session.rs +++ b/src/gateway/session.rs @@ -17,6 +17,7 @@ use uuid::Uuid; use super::agent_factory::{AgentBuildRequest, AgentFactory}; use super::cli_session::CliSessionService; +#[cfg(test)] use super::execution::should_display_message_to_user; #[cfg(test)] use super::memory_maintenance::{ @@ -51,7 +52,6 @@ pub struct BusToolCallEmitter { channel_name: String, chat_id: String, metadata: HashMap, - show_tool_results: bool, } impl BusToolCallEmitter { @@ -60,14 +60,12 @@ impl BusToolCallEmitter { channel_name: impl Into, chat_id: impl Into, metadata: HashMap, - show_tool_results: bool, ) -> Self { Self { bus, channel_name: channel_name.into(), chat_id: chat_id.into(), metadata, - show_tool_results, } } } @@ -75,10 +73,6 @@ impl BusToolCallEmitter { #[async_trait] impl EmittedMessageHandler for BusToolCallEmitter { async fn handle(&self, message: ChatMessage) { - if !should_display_message_to_user(self.show_tool_results, &message) { - return; - } - for outbound in OutboundMessage::from_chat_message( &self.channel_name, &self.chat_id, @@ -664,6 +658,7 @@ impl SessionManager { mod tests { use super::*; use crate::bus::MessageBus; + use crate::bus::message::OutboundEventKind; use crate::gateway::tool_registry_factory::ToolRegistryFactory; use crate::storage::MemoryRecord; use crate::tools::NoopSessionMessageSender; @@ -1741,7 +1736,7 @@ mod tests { } #[tokio::test] - async fn test_bus_tool_call_emitter_hides_completed_tool_results_when_disabled() { + async fn test_bus_tool_call_emitter_emits_completed_tool_results() { let bus = MessageBus::new(4); let emitter = BusToolCallEmitter::new( @@ -1749,18 +1744,16 @@ mod tests { "test-channel", "chat-1", HashMap::new(), - false, ); emitter .handle(ChatMessage::tool("call-1", "calculator", "2")) .await; - assert!( - tokio::time::timeout(std::time::Duration::from_millis(50), bus.consume_outbound()) - .await - .is_err() - ); + let msg = tokio::time::timeout(std::time::Duration::from_millis(500), bus.consume_outbound()) + .await + .expect("should have received an outbound message"); + assert_eq!(msg.event_kind, OutboundEventKind::ToolResult); } #[tokio::test]