Repository navigation
Description
Overview
The local agent's prompt assembler owns agent guidance rules (search-first, schema creation, node reference format) as DB-seeded prompt nodes. Under ADR-032, the @nodespace/agent-tools TypeScript package will also need consistent guidance injected into per-agent context files (CLAUDE.md / AGENTS.md). Both paths must derive from a single authoritative source to prevent drift.
The MCP initialize handler (packages/core/src/mcp/handlers/initialize.rs) that previously held a parallel copy of these rules is being deleted as part of ADR-031.
Problem Statement
Two locations own overlapping guidance content today:
packages/agent/src/prompt_assembler.rs—seed_prompt_nodes()returns built-in prompt sections seeded to the DB on startup, used by the local Ollama agentpackages/agent/src/acp/context_assembly.rs— assembles context for agent sessions; after ADR-032 this writesCLAUDE.md/AGENTS.mdfiles and must embed the same rules
Rules that exist in both and can drift:
- Schema creation rules:
title_templatetokens must match fields array; do not addname/titlefields unless used in template - Search first guidance: always search before updating or fetching by ID; never use placeholder IDs
- Node reference format: bare
nodespace://URIs (no markdown links, no backticks)
Any change to these rules must currently be made in multiple places with no test ensuring they stay in sync.
Proposed Solution
Extract shared rules into a single authoritative source in packages/agent/src/agent_guidance.rs exporting const rule strings. Both prompt_assembler.rs and context_assembly.rs import from it.
// packages/agent/src/agent_guidance.rs
pub const SEARCH_FIRST_RULES: &str = "TOOL STRATEGY:\n- ALWAYS search first...";
pub const SCHEMA_CREATION_RULES: &str = "SCHEMA CREATION RULES:\n...";
pub const NODE_REFERENCE_FORMAT: &str = "NODE REFERENCES: ...";Acceptance Criteria
- Shared guidance rules (search-first, schema creation, node references) exist in exactly one place in the codebase
- Local agent (
PromptAssembler) derives guidance from that single source - Context file assembler (
context_assembly.rs) derives guidance from that single source - Changing a rule in one place automatically updates behavior for both the local agent and all PTY agent sessions
- All existing tests pass (
bun run test:all) - Code passes
bun run quality:fix
Technical Specifications
Files to Modify
packages/agent/src/agent_guidance.rs(NEW) — single source of truth for guidance constantspackages/agent/src/prompt_assembler.rs— replace inline rule strings with importspackages/agent/src/acp/context_assembly.rs— import shared rules when assembling context filespackages/agent/src/lib.rs— exposeagent_guidancemodule
Current overlapping content locations
| Rule | Prompt assembler location | Context assembly location |
|---|---|---|
| Schema creation | prompt_assembler.rs Tool Strategy Guide seed (priority 50) |
context_assembly.rs (to be added under ADR-032) |
| Search first | prompt_assembler.rs Tool Strategy Guide seed |
Same |
| Node references | prompt_assembler.rs Response Formatting Rules seed (priority 60) |
Same |
Dependencies
- Schema field rename with property data migration #1088 (schema field rename — schema creation guidance will need updating when implemented)
Related Issues
- Schema field rename with property data migration #1088 (schema field rename — guidance update required)
Activity
[-]Unify agent guidance rules into a single source for MCP and local agent[/-][+]Unify agent guidance rules into a single source for local agent and gRPC tool layer[/+]malibio commentedon May 17, 2026
Architecture update: MCP references removed
Updated to reflect ADR-031 and ADR-032:
packages/core/src/mcp/handlers/initialize.rs) is being deleted — its parallel copy of guidance rules disappears with itcontext_assembly.rs, which under ADR-032 writesCLAUDE.md/AGENTS.mdcontext files for PTY agent sessionsagent_guidance.rsmalibio commentedon May 17, 2026
Starting work on this issue in worktree-issue-1089-unify-agent-guidance.
Baseline test status (from worktree, before any changes):
src/tests/utils/marked-config.test.ts > Performance and reliability > should handle large text efficiently— performance threshold flake (661ms vs 500ms limit), unrelated to this issue.Address review feedback on #1089
Unify agent guidance into single source of truth (#1089) (#1129)
Delete ACP transport/MCP server; rework GraphContextAssembler to writ…
Unify agent guidance into single source of truth (#1089) (#1129)
Delete ACP transport/MCP server; rework GraphContextAssembler to writ…