AI Agents

An AI agent is a system that uses a model to choose actions in an environment. Agents often combine reasoning, memory, tools, retrieval, and feedback so they can complete multi-step tasks.

What is workflow checkpointing?

Workflow checkpointing means saving an agent workflow's execution state at defined points so progress is not lost when execution pauses or fails. A checkpoint can capture the state values and execution metadata the orchestration framework needs to continue from a consistent point. Example: Generating API tests An agent processes a large API specification using several workflow nodes: 1. Extract requirements for an endpoint. 2. Generate test cases from those requirements. 3. Validate coverage and identify missing cases. 4. Prepare the final report . After the requirements node completes, the workflow saves a checkpoint. Another checkpoint is created after test generation. If the process crashes during validation, a durable checkpoint can preserve earlier completed work instead of requiring the agent to extract the requirements again. Think of checkpointing as saving progress in a game : the workflow stores enough information to continue from a known state rather than always starting over. What does a checkpoint contain? Depending on the framework, a checkpoint may store: Workflow state: Inputs, intermediate results, counters, and statuses. Execution position: Which work has completed and what is eligible to run next. Run identity: A thread or execution identifier that separates one workflow from another. Framework metadata: Information needed to reconstruct a consistent execution state. Large documents or generated test files can be stored separately, while state keeps references to those artifacts. In LangGraph LangGraph supports checkpointing through a checkpointer associated with a compiled graph. A stable thread id identifies the workflow thread whose saved state is being recorded and retrieved. For local experiments, an in memory checkpointer may be sufficient, but it does not protect against process restarts. Production applications typically use a durable persistence backend appropriate to their deployment. Checkpointing also supports inspecting state and pausing workflows for human review. Exact replay and recovery behavior depend on checkpoint placement, framework semantics, and how nodes perform side effects. Checkpoints are not external transaction rollbacks A saved workflow state does not automatically undo an API call, email, payment, or database update already performed by a node. If a node runs again after a failure, an external action could be repeated. For workflows that mutate external systems, use idempotency keys, operation IDs, or reconciliation checks so replaying execution does not cause duplicate actions. Practical considerations Save checkpoints at useful boundaries rather than copying huge payloads after every trivial operation. Use durable storage when crash recovery matters. Isolate checkpoints by workflow and tenant, and enforce access controls. Protect sensitive state with appropriate retention and encryption policies. Test interrupted executions, including failures before and after external side effects. Monitor checkpoint storage growth and cleanup. In short Checkpointing makes agent workflows more durable and inspectable by preserving execution progress. It provides the foundation for reliable recovery, although resuming a failed run and safely replaying side effects require additional care.

How do you resume a failed agent workflow?

Resuming a failed agent workflow means restarting execution from a valid saved state instead of repeating the entire task. It requires a durable checkpoint, a clear understanding of the failure, and safe handling of any actions that may already have happened outside the workflow. Example: An API test generation agent Imagine an agent with these steps: 1. Read API requirements for an endpoint. 2. Generate test cases . 3. Validate tests against the specification. 4. Save the approved test suite . After test generation, the workflow saves a checkpoint. The validation step then fails because the test runner temporarily loses its connection. Once the dependency is available, the orchestration system can load the saved state, recover the generated tests, and run the remaining work without extracting the requirements again. Checkpoint → Failure → Diagnose → Restore saved state → Continue or retry safely How does recovery work? Identify the affected run: Use a stable workflow/thread identifier, not just the latest job in a shared queue. Inspect the failure: Check the failed node, error category, retry attempts, and whether recovery is safe. Load a durable checkpoint: Retrieve the last consistent saved state and execution metadata. Reconcile external effects: Determine whether any timed out API call, file write, or database update already succeeded. Apply an appropriate fix: Restore service availability, correct the invalid input, or obtain required approval. Resume execution: Continue from the checkpoint according to the workflow framework's replay and scheduling semantics. Verify completion: Confirm expected outputs and record whether recovery succeeded or needs escalation. LangGraph example In LangGraph, a graph compiled with a durable checkpointer can associate saved execution state with a thread id . A subsequent invocation using that thread can recover persisted progress. A key distinction: resuming does not guarantee that the failed line of code continues exactly where it stopped. Depending on the execution boundary, a node or task may be replayed. Place side effecting operations behind idempotency or reconciliation checks. For intentional human interrupt flows, resumption uses the framework's interrupt/resume mechanisms rather than simply treating an interruption as an ordinary exception. What changes when using Celery? A Celery worker retry starts another task attempt; it does not automatically restore a LangGraph checkpoint. When combining Celery and LangGraph, the task should carry a stable workflow identifier, and the graph runtime should load its own saved state from durable storage. Also prevent two workers from resuming the same run simultaneously without coordination, for example by using a run level lock or lease. When should you avoid automatic resumption? Required permissions or human approval are missing. The previous operation's external outcome is unknown and repeating it could be harmful. The checkpoint is missing, incompatible, or corrupted. The failure is permanent, or retry and resource budgets are exhausted. In short Reliable workflow resumption combines durable checkpoint retrieval, failure aware recovery, and safe replay. It saves repeated work while protecting against duplicate actions and inconsistent outputs.

