Skip to content

feat(orchestration): Phase 2 — LLM Planner (goal decomposition) #1237

@bug-ops

Description

@bug-ops

Parent: #1235
Blocked by: #1236

Summary

Implement LLM-based task decomposition — converts a user goal into a validated TaskGraph.

Branch: feat/m33/orchestration-planner

Deliverables

New files

  • crates/zeph-core/src/orchestration/planner.rsPlanner trait + LlmPlanner impl

Details

  • Prompt template with JSON schema and agent catalog injection
  • String-based task_id in LLM output, parsed to internal TaskId(u32) indices
  • JSON response parsing with retry-on-malformed (single retry)
  • Validation of planner output via dag::validate
  • max_tasks enforcement (reject if LLM exceeds limit)
  • planner_model config: use configured model or fall back to agent's primary model
  • planner_max_tokens config for response budget

Planner prompt design

Structured prompt includes:

  1. Available agent catalog (name + description + tools)
  2. JSON schema for output format
  3. Instructions: prefer fewer/larger tasks, use string task_ids, declare dependencies

Tests (~15)

  • Parse valid JSON with string task_ids into TaskGraph
  • Reject JSON with cycles
  • Reject JSON with invalid agent hints (warn but proceed with None)
  • Reject JSON exceeding max_tasks
  • Handle malformed JSON (non-JSON LLM response)
  • Handle integer-based IDs (detect and reject with clear error)
  • Empty goal handling
  • Agent catalog formatting (correct prompt injection)
  • Single-task goal produces single-node graph

Dependencies

Blocked by: Phase 1 (#1236)
Can run in parallel with: Phase 3 (#1238)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestorchestrationTask orchestration / DAG scheduling

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions