Skip to main content

agent_engine/tools/subagent/
models.rs

1//! Read-only session worker catalog operation.
2use super::super::{Tool, ToolContext};
3use crate::{Result, RuntimeError};
4use serde_json::{json, Value};
5
6pub struct SubagentModelsTool;
7
8#[async_trait::async_trait]
9impl Tool for SubagentModelsTool {
10    fn origin(&self) -> crate::tools::ToolOrigin {
11        crate::tools::ToolOrigin::Builtin
12    }
13
14    fn name(&self) -> &str {
15        "subagent_models"
16    }
17    fn description(&self) -> &str {
18        "List this session's exact trusted worker model choices. Omit model on delegation to inherit the foreground identity."
19    }
20    fn parameters(&self) -> Value {
21        json!({"type": "object", "properties": {}, "additionalProperties": false})
22    }
23    async fn execute(&self, _params: Value, ctx: ToolContext) -> Result<String> {
24        let policy = ctx
25            .capabilities
26            .orchestration
27            .as_ref()
28            .ok_or_else(|| RuntimeError::Tool("delegation policy unavailable".into()))?;
29        Ok(json!({
30            "foreground_model": policy.foreground_model(),
31            "models": policy.effective_choices(),
32            "model_omission": "inherit_foreground"
33        })
34        .to_string())
35    }
36}