SelfCritiqueAgent
SelfCritiqueAgent
The SelfCritiqueAgent is a Crowe-native, reflection-driven agent that improves outputs through drafting, structured critique, self-reflection, and targeted revision. It iterates over a task multiple times, learning from its own feedback and retained memories to deliver higher-quality responses.
Overview
SelfCritiqueAgent employs three internal roles:
Author – produces the initial draft/output
Critic – evaluates the draft against explicit quality criteria
Reflector – distills lessons and patterns to guide revisions and future outputs
Initialization
from crowe.agents import SelfCritiqueAgent
agent = SelfCritiqueAgent(
agent_name="self-critique-agent",
system_prompt="...", # Optional: custom system prompt
model_name="openai/gpt-4o",
max_cycles=3,
memory_capacity=128
)Parameters
agent_name
str
"self-critique-agent"
Agent identifier for logs and routing
system_prompt
str
SC_PROMPT_DEFAULT
Base system prompt for all sub-roles
model_name
str
"openai/gpt-4o"
Backbone model used by the roles
max_cycles
int
3
Maximum iterative improvement cycles
memory_capacity
int
128
Long-term memory capacity (items)
return_list
bool
False
If True, return conversation as list
return_dict
bool
False
If True, return conversation as dict
Methods
draft
draftGenerate an initial draft for a task (Author role).
Args
task: The problem or instruction.context(optional): Extra hints, constraints, or retrieved facts.
critique
critiqueEvaluate a response against objective criteria (Critic role).
Returns
feedback: Structured critique text.score: A float in[0, 1]indicating quality.
self_reflect
self_reflectProduce self-reflection statements that generalize beyond a single attempt (Reflector role).
revise
reviseRevise a response using the latest critique and reflection.
cycle
cycleRun one improvement cycle: draft/critique/reflect/revise.
Returns a dictionary containing:
task,draft,feedback,reflection,revised,score,iteration
run_batch
run_batchExecute the iterative process for a list of tasks.
Returns
If
include_intermediates=False: List of final revised responsesIf
include_intermediates=True: Full histories per task
Example Usage
Memory System
SelfCritiqueAgent ships with InsightMemory, maintaining both short-term and long-term records of drafts, critiques, and reflections to guide future work.
Memory Features
Short-term traces for current session context
Long-term insights for durable lessons and reusable patterns
Capacity limits with automatic pruning
Relevance retrieval for similar future tasks
Similarity deduplication to avoid memory bloat
Best Practices
Define clear tasks: Supply constraints, audience, tone, and format.
Tune cycles: Increase
max_cyclesfor complex or high-stakes outputs.Curate memory: Adjust
memory_capacityand periodically purge.Choose the right model: Favor models with strong reasoning and instruction-following.
Harden for production: Add timeouts, retries, and validation if outputs feed downstream systems.
Last updated