diff --git a/crates/axe-node/src/dispatch.rs b/crates/axe-node/src/dispatch.rs index b679fad..1202cee 100644 --- a/crates/axe-node/src/dispatch.rs +++ b/crates/axe-node/src/dispatch.rs @@ -25,7 +25,7 @@ use crate::runtime_config::{self, RuntimeConfig}; mod bots; mod pre_check; pub mod services; -pub use bots::{splice_bot_args, voice_wakes, write_bot_agent}; +pub use bots::{splice_bot_args, voice_wakes, write_bot_agent, BOT_AGENT_TOOLS}; const TICK: Duration = Duration::from_secs(2); /// Longest gap between admission reports while no new sample was taken. diff --git a/crates/axe-node/src/dispatch/bots.rs b/crates/axe-node/src/dispatch/bots.rs index 1038383..0edd099 100644 --- a/crates/axe-node/src/dispatch/bots.rs +++ b/crates/axe-node/src/dispatch/bots.rs @@ -97,11 +97,35 @@ pub fn transcribe_voices( .collect() } +/// The tools a bot's Antigravity agent may use. An agent file without +/// `tools` gets none of the shell or file tools, so a bot could not run +/// `axe`. Every name is one agy's `init.tools` reports +/// (`crates/axe/tests/fixtures/antigravity/antigravity-run.jsonl`): an +/// unmapped name may hang the process +/// (https://antigravity.google/docs/subagents/). +pub const BOT_AGENT_TOOLS: &[&str] = &[ + "run_command", + "command_status", + "view_file", + "write_to_file", + "replace_file_content", + "grep_search", + "find_by_name", + "list_dir", + "search_web", + "read_url_content", +]; + /// Writes bot `bot`'s system prompt as custom agent `name` at `path` -/// (https://antigravity.google/docs/cli/commands/agents/: YAML `name` and -/// `description`, then the prompt), when it changed. +/// (https://antigravity.google/docs/cli/commands/agents/: YAML `name`, +/// `description` and `tools`, then the prompt), when it changed. pub fn write_bot_agent(path: &Path, name: &str, bot: &str, system: &str) -> Result<()> { - let text = format!("---\nname: {name}\ndescription: axe bot {bot}\n---\n\n{system}"); + let tools: String = BOT_AGENT_TOOLS + .iter() + .map(|t| format!(" - {t}\n")) + .collect(); + let text = + format!("---\nname: {name}\ndescription: axe bot {bot}\ntools:\n{tools}---\n\n{system}"); if std::fs::read_to_string(path).ok().as_deref() == Some(text.as_str()) { return Ok(()); } diff --git a/crates/axe/tests/dispatch.rs b/crates/axe/tests/dispatch.rs index b06f04c..51281d3 100644 --- a/crates/axe/tests/dispatch.rs +++ b/crates/axe/tests/dispatch.rs @@ -249,8 +249,8 @@ fn parses_antigravity_conversation_id() { } /// A bot on Antigravity gets its system prompt as a custom agent file -/// (https://antigravity.google/docs/cli/commands/agents/), rewritten only -/// when it changed. +/// (https://antigravity.google/docs/cli/commands/agents/) with the shell and +/// file tools, rewritten only when it changed. #[test] fn a_bot_system_prompt_is_an_antigravity_agent_file() { let d = tempfile::tempdir().unwrap(); @@ -258,8 +258,21 @@ fn a_bot_system_prompt_is_an_antigravity_agent_file() { axe::dispatch::write_bot_agent(&path, "axe-os", "os", "You are os.\n").unwrap(); assert_eq!( std::fs::read_to_string(&path).unwrap(), - "---\nname: axe-os\ndescription: axe bot os\n---\n\nYou are os.\n" + "---\nname: axe-os\ndescription: axe bot os\ntools:\n - run_command\n - command_status\n \ + - view_file\n - write_to_file\n - replace_file_content\n - grep_search\n \ + - find_by_name\n - list_dir\n - search_web\n - read_url_content\n---\n\nYou are os.\n" ); + // Every tool is one agy reports; an unmapped name may hang it. + let init = std::fs::read_to_string( + std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/antigravity/antigravity-run.jsonl"), + ) + .unwrap(); + let init: serde_json::Value = serde_json::from_str(init.lines().next().unwrap()).unwrap(); + let reported = init["init"]["tools"].as_array().unwrap(); + for t in axe::dispatch::BOT_AGENT_TOOLS { + assert!(reported.iter().any(|r| r == t), "{t} not in init.tools"); + } let before = std::fs::metadata(&path).unwrap().modified().unwrap(); axe::dispatch::write_bot_agent(&path, "axe-os", "os", "You are os.\n").unwrap(); assert_eq!(