Skip to content

Add AgentEvolution haystack ServiceType (Phase 2) #728

@AlexMikhalev

Description

@AlexMikhalev

Summary

Add AgentEvolution as a new ServiceType in the haystack architecture, enabling agents to search their prior lessons and memories as part of domain knowledge retrieval.

Approach

  • Add AgentEvolution variant to ServiceType enum in crates/terraphim_config/src/lib.rs
  • Implement IndexMiddleware that searches persisted LessonsState and MemoryState, returns matching entries as Document
  • Add match arm in search_haystacks() for the new service type
  • Add knowledge_haystacks and max_knowledge_items to AgentDefinition config
  • Extend spawn_agent() to search haystacks with task as needle, prepend results to prompt

TOML Config Example

[[agents]]
name = "product-development"
max_knowledge_items = 5

[[agents.knowledge_haystacks]]
location = "product-development"
service = "AgentEvolution"

[[agents.knowledge_haystacks]]
location = "~/.config/terraphim/kg/projects/terraphim-ai/"
service = "Ripgrep"

Critical Files

  • crates/terraphim_config/src/lib.rs:273 -- ServiceType enum
  • New: crates/terraphim_middleware/src/haystack/agent_evolution.rs -- IndexMiddleware impl
  • crates/terraphim_middleware/src/indexer/mod.rs -- search_haystacks() match arm
  • crates/terraphim_orchestrator/src/config.rs -- AgentDefinition fields
  • crates/terraphim_orchestrator/src/lib.rs -- spawn_agent() enrichment

Acceptance Criteria

  • Agent with configured knowledge_haystacks receives prior lessons in prompt
  • Empty haystack returns gracefully
  • TOML config parses correctly
  • cargo test --workspace passes

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions