Repository navigation
Closed
Description
Overview
Implement the AgentToolExecutor that exposes NodeSpace graph operations as tools the local agent can call. Each tool wraps a NodeService or NodeEmbeddingService method with JSON schema validation and result formatting optimized for the local model's context budget.
Can be developed against mock NodeService in parallel with the agent loop (#1005).
Acceptance Criteria
-
AgentToolExecutortrait from Shared types, traits, and interface contracts for agent subsystems #998 fully implemented - All 7 tools implemented with correct JSON Schema definitions
- Argument validation rejects invalid inputs with helpful error messages (model can self-correct)
- Results formatted concisely (token-efficient for 8k context budget)
- Long node bodies truncated to 500 chars with
[truncated]indicator - Node IDs always included in results for follow-up tool calls
- Error handling: missing node, invalid ID, search failures all return structured errors
- Never panics — all errors returned as
ToolResult { success: false } - Unit tests with mock NodeService for each tool
- Integration test: execute search_nodes against real NodeService with test data
- Code passes
bun run quality:fix
Technical Specifications
New Module
packages/desktop-app/src-tauri/src/local_agent/tools.rs
Tool Definitions
1. search_nodes
- Description: Search for nodes by keyword or structured query
- Params:
{ query: string, node_type?: string, limit?: integer (default 10) } - Returns: Array of node summaries (id, title, type, snippet)
2. search_semantic
- Description: Find nodes semantically related to a query
- Params:
{ query: string, limit?: integer (default 5), collection?: string } - Returns: Ranked results with similarity scores
3. get_node
- Description: Get full content of a node by ID
- Params:
{ id: string } - Returns: Complete node (title, body truncated to 2000 chars, properties, type)
4. create_node
- Description: Create a new node with content
- Params:
{ title: string, body?: string, node_type: string, properties?: object, parent_id?: string } - Returns: Created node ID
5. update_node
- Description: Update an existing node
- Params:
{ id: string, title?: string, body?: string, properties?: object } - Returns: Success confirmation
6. create_relationship
- Description: Create a relationship between two nodes
- Params:
{ from_id: string, to_id: string, relationship_type: string } - Returns: Success confirmation
7. get_related_nodes
- Description: Get all nodes related to a given node
- Params:
{ id: string, relationship_type?: string, direction?: "in" | "out" | "both" (default "both") } - Returns: Array of related nodes with relationship info
Argument Validation
- Validate incoming JSON against each tool's schema before executing
- Return structured error if validation fails:
ToolResult { success: false, output: "Error: 'query' is required for search_nodes. Expected: { query: string, limit?: number }" } - Model can use error message to self-correct on next iteration
Result Formatting
- Optimize for token efficiency (local model has 8k context budget)
- Node summaries:
[id:abc123] "Title" (type) — first 100 chars of body - Full nodes: include properties as
key: valuepairs, body truncated to 2000 chars - Search results: include match count, ranked list
- Always include node IDs so model can reference them in follow-up calls
Dependency Injection
GraphToolExecutorreceivesNodeServiceandNodeEmbeddingServicereferences- References obtained per-operation from
AppServices(survive database hot-swaps) - No service references stored long-term
Reference Files
packages/core/src/services/— NodeService APIpackages/core/src/services/embedding_service.rs— NodeEmbeddingService APIpackages/core/src/mcp/handlers/search.rs— existing search implementation patternspackages/core/src/mcp/handlers/tools.rs— existing tool definition patterns
Exports
GraphToolExecutorstruct implementingAgentToolExecutor
Dependencies
Related Issues
- ACP Integration and Local LLM Capability #997 (parent epic)
- Context assembly: build rich prompts from knowledge graph #1005 (local agent loop — consumes this)
Activity
malibio commentedon Apr 3, 2026
Baseline: Frontend tests fail in worktree due to missing .svelte-kit/tsconfig.json (pre-existing env issue). This is a Rust-only task — proceeding with cargo check/test baseline.
feat: agent tool executor with graph operation tools for local agent (c…
feat: agent tool executor with graph operation tools for local agent (c…
feat: agent tool executor with graph operation tools for local agent (c…