Zach's Agent Platform is a library built on top of Temporal, FastMCP, and LiteLLM to build resilient agents.
Project description
Zap - Zach's Agent Platform
Zap is an opinionated library for building resilient AI agents on top of Temporal. It provides a scalable, fault-tolerant way to create AI agents that can power demanding use cases and complex architectures.
Why Zap?
LLM providers can't yet guarantee production-level SLAs. API calls fail, rate limits hit, and connections drop. Zap solves this by running your agents on Temporal—a fault-tolerant code execution platform that captures state and retries failed steps automatically.
Key Benefits:
- Automatic retries with configurable policies for LLM and tool calls
- State persistence - agents survive crashes and can resume mid-conversation
- Sub-agent delegation - compose complex systems from specialized agents
- MCP integration - easily add tools via the Model Context Protocol
- Provider agnostic - use any LLM supported by LiteLLM (OpenAI, Anthropic, etc.)
Built On
- Temporal - Fault-tolerant workflow orchestration
- LiteLLM - Unified LLM provider interface
- FastMCP - Model Context Protocol client for tool integration
Installation
pip install zap-ai
Or with uv:
uv add zap-ai
Prerequisites
-
Temporal Server - You need a running Temporal cluster:
# Local development (requires Docker) temporal server start-dev # Or use Temporal Cloud: https://temporal.io/cloud
-
LLM API Keys - Set environment variables for your LLM provider:
export OPENAI_API_KEY="sk-..." # Or ANTHROPIC_API_KEY, AZURE_API_KEY, etc.
Quick Start
1. Define Your Agents
import asyncio
from zap_ai import ZapAgent, Zap, TaskStatus
from fastmcp import Client
# Create MCP clients for tool access
search_client = Client("https://example.com/search-mcp")
database_client = Client("./my_db_server.py")
# Define a main agent with access to tools and a sub-agent
main_agent = ZapAgent(
name="MainAgent",
prompt="You are a helpful research assistant. Use your tools to find information and delegate complex lookups to the LookupAgent.",
model="gpt-4o", # Any LiteLLM-supported model
mcp_clients=[search_client],
sub_agents=["LookupAgent"], # Can delegate to this agent
)
# Define a specialized sub-agent
lookup_agent = ZapAgent(
name="LookupAgent",
prompt="You are a database specialist. Query the database to find detailed information.",
discovery_prompt="Use this agent for database lookups and detailed data retrieval",
model="gpt-4o-mini", # Can use different models per agent
mcp_clients=[database_client],
)
# Create the Zap instance (validates configuration at build time)
zap = Zap(agents=[main_agent, lookup_agent])
2. Start the Platform
async def main():
# Initialize Temporal connection and MCP clients
await zap.start()
# Execute a task
task = await zap.execute_task(
agent_name="MainAgent",
task="Research the latest developments in quantum computing and summarize the key findings.",
)
print(f"Task started: {task.id}")
# Poll for completion
while True:
task = await zap.get_task(task.id)
print(f"Status: {task.status}")
if task.status == TaskStatus.COMPLETED:
print(f"Result: {task.result}")
break
elif task.status == TaskStatus.FAILED:
print(f"Error: {task.error}")
break
await asyncio.sleep(2)
asyncio.run(main())
3. Follow Up on Tasks
# Continue an existing conversation
await zap.execute_task(
follow_up_on_task=task.id,
task="Now compare these findings to classical computing approaches.",
)
4. Run the Worker (Separate Process)
# worker.py
from zap_ai.worker import run_worker
import asyncio
asyncio.run(run_worker())
python worker.py
Configuration
ZapAgent Options
| Parameter | Type | Default | Description |
|---|---|---|---|
name |
str |
required | Unique identifier (no spaces) |
prompt |
str |
required | System prompt for the agent |
model |
str |
"gpt-4o" |
LiteLLM model identifier |
mcp_clients |
list[Client] |
[] |
FastMCP clients for tool access |
sub_agents |
list[str] |
[] |
Names of agents this agent can delegate to |
discovery_prompt |
str |
None |
Description shown to parent agents |
max_iterations |
int |
50 |
Maximum agentic loop iterations |
Zap Options
| Parameter | Type | Default | Description |
|---|---|---|---|
agents |
list[ZapAgent] |
required | All agents in the system |
temporal_client |
Client |
None |
Custom Temporal client (auto-connects if None) |
task_queue |
str |
"zap-agents" |
Temporal task queue name |
Architecture
How It Works
┌─────────────────────────────────────────────────────────────────┐
│ Zap Orchestrator │
│ • Validates agent configuration at build time │
│ • Manages Temporal client connection │
│ • Routes tasks to appropriate agent workflows │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Temporal Workflow (per task) │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │
│ │ Receive │───▶│ LLM │───▶│ Tool Execution │ │
│ │ Message │ │ Inference │ │ (parallel) │ │
│ └─────────────┘ └─────────────┘ └─────────────────────┘ │
│ ▲ │ │
│ │ │ │
│ └────────────────────────────────────────┘ │
│ (agentic loop) │
│ │
│ Features: │
│ • Signals: Receive follow-up messages │
│ • Queries: Check status, get history │
│ • Continue-as-new: Handle long conversations │
│ • Child workflows: Delegate to sub-agents │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Activities │
│ ┌────────────────────┐ ┌─────────────────────────────────┐ │
│ │ Inference │ │ Tool Execution │ │
│ │ (LiteLLM) │ │ (FastMCP clients) │ │
│ │ • Retry on failure│ │ • Parallel execution │ │
│ │ • Provider agnostic│ │ • Schema conversion │ │
│ └────────────────────┘ └─────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
The Agentic Loop
- Receive Message - Initial task or follow-up signal
- LLM Inference - Call the model with conversation history and available tools
- Tool Execution - Execute any requested tools in parallel
- Repeat - Continue until the agent responds without tool calls
- Wait - Idle until a follow-up signal arrives or timeout
Sub-Agent Delegation
When an agent has sub-agents configured, a special transfer_to_agent tool is automatically added. When called:
- A child workflow is spawned for the sub-agent
- The parent workflow waits for completion
- The sub-agent's result is returned as a tool response
- The parent continues with the new context
State Management
- Conversation history is stored in the workflow state
- Continue-as-new prevents event history from growing unbounded
- Queries allow external access to current status and history
- Signals enable follow-up messages to running workflows
Task Status
| Status | Description |
|---|---|
PENDING |
Task created, not yet started |
RUNNING |
Agent is processing (inference or between tool calls) |
AWAITING_TOOL |
Waiting for tool execution to complete |
DELEGATED |
Running in a sub-agent (child workflow) |
COMPLETED |
Task finished successfully |
FAILED |
Task failed with an error |
Limitations
- No streaming - Currently uses query-based polling for status. Real-time streaming may be added in future versions.
- Temporal required - You need a running Temporal cluster (local dev server or Temporal Cloud).
- MCP tools only - Tools must be exposed via MCP servers (FastMCP makes this easy).
Future Plans
- Real-time streaming via callbacks/webhooks
- Human-in-the-loop tools (approval workflows)
- Hooks system for custom logic injection
- Expose agents as MCP servers for agent-to-agent communication
- Execution statistics and debugging tools
Contributing
Contributions are welcome! Please see IMPLEMENTATION.md for the development roadmap and open tasks.
License
MIT License - see LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zap_ai-0.2.0.tar.gz.
File metadata
- Download URL: zap_ai-0.2.0.tar.gz
- Upload date:
- Size: 314.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b5de7edd4e989be3d7b6c41d642a9a7a95d6b670416e9f8c115486755194024
|
|
| MD5 |
42df468dcd7278a22c3e64b6da56d23d
|
|
| BLAKE2b-256 |
05a0ce0977bdfdcf749a3a193f930ab112a7580f53687c002c57dccd38760215
|
Provenance
The following attestation bundles were made for zap_ai-0.2.0.tar.gz:
Publisher:
deploy.yml on zachrobo1/zap-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zap_ai-0.2.0.tar.gz -
Subject digest:
4b5de7edd4e989be3d7b6c41d642a9a7a95d6b670416e9f8c115486755194024 - Sigstore transparency entry: 791060541
- Sigstore integration time:
-
Permalink:
zachrobo1/zap-ai@770af2daa11bb9dd0ae47dd65f1b1723435d3135 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/zachrobo1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@770af2daa11bb9dd0ae47dd65f1b1723435d3135 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file zap_ai-0.2.0-py3-none-any.whl.
File metadata
- Download URL: zap_ai-0.2.0-py3-none-any.whl
- Upload date:
- Size: 45.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dcf2c09d6716d78578083752b198894d2e36f2ec70cf2b01c0caf7df6e777c27
|
|
| MD5 |
c8ca98e653f31b5a30b6d2c3bc32da7d
|
|
| BLAKE2b-256 |
2a275f752cd2e26838910b52ff0fe8f95b3243caf94b86d147b3ff0aca592f70
|
Provenance
The following attestation bundles were made for zap_ai-0.2.0-py3-none-any.whl:
Publisher:
deploy.yml on zachrobo1/zap-ai
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
zap_ai-0.2.0-py3-none-any.whl -
Subject digest:
dcf2c09d6716d78578083752b198894d2e36f2ec70cf2b01c0caf7df6e777c27 - Sigstore transparency entry: 791060544
- Sigstore integration time:
-
Permalink:
zachrobo1/zap-ai@770af2daa11bb9dd0ae47dd65f1b1723435d3135 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/zachrobo1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@770af2daa11bb9dd0ae47dd65f1b1723435d3135 -
Trigger Event:
workflow_dispatch
-
Statement type: