MIRA Thalaplan: AgentMira Architecture

Overview

AgentMira is integrated into RAG pipelines (plan_rag_assistant_template and plan_rag_assistant_no_answer_template) in AgentPlanner.py. This document describes the current implementation and planned evolution.


Current Implementation

Status: ✅ Implemented

AgentMira runs as a single agent within the RAG pipeline with an internal LLM-driven loop:

# plan_rag_assistant_template (line 168)
agent_plan_rag_assistant_template.append(
    Goal(None, None, "Assistant-Mira", None, GoalTarget.AGENT, agent_mira, [])
)

# plan_rag_assistant_no_answer_template (line 188)
agent_plan_rag_assistant_no_answer_template.append(
    Goal(None, None, "Assistant-Mira", None, GoalTarget.AGENT, agent_mira, [-7])
)

Internal Loop Mechanism

  1. LLM Call: AgentMira invokes the LLM with user prompt + context
  2. Tool Decision: LLM decides whether to call MIRA MCP tools to query Innovator
  3. Dynamic Subgoal Injection: If tool invocation needed, AgentToolCaller subgoal is injected
  4. Tool Execution: MIRA MCP tools extract structured data from Innovator
  5. Result Integration: Tool results feed back as context for next LLM call
  6. Loop: Repeats until LLM decides task is complete or max iterations reached

MIRA MCP Tools: - MIRA_NodeSearch — Search for nodes in knowledge graph - MIRA_RelationshipQuery — Query relationships between nodes - MIRA_NodeProperties — Retrieve node properties - MIRA_PathQuery — Find paths between nodes - MIRA_Summarize — Generate summaries


Target Implementation

Status: 🚧 Planned

Replace the internal loop with a declarative plan structure: plan_mira. This eliminates dynamic subgoal injection in favor of explicit plan structure managed by Thalaplan.

plan_mira Structure

agent_plan_mira_template = []
agent_plan_mira_template.append(Goal(None, None, "AgentMiraIterator", None, GoalTarget.AGENT, agent_mira_iterator, []))
agent_plan_mira_template.append(Goal(None, None, "Consolidator", None, GoalTarget.CONSOLIDATOR, None, [-1]))

Chain of Goals: 1. AgentMiraIterator (NEW) — Orchestrates multi-step reasoning with tool calls 2. Consolidator — Merges results

Note: AgentMira remains in the RAG plan (current implementation), and plan_mira is invoked as a sub-plan from within AgentMira's internal loop.

AgentMiraIterator (New Agent)

Derives from: AgentToolPreparer

Replaces AgentMira's internal loop. Responsibilities: - Analyze initial request - Decide which tool calls are needed - Instantiate AgentToolCaller subgoals (delegated to Thalaplan) - Consolidate tool results - Perform follow-up analysis if needed

Key Difference: Subgoal injection is now declarative (via Thalaplan) rather than imperative (LLM-driven from within AgentMira).

Integration: AgentMira (in RAG plan) calls plan_mira as a sub-plan when tool invocation is needed.


Implementation Roadmap

Component Status Priority Notes
AgentMira (current) ✅ Done — Working internal loop
plan_mira template 📝 To Do High Add to AgentPlanner.init_agent_planner()
AgentMiraIterator 📝 To Do High New orchestrator agent
Integration 📝 To Do High Replace AgentMira in RAG plans with plan_mira

Files