Skip to content
Open
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
11 changes: 10 additions & 1 deletion crates/forge_app/src/tool_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl<S: Services + EnvironmentInfra<Config = forge_config::ForgeConfig>> ToolReg
let agent_tools = self.agent_executor.agent_definitions().await?;

// Get agents for template rendering in Task tool description
let agents = self.services.get_agents().await?;
let mut agents = self.services.get_agents().await?;

// Check if current working directory is indexed
let environment = self.services.get_environment();
Expand All @@ -258,6 +258,15 @@ impl<S: Services + EnvironmentInfra<Config = forge_config::ForgeConfig>> ToolReg

// Build TemplateConfig from ForgeConfig for tool description templates
let config = self.services.get_config()?;

// Filter out research subagents from task tool description when disabled
if !config.research_subagent {
agents.retain(|agent| {
let id = agent.id.as_str();
id != "sage" && id != "agent"
});
}

let template_config = TemplateConfig {
max_read_size: config.max_read_lines as usize,
max_line_length: config.max_line_chars,
Expand Down
12 changes: 0 additions & 12 deletions crates/forge_repo/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ impl<F: FileInfoInfra + EnvironmentInfra<Config = ForgeConfig> + DirectoryReader

Ok(agent_defs
.into_iter()
.filter(|def| filter_agent(def, &config))
.map(|def| {
def.into_agent(
ProviderId::from(session.provider_id.clone()),
Expand All @@ -214,11 +213,9 @@ impl<F: FileInfoInfra + EnvironmentInfra<Config = ForgeConfig> + DirectoryReader
}

async fn get_agent_infos(&self) -> anyhow::Result<Vec<forge_domain::AgentInfo>> {
let config = self.infra.get_config()?;
let agent_defs = self.load_agents().await?;
Ok(agent_defs
.into_iter()
.filter(|def| filter_agent(def, &config))
.map(|def| forge_domain::AgentInfo {
id: def.id,
title: def.title,
Expand All @@ -228,15 +225,6 @@ impl<F: FileInfoInfra + EnvironmentInfra<Config = ForgeConfig> + DirectoryReader
}
}

/// Returns `false` for agents that are disabled by a feature flag in the
/// configuration, `true` for all others.
fn filter_agent(def: &AgentDefinition, config: &ForgeConfig) -> bool {
if def.id.as_str() == forge_domain::AgentId::SAGE.as_str() && !config.research_subagent {
return false;
}
true
}

#[cfg(test)]
mod tests {
use forge_domain::AgentId;
Expand Down
Loading