What is human-in-the-loop workflow orchestration?

Human in the loop (HITL) workflow orchestration means deliberately including a human decision or review step inside an otherwise automated agent workflow. The orchestrator controls when human involvement is needed, what information is presented, and how the workflow proceeds after a decision. Example: An API test generation agent An agent reads an API specification, generates test cases, and checks their coverage. Most cases can be processed automatically. But suppose the specification is ambiguous about whether an endpoint may expose customer data. The workflow can follow this path: Read requirements → Generate tests → Validate → Human review when needed → Continue or stop A reviewer receives the relevant requirement, proposed test, evidence, and a clear question. They may: Approve: Continue with the validated test suite. Request changes: Send the proposed tests to a revision node. Reject: Stop the affected action and record the reason. The agent must not treat missing or expired approval as permission to proceed. When is human involvement useful? High impact actions: Deleting production data, spending money, or changing access permissions. Ambiguous requirements: An expert must resolve conflicting or incomplete instructions. Quality gates: A reviewer verifies an important artifact before release. Policy exceptions: A decision needs accountable authorization rather than model judgment alone. Uncertain outcomes: Automation lacks enough reliable evidence to choose safely. Not every routine step requires a person. Excessive review can create delays and remove the benefits of automation. What does the orchestrator manage? 1. Trigger: A predefined rule identifies when review is required. 2. Review package: The workflow provides a concise proposal, supporting evidence, and allowed actions. 3. Pause or hold: Dependent actions must not execute until an authorized decision is received. 4. Decision capture: Record who made the decision, its scope, outcome, and relevant timestamp. 5. Controlled continuation: Validate the response and select the approved next node. 6. Timeout or rejection: Apply a safe fallback, such as escalation or termination, rather than silently approving. In a durable graph workflow such as LangGraph, checkpoints and interrupt/resume mechanisms can help preserve execution state while awaiting external input. The application's identity and authorization checks must still protect the approval action. Human review is not just another LLM call A model may recommend a course of action, but human approval is an external decision by an authorized person . It must be authenticated and tied to the specific operation being approved. For example, approval to run staging tests should not automatically authorize running the same tests against production systems. In short HITL orchestration combines automated execution with explicit human control at meaningful decision points. It improves oversight and accountability without forcing people to supervise every routine step.

How do you pause an agent workflow for human approval?

Pause an agent workflow for human approval by adding an explicit approval gate that interrupts execution, saves its state, and permits continuation only after an authorized person responds. Unlike a normal delay, the workflow must prevent the protected action from running while approval is pending. Example: API test generation agent An agent prepares tests for a production payment API. It may draft and validate the tests automatically, but executing them against production requires a reviewer. Generate tests → Validate → Request approval → Pause → Approve, reject, or revise Approve: After verifying the reviewer and scope, execute only the approved test plan. Reject: Stop the protected action and record the decision. Request changes: Return to test revision; seek fresh approval if the plan changes materially. No response: Stay blocked until a defined timeout or escalation policy takes effect. Never interpret silence as approval. How to implement the approval gate 1. Create a review request with a stable workflow ID, action summary, environment, relevant risks, and proposed parameters. 2. Checkpoint the workflow state using durable persistence so the running process need not stay active. 3. Interrupt before the sensitive action. The node should not make the production API call before approval is granted. 4. Authenticate and authorize the reviewer. Approval must be tied to the intended action, tenant, and environment. 5. Validate the response against allowed decisions and the exact version of the proposed plan. 6. Resume the same workflow with the recorded decision, or terminate/escalate. 7. Audit the transition including the reviewer, decision time, approved scope, and execution result. LangGraph example LangGraph supports human review with interrupt and Command(resume=...) when a checkpointer and consistent thread identifier are configured. Conceptually, an approval node can request input: The application collects an authenticated human decision and resumes the same thread using Command(resume=decision) . The returned decision still requires server side authorization and scope validation ; the presence of an approval looking string is not sufficient. When the interrupted node resumes, code before the interrupt can run again. Keep external side effects outside that replay prone section, or make them safely idempotent. Production safeguards Persist pending approvals so worker restarts do not lose them. Prevent duplicate or conflicting approvals with atomic state transitions. Expire approvals when the plan, credentials, or target environment changes. Enforce a safe timeout and revocation path. Never embed secrets in approval notifications or workflow checkpoints. In short A safe approval pause is a durable, fail closed checkpoint with authenticated decisions and controlled resumption. It gives people real authority over sensitive steps without blocking a worker indefinitely.

How do you design idempotent agent workflow steps?

An idempotent agent workflow step produces the same intended external outcome when the same logical operation is executed more than once. This matters because workers can retry tasks, networks can time out, and checkpoint recovery can replay a node. Beginner friendly example: Saving generated API tests An AI agent generates a test suite for the GET /orders/{id} endpoint. A worker saves the suite to a database, but its acknowledgment is lost. Celery retries the task. Without idempotency: The second attempt inserts another identical suite. With idempotency: Both attempts refer to the same logical save operation, so only one test suite record is created. For example, assign the save operation a stable key such as run 42:orders get:save suite:v1 . If the same request arrives again with the same key and payload, return the existing result rather than creating another record. How do you design an idempotent step? 1. Identify side effects: Look for database writes, emails, payments, deployments, and external API calls. Pure calculations generally do not create duplicate external effects. 2. Define a logical operation ID: Build a stable idempotency key from the workflow run, target resource, step, and operation version. A retry must reuse the original key—not generate a new random key. 3. Enforce deduplication atomically: Use a database unique constraint, transactional insert/upsert, or the external service's supported idempotency mechanism. A separate “check then insert” is vulnerable to concurrent retries. 4. Validate repeated requests: If a key is reused with materially different parameters, reject the conflict rather than silently treating a new action as an old one. 5. Record outcomes: Persist enough result information to recognize completed operations and return or reconcile their status. 6. Handle uncertain results: After a timeout, query the external system when possible before retrying. A local success flag cannot prove that a remote side effect did—or did not—occur. Small database example Assume a test suites table has a unique constraint on operation id . The save step can use an atomic insert with conflict handling: A later read can retrieve the existing row and compare its stored content or request hash. The unique constraint prevents duplicate rows even if two Celery workers attempt the same operation concurrently. Important: This protects only the specified database insert. If the step also sends an email or triggers another external service, that side effect needs its own deduplication strategy. LangGraph and Celery considerations LangGraph: A node may run again after checkpoint replay or resume. Persist operation IDs and protect side effects independently from graph state. Celery: Delivery and retries can result in repeated task execution. Reusing a stable operation ID across attempts prevents duplicate effects. Parallel branches: Namespace operation IDs by branch and target, while ensuring retries of that branch reuse the same ID. Multi tenancy: Scope identifiers and uniqueness appropriately so one tenant's operation never collides with another's. Common mistakes Generating a fresh idempotency key on every retry. Relying only on an in memory “already done” flag. Using a non atomic read before write check. Assuming a timeout means the external operation failed. Treating checkpointing as automatic rollback of external actions. In short Design idempotent steps around stable operation identities and atomic deduplication at the side effect boundary. This lets an agent safely retry or resume work without accidentally repeating the same action.

What is the supervisor pattern in multi-agent systems?

