Skip to main content
QitOS provides method templates — ready-made Agent + Critic pairs that implement well-known agentic reasoning patterns. Each template packages a specialized state, critic, and agent so you can apply the pattern without rewriting the control loop.

What is a method template?

A method template combines: The critic is the key: it evaluates each step and decides whether to retry (with an instruction patch), continue, or stop. The agent enriches prompts with pattern context (previous reflections, draft versions, critiques).

Self-Refine

The Self-Refine pattern (Madaan et al. 2023) iterates: generate → critique → refine until quality meets a threshold or max refinements are reached.

When to use it

  • Text generation tasks where quality matters more than speed
  • Summarization, translation, code generation with self-evaluation
  • Any task where iterative improvement reliably produces better output

Quick start

How it works

  1. Generate: The agent produces an initial draft.
  2. Critique: SelfRefineCritic evaluates the draft quality using heuristic scoring (longer drafts after more refinements score higher; very short drafts are penalized). In production, replace heuristics with an LLM-based scorer.
  3. Refine: If the score is below quality_threshold and refinements remain, the critic returns retry with an instruction_patch asking the agent to improve. The agent sees its previous draft and the critique in the next prompt.
  4. Accept: When the score meets the threshold or max_refinements is reached, the critic returns continue or stop.

SelfRefineCritic parameters

SelfRefineState fields

Customizing the quality scorer

The built-in critic uses heuristics. For production use, subclass and override evaluate():

Reflexion

The Reflexion pattern (Shinn et al. 2023) iterates: act → evaluate → reflect → retry with memory. On failure, the critic generates a verbal reflection stored in state and injected into future prompts.

When to use it

  • Debugging and error-correction tasks where the agent must learn from failures
  • Tasks where different strategies should be tried after failure
  • Multi-attempt problems (coding, reasoning) where reflections improve subsequent attempts

Quick start

How it works

  1. Act: The agent takes an action toward the task.
  2. Evaluate: ReflexionCritic checks for failures (errors, non-zero return codes, empty results).
  3. Reflect: On failure, the critic generates a verbal reflection from the error context and returns retry with the reflection as an instruction_patch. The reflection is stored in state.reflections.
  4. Retry with memory: The agent’s build_system_prompt() includes all previous reflections, so the LLM can avoid repeating the same mistakes.

ReflexionCritic parameters

ReflexionState fields

LATS

The LATS pattern (Zhou et al. 2023) applies Monte Carlo Tree Search to language agents: select → expand → evaluate → backpropagate. Failed trajectories generate reflections that guide future exploration away from similar mistakes.

When to use it

  • Tasks requiring systematic exploration of multiple solution paths
  • Logic puzzles, coding challenges, and multi-step reasoning
  • Problems where trying different strategies improves success

Quick start

How it works

  1. Simulate: The agent takes an action, producing a result.
  2. Evaluate: LATSCritic computes a reward from the result (errors → low reward, FINAL ANSWER → high reward).
  3. Reflect: Failed paths (reward < 0.3) generate reflections stored in state.reflections.
  4. Guide: On retry, the critic provides an instruction_patch that includes reflections and UCB1-style exploration guidance.
  5. Stop: When a path succeeds (reward ≥ success_threshold) or max_simulations is reached.

LATSCritic parameters

LATSState fields

MoA (Mixture-of-Agents)

The MoA pattern (Wang et al. 2024) runs multiple proposers independently and synthesizes their outputs: propose → aggregate. Diversity of proposals improves quality, even when individual proposers are weaker models.

When to use it

  • Tasks benefiting from diverse perspectives or creative responses
  • Analysis, evaluation, and synthesis problems
  • Quality improvement through ensemble reasoning

Quick start

How it works

  1. Collect: MoACritic checks if enough proposals have been gathered. If not, it returns retry with an instruction to gather more proposals.
  2. Aggregate: When all proposals are collected, the critic prompts for synthesis.
  3. Output: When synthesis is complete and meets the quality threshold, the critic returns stop.
For parallel proposer execution with actual multi-agent delegation, use qitos.kit.patterns.moa.build_moa_system().

MoACritic parameters

MoARecipeState fields

Magentic-One

The Magentic-One pattern (Furtado et al. 2024) uses an orchestrator with a dual-ledger architecture: plan → delegate → track progress → re-plan when stuck. The orchestrator maintains a Fact Bank and Task Ledger, delegates to specialist agents, and re-plans when progress stalls.

When to use it

  • Complex, multi-step tasks requiring coordination of different capabilities
  • Tasks where an orchestrator needs to adapt its plan based on intermediate results
  • Open-ended problems with research, coding, and analysis subtasks

Quick start

How it works

  1. Plan: The orchestrator creates a task ledger and gathers initial facts.
  2. Delegate: At each step, a subtask is assigned to a specialist.
  3. Track: ProgressCritic evaluates whether new facts have been gathered or tasks completed.
  4. Re-plan: If no progress is detected for max_stalls consecutive steps, the critic returns retry with re-planning guidance.
  5. Stop: When a FINAL ANSWER is provided, or when stall budget is exhausted.

ProgressCritic parameters

MagenticOneState fields

Scaffolding a new agent

Use the qit new CLI command to scaffold a new agent project from the built-in cookiecutter template:
The scaffolded project includes:
  • src/agent.py — Agent class with State, init_state, build_system_prompt, reduce
  • configs/default.yaml — Default model and step configuration
  • tests/test_agent.py — Basic smoke tests
  • snowl_compat.py — Snowl evaluation compatibility adapter
  • eval_config.yaml — Evaluation configuration

Building your own method template

To create a custom method template, follow the same Agent + Critic pattern:
  1. Define a state that extends StateSchema with your pattern’s tracking fields
  2. Implement a critic that returns retry with instruction_patch and state_patch when the pattern requires iteration
  3. Implement an agent whose build_system_prompt() injects pattern context from state