Repository navigation
Description
Overview
The system prompt currently injects the full list of entity types (all user-defined schemas, their fields, enum values, etc.) into every agent turn via dynamic_context. At small scale this works, but at scale — 100 custom schemas — this could be 5–10k tokens injected every turn, bloating the context window and consuming the token budget reserved for conversation history.
Problem Statement
- Context window bloat at scale — every turn pays the full schema list cost regardless of whether types are relevant to the current message
- Architectural incoherence — injecting all types upfront makes
search_skillsoptional when it should be load-bearing. The model can resolvenode_typevalues and field names from the system prompt without ever callingsearch_skills, making the skill routing layer redundant search_skillsis designed to be the on-demand discovery mechanism for workspace-specific knowledge. With eager injection, that role is already filled before inference begins.
Proposed Solution
Remove entity type injection from the system prompt. Instead, search_skills returns the matched skill plus the relevant type metadata for the current intent — field names, valid enum values, the correct node_type ID. The model gets exactly the schema context it needs, scoped to the current intent, rather than the entire schema dictionary on every turn.
Acceptance Criteria
-
build_workspace_context/format_for_promptno longer injects entity type list into the system prompt -
search_skillsresponse includes the matched skill's associated schema metadata (type ID, fields, enum values) sufficient for the model to construct correctcreate_node/search_nodes/update_nodecalls - Agent produces correct
node_typevalues on create/update calls by reading fromsearch_skillsresponse rather than system prompt - Context window usage per turn decreases proportionally to the number of registered schemas
- Existing agent behavior is preserved for conversational turns (no regression on turns that don't need schema context)
-
PromptAssemblerupdated to omit entity type block - Benchmark harness (
packages/agent/tests/search_skills_latency.rs) updated: scenarios use user-defined type prompts (e.g. "show me overdue invoices"), assertsearch_skillswas called (hard failure, not WARN), andBenchToolExecutorreturns realistic type metadata in skill match responses - Benchmark rerun on the updated architecture and results committed to
nodespace-docs/development/benchmarks/ - Code passes
bun run quality:fix - Tests pass (
bun run test:all)
Technical Specifications
Reference Files
packages/agent/src/acp/context_assembly.rs— buildsdynamic_contextstring injected into sessionpackages/agent/src/prompt_assembler.rs—PromptAssemblerassembles system prompt including workspace contextpackages/agent/src/local_agent/prompt_templates.rs—fallback_system_prompttakesdynamic_contextparampackages/agent/src/local_agent/agent_loop.rs— passessession.dynamic_contextinto prompt assembly each turnpackages/agent/src/local_agent/tools.rs—exec_search_skills— needs to return type metadata alongside skill matchpackages/core/src/ops/skill_ops.rs—find_skills/FindSkillsOutput— return shape needs schema metadatapackages/agent/tests/search_skills_latency.rs— benchmark harness to update
Implementation Details
The search_skills response shape needs to be extended. Currently returns { query, matches: [{ name, confidence, description, tools }] }. Needs to include per-match schema metadata: the type IDs and field definitions associated with each skill's tool_whitelist scope.
Benchmark scenario prompts should reference user-defined types the model cannot resolve without search_skills — e.g. "show me overdue invoices", "find campaigns in draft status", "create a new sprint for Q3". The BenchToolExecutor should return a search_skills response that includes type metadata (field names, enum values, correct node_type ID), and each scenario should assert search_skills_calls > 0 as a hard failure rather than a warning.
Non-Goals
- Changing skill definitions or the skill pipeline's semantic search implementation
- Removing workspace context entirely — collections, playbooks, and other non-schema context may still be injected
- Optimizing inference engine internals
Related Issues
- Replace pre-LLM skill routing with LLM-orchestrated skill search #1130 (introduced
search_skillsas LLM-orchestrated routing) - Measure search_skills end-to-end latency on local 7B model #1152 (latency benchmark that surfaced the architectural incoherence)
Activity
malibio commentedon May 31, 2026
Frontend baseline: 132 files, 3836 tests passed
Address review: polish constants, budget guards, log message, and com…
Semantic retrieval for workspace_context: cover implicit type referen…
Remove entity type injection from system prompt in favor of on-demand…
Semantic retrieval for workspace_context: cover implicit type referen…