The supervisor pattern is a multi agent architecture in which one coordinating agent delegates work to specialist agents, reviews their results, and decides what happens next. The supervisor manages the overall task; specialists focus on narrower responsibilities. Beginner friendly example: API test generation Suppose a user asks an AI system to generate a complete test suite for a payment API. A supervisor can coordinate three specialists: Requirements agent: Extracts relevant endpoint behavior and constraints. Test generation agent: Produces positive, negative, and boundary test cases. Review agent: Checks coverage, correctness, and missing scenarios. The flow is: User request → Supervisor → Specialist agent → Supervisor → Next specialist or final answer For example, the supervisor first asks the requirements agent to identify authentication rules. It then gives that verified context to the test generation agent. If the review agent finds a missing 401 Unauthorized case, the supervisor can request a targeted correction instead of restarting the entire workflow. What does the supervisor do? 1. Understand the overall goal: Track the user's objective and acceptance criteria. 2. Select a specialist: Delegate only the relevant task and necessary context. 3. Coordinate handoffs: Pass useful results between agents without mixing unrelated data. 4. Evaluate progress: Decide whether more work, correction, or human review is necessary. 5. Finish or escalate: Produce the final result when checks pass, or stop with a clear reason. The supervisor may use an LLM for flexible delegation, while deterministic rules enforce permissions, budgets, and mandatory validation. Supervisor vs. ordinary sequential workflow In a fixed sequential workflow , the next node is already known: A → B → C. In a supervisor pattern , the coordinator may dynamically choose which specialist to call next. A specialist can be revisited when additional work is needed. However, a supervisor does not have to use an LLM: rule based coordination is possible when decisions are well defined. Supervisor vs. peer to peer collaboration With a supervisor, central coordination decides delegation and termination. In a peer to peer design, agents may communicate or hand tasks directly to one another. Central coordination offers clearer control and auditing, but it can become a bottleneck if every small decision requires another supervisor step. Practical implementation with LangGraph A LangGraph supervisor can be implemented as a graph node that chooses an allowed worker route. Each worker returns its structured result to shared workflow state; execution then returns to the supervisor for the next decision. For a reliable production design: Define each specialist's responsibilities and allowed tools. Give specialists focused inputs instead of the entire conversation. Validate their outputs before they influence later steps. Bound delegation cycles, model calls, and total cost. Require independent authorization for sensitive actions. Log handoffs and keep workflow state isolated by run and tenant. When should you use this pattern? Use it when a task needs multiple distinct skills and the order of specialist involvement may depend on intermediate results. For a small, predictable process, a simple workflow is usually cheaper and easier to maintain. In short A supervisor organizes specialist agents around one shared objective, selects their work, checks progress, and controls when the multi agent workflow is finished.

What is the hierarchical multi-agent architecture?

A hierarchical multi agent architecture organizes agents into multiple levels of responsibility. Higher level coordinators break down a goal and delegate parts of it to lower level coordinators or specialist agents, which return results upward for validation and integration. Unlike the basic supervisor pattern, where one supervisor often directly manages all specialists, a hierarchy can have several layers of supervisors . This is useful when a large task contains separate workstreams that each need their own coordination. Example: Generating tests for 100 API endpoints Imagine an AI system creating test suites for a service with 100 endpoints. Top level coordinator: Receives the overall goal and assigns workstreams. API domain coordinators: Manage separate groups, such as payments, users, and orders. Specialist agents: Extract endpoint requirements, generate tests, and validate coverage. Top level coordinator: Collects validated results and prepares the overall summary. Overall request → Domain coordinators → Specialist agents → Domain results → Final integration For example, the payments coordinator may independently manage test generation for 30 payment endpoints, while the orders coordinator handles 40 order endpoints. The top level coordinator should receive compact status and result references rather than the entire intermediate conversation for every endpoint. How does delegation work? 1. Decompose the goal: Identify workstreams with clear boundaries. 2. Assign subgoals: Give each coordinator its own scope, constraints, and completion criteria. 3. Delegate to specialists: Local coordinators select the appropriate agent for each task. 4. Validate locally: Each layer checks results before reporting completion upward. 5. Aggregate results: A higher layer combines validated outputs and handles unresolved cross team dependencies. 6. Finish or escalate: The top level coordinator verifies global acceptance criteria or reports blockers. A hierarchy need not force every task through every layer; simple work may go directly to a specialist when policy allows. How is this different from a single supervisor? Single supervisor: One coordinator directly manages the specialist agents. Hierarchical architecture: Coordinators can manage other coordinators, creating a tree or tiered management structure. The hierarchy can reduce the planning burden on a single supervisor, but it adds handoffs, orchestration complexity, latency, and the risk of losing context between levels. Designing it with LangGraph A practical implementation can represent each domain team as a subgraph with its own agent nodes and internal state. A parent graph delegates a scoped task to the subgraph and receives structured outputs. Good boundaries include: Input contract: Endpoint set, allowed tools, tenant identity, and acceptance criteria. Output contract: Completed test suite references, validation summary, and unresolved issues. State isolation: Separate per run and per team working state, with controlled sharing. Budgets: Maximum delegation depth, retries, token usage, and concurrency. Permissions: Sub agents cannot gain authority beyond what the parent workflow allows. A hierarchy is a logical coordination model; it does not require a separate server or Celery worker for every agent. Execution resources are scheduled independently. When is it appropriate? Use hierarchical agents when a task naturally splits into large, semi independent teams of work and one central supervisor would become difficult to manage. For a handful of simple steps, a flat workflow or single supervisor is usually easier and cheaper. In short Hierarchical multi agent systems coordinate complex tasks through layers of delegated responsibility. They improve modularity and scaling of decisions when workstreams are large, provided handoffs, validation, and permissions remain explicit.

