Skip to content

Commit 2b28f6d

Browse files
Copilotyiwang
andcommitted
Add test and update documentation for heartbeat tool factory
Co-authored-by: yiwang <142937+yiwang@users.noreply.github.com>
1 parent 7922923 commit 2b28f6d

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ Mobile crate uses `default-features = false, features = ["embeddings-openai"]`
9494

9595
**Tool safety split:** `Agent::new()` creates safe tools only (memory_search, memory_get, web_fetch, web_search). CLI injects dangerous tools (bash, read_file, write_file, edit_file) via `agent.extend_tools(create_cli_tools())`. Server agents intentionally only get safe tools.
9696

97+
**Heartbeat tool injection:** `HeartbeatRunner` in core accepts an optional `ToolFactory` callback to extend the agent with additional tools. CLI daemon provides `create_cli_tools` factory so heartbeat can perform file operations and execute commands. Without the factory, heartbeat runs with safe tools only.
98+
9799
**Custom tool sets:** `Agent::new_with_tools()` replaces all tools — used by Gen mode for its own Bevy tools (spawn_entity, modify_entity, etc.).
98100

99101
**Thread safety:** Agent is not `Send+Sync` due to SQLite. Use `AgentHandle` (`Arc<tokio::sync::Mutex<Agent>>`) for mobile/server. HTTP handler uses `spawn_blocking`.

crates/core/src/heartbeat/runner.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,4 +435,17 @@ mod tests {
435435
assert!(noon >= start && noon <= end);
436436
assert!(!(midnight >= start && midnight <= end));
437437
}
438+
439+
#[test]
440+
fn test_tool_factory_type_signature() {
441+
// Verify that the ToolFactory type can be constructed with a closure
442+
// that matches create_cli_tools signature
443+
let _factory: ToolFactory = Box::new(|_config: &Config| {
444+
// Simulate returning CLI tools
445+
Ok(Vec::new())
446+
});
447+
448+
// This test just verifies the type signature compiles correctly
449+
// Actual tool creation is tested in integration tests
450+
}
438451
}

0 commit comments

Comments
 (0)