Skip to content

joshmsmith/temporal-multi-agent-consensus-approval-analysis

Repository files navigation

temporal-multi-agent-consensus-approval-analysis

Examples showing agents analyzing data and doing consensus to review and approve proposals - in this case, Cosmos Insurance proposals. These agents are automation agents who accomplish tasks intelligently and independently. They are not conversational. These agents are exposed as tools (via MCP) so they can be used by an MCP client.

We will demonstrate several kinds of agents:

  • local agents that strips sensitive data?
  • analysis agents that review proposals for acceptance based on insurance rules
    • these are evaluated which weighs their judgements
  • consensus agent that reviews analysis and comes to a final result
  • summary agent that summarizes the review and analysis

Space Insurance Approvals

How it works: Consensus

Prerequisites:

1. Setup

uv venv
source .venv/bin/activate
poetry install

Launch Temporal locally

(if using local Temporal, see .env.example for other options)

temporal server start-dev

Set up your .env settings

Copy .env.example to .env and set your properties, particularly:

LLM_MODEL=openai/gpt-4o
LLM_KEY=sk-proj-...

Start the worker

poetry run python run_worker.py

Trigger Analysis!

poetry run python run_analysis.py # defaults to bebop

Or pass a proposal name in:

poetry run python run_analysis.py serenity

2. Running

This agent is:

  • a tool that takes action for an agent in MCP context
  • an agent that makes decisions - to approve or reject the proposals
  • an orchestrator of the consensus agents
  • a Temporal Workflow - dynamically taking action to accomplish the review analysis

(related definitions)

Note: It does create reviews.json and creates a review.pdf

Terminal

An easy way to understand what it's doing is to kick it off via a terminal:

poetry run python run_consensus_agent.py 

Here's what the output looks like:


You can follow along with its progress in the Temporal UI Workflow History.

MCP

You can also hook this up to an MCP Client using the included mcp_server.py.
(You may want to reset the data files between runs to get the same results again.) WSL config:

    "analysis_agent": {
      "disabled": false,
      "timeout": 60,
      "type": "stdio",
      "command": "wsl.exe",
      "args": [
        "--cd",
        "/path/to/temporal-multi-agent-consensus-approval-analysis",
        "--",
        "poetry",
        "run",
        "python",
        "mcp_server.py"
      ]
    }

agents and what they do

3. Results

What's Cool About This:

Building agents is easy and straightforward with Temporal. Temporal features like Workflows, Activities, and Signals, plus durable state management and retries, dramatically simplify building out agentic systems. Plus, because Temporal Cloud can scale to extremely high volumes, our agent application is also scalable to high volumes easily, by scaling up our workers (and paying for LLM API Keys with high rate limits, ha).

Consensus is useful for important processes that you want to automate but not leave to only one agent.

If you already know how to build with Temporal, you have a head start on building some agentic systems. If not, play with the code, take some (free) courses, and enjoy learning.

In Production

About

An example showing AI agents doing approval analysis & consensus with Temporal orchestration in an insurance context

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages