ActorCritic
ActorCritic pairs two agents: an actor that writes a draft and a critic that looks for problems in it, with a different prompt and ideally a different model. The actor revises until the critic’s score clears a threshold. Use it for quality-critical work such as code generation, security review or important written communication, where a second, differently-built reviewer catches mistakes a model misses in its own output.
The critic returns structured JSON ({score, issues, summary}); the
actor refines below threshold.
Why a separate Self-Refine?
Self-Refine runs critic + refiner
with the parent’s same model and same prompt template. ActorCritic
earns its complexity only when the actor and critic have different
blind spots, which usually means different models. ActorCritic requires both
actor and critic Agent instances; for same-model self-critique,
use Self-Refine.
Usage
from loomflow import Agent
from loomflow.team import Team
actor = Agent(
"Generate the code.",
model="claude-opus-4-7",
)
critic = Agent(
"Find bugs, security issues, and edge cases. Return strict JSON: "
'{"score": 0..1, "issues": [...], "summary": "..."}',
model="gpt-4o", # different model on purpose
)
team = Team.actor_critic(
actor=actor,
critic=critic,
max_rounds=3,
approval_threshold=0.9,
model="claude-opus-4-7", # coordinator
)
result = await team.run("Write a function that sanitizes user input.")When to use
- Code generation: Actor generates, critic looks for bugs / security issues / missing edge cases.
- Security review: Actor drafts a policy; critic challenges it against an attacker model.
- Important written communication: Actor drafts; critic checks tone / accuracy / sensitive content.
Cost: 2–4× a single-actor ReAct run, depending on rounds. Pays off when shipping a wrong answer is more expensive than the extra calls.
Different models matter. The whole point is blind-spot diversity. Same-model actor and critic share the same blind spots, so the gain collapses. Use Anthropic for the actor + OpenAI for the critic, or vice versa, or two different model sizes (large for actor, small fast critic for cost). Anything works except the identical model.