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
- Generate: The agent produces an initial draft.
- Critique:
SelfRefineCriticevaluates 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. - Refine: If the score is below
quality_thresholdand refinements remain, the critic returnsretrywith aninstruction_patchasking the agent to improve. The agent sees its previous draft and the critique in the next prompt. - Accept: When the score meets the threshold or
max_refinementsis reached, the critic returnscontinueorstop.
SelfRefineCritic parameters
SelfRefineState fields
Customizing the quality scorer
The built-in critic uses heuristics. For production use, subclass and overrideevaluate():
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
- Act: The agent takes an action toward the task.
- Evaluate:
ReflexionCriticchecks for failures (errors, non-zero return codes, empty results). - Reflect: On failure, the critic generates a verbal reflection from the error context and returns
retrywith the reflection as aninstruction_patch. The reflection is stored instate.reflections. - 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
- Simulate: The agent takes an action, producing a result.
- Evaluate:
LATSCriticcomputes a reward from the result (errors → low reward, FINAL ANSWER → high reward). - Reflect: Failed paths (reward < 0.3) generate reflections stored in
state.reflections. - Guide: On retry, the critic provides an
instruction_patchthat includes reflections and UCB1-style exploration guidance. - Stop: When a path succeeds (reward ≥ success_threshold) or
max_simulationsis 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
- Collect:
MoACriticchecks if enough proposals have been gathered. If not, it returnsretrywith an instruction to gather more proposals. - Aggregate: When all proposals are collected, the critic prompts for synthesis.
- Output: When synthesis is complete and meets the quality threshold, the critic returns
stop.
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
- Plan: The orchestrator creates a task ledger and gathers initial facts.
- Delegate: At each step, a subtask is assigned to a specialist.
- Track:
ProgressCriticevaluates whether new facts have been gathered or tasks completed. - Re-plan: If no progress is detected for
max_stallsconsecutive steps, the critic returnsretrywith re-planning guidance. - Stop: When a FINAL ANSWER is provided, or when stall budget is exhausted.
ProgressCritic parameters
MagenticOneState fields
Scaffolding a new agent
Use theqit new CLI command to scaffold a new agent project from the built-in cookiecutter template:
src/agent.py— Agent class with State, init_state, build_system_prompt, reduceconfigs/default.yaml— Default model and step configurationtests/test_agent.py— Basic smoke testssnowl_compat.py— Snowl evaluation compatibility adaptereval_config.yaml— Evaluation configuration
Building your own method template
To create a custom method template, follow the same Agent + Critic pattern:- Define a state that extends
StateSchemawith your pattern’s tracking fields - Implement a critic that returns
retrywithinstruction_patchandstate_patchwhen the pattern requires iteration - Implement an agent whose
build_system_prompt()injects pattern context from state