What is a peer-to-peer multi-agent architecture?

A peer to peer (P2P) multi agent architecture is a design in which agents collaborate directly with one another, without requiring one central supervisor to approve every handoff. Each agent has a defined responsibility and can communicate with eligible peers to exchange information, request help, or transfer a task. Beginner friendly example: API test generation Imagine three specialists building tests for a payment endpoint: Requirements agent: Extracts endpoint requirements from the API specification. Test generation agent: Creates positive and negative test cases. Validation agent: Checks the proposed tests against the requirements. In a peer to peer workflow, the requirements agent can send its extracted specification directly to the test generation agent. The test generation agent forwards test cases to validation. If the validator finds a missing 401 Unauthorized test, it can send targeted feedback directly to the test generation agent. Requirements agent → Test generation agent ⇄ Validation agent → Completed suite No single agent needs to make every intermediate routing decision. However, the overall application still defines allowed communications, permissions, deadlines, and completion criteria. How do peers coordinate? 1. Discover permitted peers: Each agent knows which other agents it may contact. 2. Send a structured handoff: Include the task ID, relevant context, expected output, and success criteria. 3. Work independently: A receiving agent handles its specialized task. 4. Exchange results or feedback: Agents can request corrections or additional evidence directly. 5. Track completion: The orchestration system records outstanding tasks and determines when the overall request is complete. A shared message bus or workflow runtime can transport messages without becoming an AI supervisor that makes all decisions. How is P2P different from the supervisor pattern? Supervisor pattern: A coordinator typically delegates tasks and receives results before selecting the next specialist. Peer to peer pattern: Agents can hand work directly to one another, following agreed rules and communication contracts. Peer to peer describes decision and communication topology , not necessarily physical deployment. Agents may run in one process, separate services, or Celery workers. Advantages Less central coordination: Simple peer handoffs need not return to a supervisor. Flexible collaboration: Specialists can ask one another for help when a task changes. Modularity: Teams can evolve agents independently when contracts stay stable. Challenges and safeguards Uncontrolled handoffs: Agents can bounce a task indefinitely. Set hop counts, budgets, and clear termination rules. Conflicting results: Define validation, ownership, and conflict resolution policies. Missing visibility: Assign correlation IDs and log agent to agent messages. Permission leaks: Check tenant isolation and tool access at every handoff. Duplicate actions: Use stable operation IDs and idempotency controls for external side effects. LangGraph implementation idea In LangGraph, nodes representing specialist agents can have conditional transitions that hand off control directly to another agent node . Each handoff should update structured state with the chosen destination and relevant task data. Runtime rules must validate allowed destinations and prevent unbounded cycles. When should you use it? Choose peer to peer coordination when specialist agents need frequent direct collaboration and central supervisor decisions would add unnecessary overhead. If strong centralized review, strict compliance, or a simple fixed sequence is required, a supervisor or ordinary workflow may be clearer. In short Peer to peer multi agent systems enable direct, rule governed collaboration among specialists. They trade some centralized control for flexible handoffs and therefore need strong messaging contracts, observability, and safety boundaries.

What is a collaborative multi-agent architecture?

