Skip to content

Refine local agent system prompt for better tool usage and response quality - #1052

Merged
malibio merged 7 commits into
mainfrom
feature/issue-1040-ops-layer-agent-prompt
Apr 6, 2026
Merged

malibio merged 7 commits into
mainfrom
feature/issue-1040-ops-layer-agent-prompt

Conversation

@malibio

@malibio malibio commented Apr 5, 2026

Copy link
Copy Markdown
Collaborator

Closes #1040

malibio and others added 7 commits April 5, 2026 22:40
…1040)

Extract AI agent business logic from desktop-app into a dedicated
nodespace-agent crate. Desktop-app now contains only thin Tauri
command bindings.

- Create packages/agent/ with agent_types, local_agent/, acp/ modules
- Decouple GraphToolExecutor from AppServices (accepts Arc<NodeService> directly)
- Extract Tauri event constants to desktop-app/agent_events.rs
- Update all desktop-app imports to use nodespace_agent::
- Achieve target DAG: nlp-engine ← core ← agent ← desktop-app
- Update CLAUDE.md repository structure

Co-Authored-By: Claude <[email protected]>
…#1040)

- Create core::ops module with typed operations layer:
  - node_ops: create, get, update, delete, query with collection/OCC/lifecycle
  - search_ops: semantic search with collection/scope/lifecycle filtering
  - rel_ops: relationship CRUD
  - context_ops: workspace context assembly (schemas, collections, playbooks)
- Refactor MCP handlers to delegate to ops/ (handlers become thin JSON adapters)
- Rewrite local agent system prompt with dynamic workspace context
- Add response post-processing normalizer (URI fixing, status casing, JSON stripping)
- Refactor MCP initialize handler to use context_ops

