Skip to content

pyagent-patterns — Advanced (Tier 4)

pyagent_patterns.advanced.talker_reasoner.TalkerReasoner

Bases: Pattern

Dual-process: fast intuition (System 1) + slow deliberation (System 2).

Parameters:

Name Type Description Default
talker Agent

Fast, cheap agent for routine queries (System 1).

required
reasoner Agent

Slow, expensive agent for complex queries (System 2).

required
classifier Agent | None

Optional agent that decides talker vs reasoner. If None, always starts with talker and escalates on uncertainty keywords.

None
complexity_threshold list[str] | None

Keywords in talker output that trigger escalation to reasoner.

None

pyagent_patterns.advanced.swarm.Swarm

Bases: Pattern

Decentralized swarm: agents interact locally, behavior emerges globally.

Parameters:

Name Type Description Default
agents list[Agent]

Pool of swarm agents (all follow same local rules).

required
rounds int

Number of interaction rounds.

3
neighbor_count int

How many random peers each agent interacts with per round.

2
aggregation str

How to produce final output from swarm state. "last" = last round's outputs, "vote" = majority vote.

'last'

pyagent_patterns.advanced.human_in_the_loop.HumanInTheLoop

Bases: Pattern

Agent with human approval gate.

Parameters:

Name Type Description Default
agent Agent

The LLM agent that processes the task.

required
review_fn HumanReviewFn

Callable that presents output to human and returns decision. Signature: (output: str, metadata: dict) -> HumanDecision

auto_approve
max_revisions int

Maximum number of revision attempts after rejection.

3

pyagent_patterns.advanced.react.ReAct

Bases: Pattern

Reasoning + Acting loop with tool use.

Parameters:

Name Type Description Default
agent Agent

The reasoning agent.

required
tools dict[str, ToolFn] | None

Mapping of tool names to callable functions.

None
max_steps int

Maximum number of Thought→Action→Observation cycles.

5
finish_token str

Token in agent response that signals task completion.

'FINISH'