A collaborative multi agent architecture is a system in which several specialized AI agents contribute to the same goal by sharing findings, reviewing one another's work, and combining their results. Unlike merely splitting a task into isolated parts, collaboration involves meaningful interaction or feedback between agents. Example: Building an API test suite Suppose a team of agents must generate reliable tests for a payment API: Requirements agent: Extracts the endpoint behavior, authorization rules, and expected responses. Test designer: Drafts positive, negative, and boundary test scenarios. Security reviewer: Flags missing authentication or sensitive data checks. Quality reviewer: Checks overall coverage and consistency. The agents work toward one validated test suite . For example, the security reviewer notices that a missing token case is absent and provides feedback to the test designer. The designer adds the test; the quality reviewer checks the updated suite. Shared goal → Specialist contributions → Cross review → Revision → Validated result What makes this architecture collaborative? 1. Shared objective: All agents work toward a common acceptance criterion rather than unrelated outputs. 2. Distinct expertise: Each agent handles a well defined part of the problem. 3. Information exchange: Agents share the findings their teammates need. 4. Constructive feedback: One agent can challenge, validate, or improve another's output. 5. Result integration: A designated node or coordinator assembles and verifies the joint result. A shared document, structured state, or message channel can support collaboration, but simply storing outputs in one place does not guarantee effective teamwork. How is it different from peer to peer or supervisor architectures? Collaboration describes how agents work together, not who controls them. Peer to peer defines a communication topology: agents can contact peers directly. Supervisor defines a coordination pattern: one agent manages delegation and progress. Collaborative describes shared problem solving, cross review, and iterative improvement. A collaborative system may therefore use either peer to peer communication or a supervisor to coordinate discussions. These patterns are not mutually exclusive . When is collaboration useful? A result needs expertise from several domains. Agents can detect mistakes that other specialists may miss. Requirements are ambiguous and benefit from independent review. Quality improves through feedback and revision. For predictable tasks that do not need discussion, a simple sequence or parallel workflow can be faster and cheaper. Practical design tips Specify which agent owns each artifact and who can modify it. Exchange structured evidence and findings , not entire unfiltered conversations. Track revisions and record the reason for each requested change. Establish conflict resolution rules when agents disagree. Limit discussion rounds, token consumption, and tool calls. Validate the final output independently; agreement among agents is not proof of correctness. Enforce tool permissions and tenant boundaries at every handoff. For a LangGraph implementation, agents can be separate graph nodes that update shared state and route feedback to one another. The graph should still have explicit completion conditions so review cycles do not continue indefinitely. In short Collaborative multi agent architecture combines specialized contributions with communication, feedback, and joint validation. Its value comes from improving a shared result, not simply increasing the number of agents.

What is a competitive multi-agent architecture?

A competitive multi agent architecture is a design in which multiple agents independently propose solutions, arguments, or actions, and a separate evaluation mechanism selects the best result. Instead of cooperating on one shared draft, agents compete to produce stronger candidates. Beginner friendly example: API test generation Suppose an AI system must create a test suite for a payment endpoint. Rather than asking one agent to generate the tests, the system asks three agents independently: Agent A: Focuses on functional coverage. Agent B: Focuses on edge cases and negative paths. Agent C: Focuses on security and authorization scenarios. Each agent produces its own candidate test suite. A judge or evaluator then scores the candidates using predefined criteria such as requirement coverage, correctness, duplication, and security coverage. Task → Multiple independent candidates → Evaluation → Best result or merged result For example, Agent B may discover an important boundary case that the others miss, while Agent C adds a missing 403 Forbidden scenario. The evaluator can select the strongest candidate or combine validated parts from several candidates. How does competition work? 1. Generate independent candidates: Agents should avoid copying one another's reasoning unless the design intentionally includes debate rounds. 2. Use the same task and constraints: Each competitor receives comparable requirements and acceptance criteria. 3. Evaluate with explicit criteria: Score outputs using deterministic checks, human review, another model, or a combination. 4. Select or aggregate: Choose one winner or merge complementary validated results. 5. Verify the final result: Competition does not guarantee correctness; the winning output still needs validation. Competitive vs. collaborative agents Collaborative architecture: Agents share information and improve one another's work. Competitive architecture: Agents independently produce alternatives that are compared. Debate architecture: Agents may explicitly challenge one another's claims over multiple rounds. These approaches can be combined. For example, agents can first compete independently, then collaborate to refine the winning proposal. When is competition useful? The problem has several plausible solutions. A single model response is too variable or unreliable. Diversity of ideas improves coverage. The system has a strong evaluation function. The cost of extra model calls is justified by higher quality. Competition is usually unnecessary for simple deterministic tasks where one validated workflow is sufficient. Practical design tips Keep prompts and input context comparable across competitors. Use different roles, models, seeds, or strategies only when diversity is intentional. Define objective scoring wherever possible. Prevent the evaluator from favoring verbose answers over correct ones. Set limits on candidate count, token usage, and evaluation rounds. Separate generation from judging to reduce self preference. Preserve provenance so the final result can be traced back to contributing agents. In LangGraph, competitive agents can run as parallel branches. Their outputs can then join at an evaluation node that scores candidates and routes the selected result forward. In short Competitive multi agent architecture improves solution diversity by having several agents independently attempt the same task and then evaluating their outputs. Its effectiveness depends more on the quality of the evaluation process than on the number of competing agents.