Co-Authored-By: Claude <[email protected]>
…malizer (#1040)

- Replace direct NodeService calls in GraphToolExecutor with core::ops calls
  (create_node, update_node, search_nodes, search_semantic, relationships)
- Local agent now gets full orchestration: collection resolution, OCC auto-fetch,
  lifecycle management, search post-filtering (previously MCP-only)
- Integrate normalize_response() at all AgentTurnResult return points in agent_loop
- Remove unused node_summary function (ops layer handles formatting)

Co-Authored-By: Claude <[email protected]>
- Route exec_get_node JSON format through node_ops::get_node (single source of truth)
- Wire dynamic_context population in local_agent_new_session via context_ops
- Add set_session_context() to LocalAgentService
- Use OnceLock for regex compilation in response normalizer (avoid per-call recompilation)
- Fix similarity score field name mismatch (score → similarity)
- Remove unused node_full/node_summary functions
- Add Default derive to WorkspaceContext

Co-Authored-By: Claude <[email protected]>
…ons (#1040)

- Add CapturingMockEngine that records InferenceRequests for assertion
- Test: dynamic context appears in system prompt when set on session
- Test: response normalizer fixes URIs and status casing end-to-end
- Test: tool definitions are included in inference requests
- Test: full tool call → response → normalization round-trip

Co-Authored-By: Claude <[email protected]>
…1040)

- Add RecordingToolExecutor that captures tool calls with args for assertion
- Test: structured query ("what are my tasks?") calls search_nodes with node_type=task
- Test: semantic query ("anything about machine learning?") calls search_semantic
- Test: multi-turn session uses different tools per turn (search_nodes then search_semantic)
- Verifies tool selection, arg passing, result handling, and response normalization

Co-Authored-By: Claude <[email protected]>
…tent (#1040)

- Rename "Prompt & tool quality tests" to "Pipeline integration tests" with
  explanation that mock engine drives tool selection, not the model
- Add doc comment to RecordingToolExecutor explaining intentional schema
  duplication for test isolation

Co-Authored-By: Claude <[email protected]>
@malibio
malibio merged commit 23cb5f6 into main Apr 6, 2026
@malibio
malibio deleted the feature/issue-1040-ops-layer-agent-prompt branch April 6, 2026 07:50
malibio added a commit that referenced this pull request Jun 22, 2026
…uality (#1052)

* refactor: Create packages/agent/ crate and relocate local agent code (#1040)

Extract AI agent business logic from desktop-app into a dedicated
nodespace-agent crate. Desktop-app now contains only thin Tauri
command bindings.

- Create packages/agent/ with agent_types, local_agent/, acp/ modules
- Decouple GraphToolExecutor from AppServices (accepts Arc<NodeService> directly)
- Extract Tauri event constants to desktop-app/agent_events.rs
- Update all desktop-app imports to use nodespace_agent::
- Achieve target DAG: nlp-engine ← core ← agent ← desktop-app
- Update CLAUDE.md repository structure

Co-Authored-By: Claude <[email protected]>

* feat: Add shared ops/ layer, dynamic context, and response normalizer (#1040)

- Create core::ops module with typed operations layer:
  - node_ops: create, get, update, delete, query with collection/OCC/lifecycle
  - search_ops: semantic search with collection/scope/lifecycle filtering
  - rel_ops: relationship CRUD
  - context_ops: workspace context assembly (schemas, collections, playbooks)
- Refactor MCP handlers to delegate to ops/ (handlers become thin JSON adapters)
- Rewrite local agent system prompt with dynamic workspace context
- Add response post-processing normalizer (URI fixing, status casing, JSON stripping)
- Refactor MCP initialize handler to use context_ops

Co-Authored-By: Claude <[email protected]>

* feat: Wire local agent tools to ops/ layer and integrate response normalizer (#1040)

- Replace direct NodeService calls in GraphToolExecutor with core::ops calls
  (create_node, update_node, search_nodes, search_semantic, relationships)
- Local agent now gets full orchestration: collection resolution, OCC auto-fetch,
  lifecycle management, search post-filtering (previously MCP-only)
- Integrate normalize_response() at all AgentTurnResult return points in agent_loop
- Remove unused node_summary function (ops layer handles formatting)

Co-Authored-By: Claude <[email protected]>

* fix: Address PR review findings (#1040)

- Route exec_get_node JSON format through node_ops::get_node (single source of truth)
- Wire dynamic_context population in local_agent_new_session via context_ops
- Add set_session_context() to LocalAgentService
- Use OnceLock for regex compilation in response normalizer (avoid per-call recompilation)
- Fix similarity score field name mismatch (score → similarity)
- Remove unused node_full/node_summary functions
- Add Default derive to WorkspaceContext

Co-Authored-By: Claude <[email protected]>

* test: Add e2e tests for prompt quality, normalizer, and tool definitions (#1040)

- Add CapturingMockEngine that records InferenceRequests for assertion
- Test: dynamic context appears in system prompt when set on session
- Test: response normalizer fixes URIs and status casing end-to-end
- Test: tool definitions are included in inference requests
- Test: full tool call → response → normalization round-trip

Co-Authored-By: Claude <[email protected]>

* test: Add structured, semantic, and multi-turn tool call e2e tests (#1040)

- Add RecordingToolExecutor that captures tool calls with args for assertion
- Test: structured query ("what are my tasks?") calls search_nodes with node_type=task
- Test: semantic query ("anything about machine learning?") calls search_semantic
- Test: multi-turn session uses different tools per turn (search_nodes then search_semantic)
- Verifies tool selection, arg passing, result handling, and response normalization

Co-Authored-By: Claude <[email protected]>

* chore: Address re-review nits — rename test section, document mock intent (#1040)

- Rename "Prompt & tool quality tests" to "Pipeline integration tests" with
  explanation that mock engine drives tool selection, not the model
- Add doc comment to RecordingToolExecutor explaining intentional schema
  duplication for test isolation

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refine local agent system prompt for better tool usage and response quality

1 participant