Skip to content

pyagent-patterns — Resolution (Tier 2)

pyagent_patterns.resolution.self_reflection.SelfReflection

Bases: Pattern

Generate → critique → refine iterative loop.

Parameters:

Name Type Description Default
agent Agent

The agent that generates and refines output.

required
critic Agent | None

Optional separate critic agent. If None, the same agent self-critiques.

None
max_rounds int

Maximum number of generate-critique rounds.

3
stop_phrase str

If the critic's response contains this phrase, stop early.

'APPROVED'

pyagent_patterns.resolution.cross_reflection.CrossReflection

Bases: Pattern

Peer review: one agent generates, another reviews, generator revises.

Parameters:

Name Type Description Default
generator Agent

Agent that produces the initial output and revisions.

required
reviewer Agent

Agent that reviews and provides feedback.

required
max_rounds int

Maximum number of generate-review-revise cycles.

2
stop_phrase str

If reviewer says this, stop early.

'APPROVED'

pyagent_patterns.resolution.debate.Debate

Bases: Pattern

Structured adversarial debate with judge resolution.

Parameters:

Name Type Description Default
debaters list[Agent]

List of agents, each arguing a different position.

required
judge Agent

Agent that evaluates arguments and renders final decision.

required
rounds int

Number of argumentation rounds.

3
positions list[str] | None

Optional list of position labels (e.g., ["BUY", "SELL"]). If not provided, positions are assigned as "Position 1", "Position 2", etc.

None

pyagent_patterns.resolution.voting.Voting

Bases: Pattern

Independent voting with configurable aggregation strategy.

Parameters:

Name Type Description Default
voters list[Agent]

List of agents that each cast a vote.

required
strategy VotingStrategy

Voting strategy (majority or weighted).

MAJORITY
weights list[float] | None

Optional per-agent weights for weighted voting. Must match length of voters. Defaults to equal weights.

None
normalize bool

If True, ask each voter to respond with a concise answer suitable for comparison.

True

pyagent_patterns.resolution.evaluator_optimizer.EvaluatorOptimizer

Bases: Pattern

Generate → evaluate → revise loop with explicit evaluation criteria.

Parameters:

Name Type Description Default
generator Agent

Agent that produces and revises output.

required
evaluator Agent

Agent that scores output against criteria.

required
criteria list[str] | None

List of evaluation criteria the evaluator checks.

None
max_rounds int

Maximum optimization rounds.

3
pass_threshold int

Score (1-10) at which the output is considered acceptable.

7