Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fusion-beta-orchestration.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add opt-in Fusion sidekick orchestration with typed lifecycle events, guarded delegation, lead review and fallback, usage accounting, and live UI phase updates.
29 changes: 23 additions & 6 deletions n00n-agent/src/agent/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use crate::cancel::{CancelMap, CancelToken, PreDispatchGate};
use crate::mcp::McpSession;
use crate::permissions::{PermissionAnswer, PermissionManager};
use crate::tools::{
ActiveTools, Deadline, FileReadTracker, LocalTools, ToolAudience, ToolContext, ToolFilter,
ToolRegistry,
ActiveTools, AdmissionError, Deadline, FileReadTracker, LocalTools, ToolAudience, ToolContext,
ToolFilter, ToolRegistry,
};
use crate::{
AgentConfig, AgentError, AgentEvent, AgentInput, AgentMode, EventSender, ExtractedCommand,
Expand Down Expand Up @@ -297,7 +297,6 @@ impl<'h> Agent<'h> {
self.mcp = mcp;
self
}

#[must_use]
pub fn with_dynamic_mcp_tools(mut self, allow: bool) -> Self {
self.allow_dynamic_mcp_tools = allow;
Expand Down Expand Up @@ -482,6 +481,26 @@ impl<'h> Agent<'h> {
}

async fn stream_response(&self, opts: RequestOptions) -> Result<StreamResponse, AgentError> {
let child_agent = self.audience.intersects(
ToolAudience::RESEARCH_SUB | ToolAudience::GENERAL_SUB | ToolAudience::WORKFLOW,
) && !self.audience.contains(ToolAudience::MAIN);
let _agent_admission = if child_agent {
Some(
self.registry
.admission()
.acquire_agent(&self.cancel)
.await
.map_err(|error| match error {
AdmissionError::Cancelled => AgentError::Cancelled,
AdmissionError::Timeout => AgentError::Api {
status: 503,
message: "tool admission timed out".into(),
},
})?,
)
} else {
None
};
let mut tools = self.tools.clone();
filter_provider_tools(&mut tools, &self.effective_tool_filter(), &self.mode);
let visible = self.fusion_delegate_visible(&tools);
Expand Down Expand Up @@ -871,6 +890,7 @@ impl<'h> Agent<'h> {
model: Arc::clone(&self.model),
event_tx: self.event_tx.clone(),
mode: Arc::clone(&self.mode),
session_id: self.session_id.clone(),
tool_use_id: None,
user_response_rx: self.user_response_rx.clone(),
loaded_instructions: self.loaded_instructions.clone(),
Expand Down Expand Up @@ -1597,7 +1617,6 @@ mod tests {
));
});
}

#[test]
fn history_replay_accepts_explicit_user_approval() {
smol::block_on(async {
Expand Down Expand Up @@ -1897,7 +1916,6 @@ mod tests {
Box::pin(async { Ok(Vec::new()) })
}
}

#[test]
fn estimate_message_tokens_counts_thinking_and_signature() {
let messages = vec![Message {
Expand Down Expand Up @@ -2097,7 +2115,6 @@ mod tests {
stop_reason: Some(StopReason::EndTurn),
}
}

fn thinking_response() -> StreamResponse {
StreamResponse {
message: Message {
Expand Down
Loading