Skip to content
Merged
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
2 changes: 1 addition & 1 deletion crates/axe-node/src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
30 changes: 27 additions & 3 deletions crates/axe-node/src/dispatch/bots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
}
Expand Down
19 changes: 16 additions & 3 deletions crates/axe/tests/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,17 +249,30 @@ 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();
let path = d.path().join(".gemini/config/agents/axe-os/agent.md");
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!(
Expand Down
Loading