Python SDK for building workflow automation agents with Erdo
Project description
Erdo Agent SDK
Build AI agents and workflows with Python. The Erdo Agent SDK provides a declarative way to create agents that can be executed by the Erdo platform.
Installation
pip install erdo
Quick Start
Creating Agents
Create agents using the Agent class and define steps with actions:
from erdo import Agent, state
from erdo.actions import memory, llm
from erdo.conditions import IsSuccess, GreaterThan
# Create an agent
data_analyzer = Agent(
name="data analyzer",
description="Analyzes data files and provides insights",
running_message="Analyzing data...",
finished_message="Analysis complete",
)
# Step 1: Search for relevant context
search_step = data_analyzer.step(
memory.search(
query=state.query,
organization_scope="specific",
limit=5,
max_distance=0.8
)
)
# Step 2: Analyze the data with AI
analyze_step = data_analyzer.step(
llm.message(
model="claude-sonnet-4-20250514",
system_prompt="You are a data analyst. Analyze the data and provide insights.",
query=state.query,
context=search_step.output.memories,
response_format={
"Type": "json_schema",
"Schema": {
"type": "object",
"required": ["insights", "confidence", "recommendations"],
"properties": {
"insights": {"type": "string", "description": "Key insights found"},
"confidence": {"type": "number", "description": "Confidence 0-1"},
"recommendations": {"type": "array", "items": {"type": "string"}},
},
},
},
),
depends_on=search_step,
)
Code Execution with External Files
Use the @agent.exec decorator to execute code with external Python files:
from erdo.types import PythonFile
@data_analyzer.exec(
code_files=[
PythonFile(filename="analysis_files/analyze.py"),
PythonFile(filename="analysis_files/utils.py"),
]
)
def execute_analysis():
"""Execute detailed analysis using external code files."""
from analysis_files.analyze import analyze_data
from analysis_files.utils import prepare_data
# Prepare and analyze data
prepared_data = prepare_data(context.parameters.get("dataset", {}))
results = analyze_data(context)
return results
Conditional Step Execution
Handle step results with conditions:
from erdo.conditions import IsSuccess, GreaterThan
# Store high-confidence results
analyze_step.on(
IsSuccess() & GreaterThan("confidence", "0.8"),
memory.store(
memory={
"content": analyze_step.output.insights,
"description": "High-confidence data analysis results",
"type": "analysis",
"tags": ["analysis", "high-confidence"],
}
),
)
# Execute detailed analysis for high-confidence results
analyze_step.on(
IsSuccess() & GreaterThan("confidence", "0.8"),
execute_analysis
)
Complex Execution Modes
Use execution modes for advanced workflows:
from erdo import ExecutionMode, ExecutionModeType
from erdo.actions import bot
from erdo.conditions import And, IsAny
from erdo.template import TemplateString
# Iterate over resources
analyze_files = agent.step(
action=bot.invoke(
bot_name="file analyzer",
parameters={"resource": TemplateString("{{resources}}")},
),
key="analyze_files",
execution_mode=ExecutionMode(
mode=ExecutionModeType.ITERATE_OVER,
data="parameters.resource",
if_condition=And(
IsAny(key="dataset.analysis_summary", value=["", None]),
IsAny(key="dataset.type", value=["FILE"]),
),
)
)
Loading Prompts
Use the Prompt class to load prompts from files:
from erdo import Prompt
# Load prompts from a directory
prompts = Prompt.load_from_directory("prompts")
# Use in your agent steps
step = agent.step(
llm.message(
system_prompt=prompts.system_prompt,
query=state.query,
)
)
State and Templating
Access dynamic data using the state object and template strings:
from erdo import state
from erdo.template import TemplateString
# Access input parameters
query = state.query
dataset = state.dataset
# Use in template strings
template = TemplateString("Analyzing: {{query}} for dataset {{dataset.id}}")
Core Concepts
Actions
Actions are the building blocks of your agents. Available action modules:
erdo.actions.memory- Memory storage and searcherdo.actions.llm- Large language model interactionserdo.actions.bot- Bot invocation and orchestrationerdo.actions.codeexec- Code executionerdo.actions.utils- Utility functionserdo.actions.resource_definitions- Resource management
Conditions
Conditions control when steps execute:
IsSuccess(),IsError()- Check step statusGreaterThan(),LessThan()- Numeric comparisonsTextEquals(),TextContains()- Text matchingAnd(),Or(),Not()- Logical operators
Types
Key types for agent development:
Agent- Main agent classExecutionMode- Control step execution behaviorPythonFile- Reference external Python filesTemplateString- Dynamic string templatesPrompt- Prompt management
Advanced Features
Multi-Step Dependencies
Create complex workflows with step dependencies:
step1 = agent.step(memory.search(...))
step2 = agent.step(llm.message(...), depends_on=step1)
step3 = agent.step(utils.send_status(...), depends_on=[step1, step2])
Dynamic Data Access
Use the state object to access runtime data:
# Access nested data
user_id = state.user.id
dataset_config = state.dataset.config.type
# Use in actions
step = agent.step(
memory.search(query=f"data for user {state.user.id}")
)
Error Handling
Handle errors with conditions and fallback steps:
from erdo.conditions import IsError
main_step = agent.step(llm.message(...))
# Handle errors
main_step.on(
IsError(),
utils.send_status(
message="Analysis failed, please try again",
status="error"
)
)
Invoking Agents
Use the invoke() function to execute agents programmatically:
from erdo import invoke
# Invoke an agent
response = invoke(
"data-question-answerer",
messages=[{"role": "user", "content": "What were Q4 sales?"}],
datasets=["sales-2024"],
parameters={"time_period": "Q4"},
)
if response.success:
print(response.result)
else:
print(f"Error: {response.error}")
Invocation Modes
- Live Mode (default): Runs against real backend with LLM API
- Replay Mode: Uses cached responses - free after first run (perfect for testing!)
- Mock Mode: Returns synthetic responses - always free
# Replay mode - free after first run
response = invoke("my-agent", messages=[...], mode="replay")
# Mock mode - always free
response = invoke("my-agent", messages=[...], mode="mock")
Testing Agents
Write fast, parallel agent tests using agent_test_* functions:
from erdo import invoke
from erdo.test import text_contains
def agent_test_csv_sales():
"""Test CSV sales analysis."""
response = invoke(
"data-question-answerer",
messages=[{"role": "user", "content": "What were Q4 sales?"}],
datasets=["sales-q4-2024"],
mode="replay", # Free after first run!
)
assert response.success
result_text = str(response.result)
assert text_contains(result_text, "sales", case_sensitive=False)
Run tests in parallel with the CLI:
# Run all tests
erdo agent-test tests/test_my_agent.py
# Verbose output
erdo agent-test tests/test_my_agent.py --verbose
Test Helpers
The erdo.test module provides assertion helpers:
from erdo.test import (
text_contains, # Check if text contains substring
text_equals, # Check exact match
text_matches, # Check regex pattern
json_path_equals, # Check JSON path value
json_path_exists, # Check if JSON path exists
has_dataset, # Check if dataset is present
)
CLI Integration
Deploy and manage your agents using the Erdo CLI:
# Login to your account
erdo login
# Sync your agents to the platform
erdo sync-agent my_agent.py
# Invoke an agent
erdo invoke my-agent --message "Hello!"
# Run agent tests
erdo agent-test tests/test_my_agent.py
Examples
See the examples/ directory for complete examples:
agent_centric_example.py- Comprehensive agent with multiple stepsstate_example.py- State management and templatinginvoke_example.py- Agent invocation patternsagent_test_example.py- Agent testing examples
API Reference
Core Classes
- Agent: Main agent class for creating workflows
- ExecutionMode: Control step execution (iterate, conditional, etc.)
- Prompt: Load and manage prompt templates
Actions
- memory: Store and search memories
- llm: Interact with language models
- bot: Invoke other bots and agents
- codeexec: Execute Python code
- utils: Utility functions (status, notifications, etc.)
Conditions
- Comparison:
GreaterThan,LessThan,TextEquals, etc. - Status:
IsSuccess,IsError,IsNull, etc. - Logical:
And,Or,Not
State & Templating
- state: Access runtime parameters and data
- TemplateString: Dynamic string templates with
{{variable}}syntax
License
Commercial License - see LICENSE file for details.
Project details
Release history Release notifications | RSS feed
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 erdo-0.1.9.tar.gz.
File metadata
- Download URL: erdo-0.1.9.tar.gz
- Upload date:
- Size: 66.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db36d85ef91cc84f79d8746bce1de765acb4b046dd9a980585040fb8ed7c6593
|
|
| MD5 |
a3218ebd01eee7a8d2e73691e2466092
|
|
| BLAKE2b-256 |
f61f4d7900093a38e9f4bc9eaa009abfa2c5af54db64dbc1103872c5bcbcf77a
|
Provenance
The following attestation bundles were made for erdo-0.1.9.tar.gz:
Publisher:
publish.yml on erdoai/erdo-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
erdo-0.1.9.tar.gz -
Subject digest:
db36d85ef91cc84f79d8746bce1de765acb4b046dd9a980585040fb8ed7c6593 - Sigstore transparency entry: 662379530
- Sigstore integration time:
-
Permalink:
erdoai/erdo-python-sdk@f043cd884c6799567b2e8b645e9244453f0d146d -
Branch / Tag:
refs/tags/v0.1.9 - Owner: https://github.com/erdoai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f043cd884c6799567b2e8b645e9244453f0d146d -
Trigger Event:
push
-
Statement type:
File details
Details for the file erdo-0.1.9-py3-none-any.whl.
File metadata
- Download URL: erdo-0.1.9-py3-none-any.whl
- Upload date:
- Size: 87.6 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 |
329490b5cd9084d8498d9099b357a1d9e8007642b0ef57b0aa81a01628fa27ca
|
|
| MD5 |
6a20b727220e54905baccb6e1cb29f5e
|
|
| BLAKE2b-256 |
d66c1d84a1bf4e9c6ace69a6cf987ab4189d80830230c06d964a01df1258a1c3
|
Provenance
The following attestation bundles were made for erdo-0.1.9-py3-none-any.whl:
Publisher:
publish.yml on erdoai/erdo-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
erdo-0.1.9-py3-none-any.whl -
Subject digest:
329490b5cd9084d8498d9099b357a1d9e8007642b0ef57b0aa81a01628fa27ca - Sigstore transparency entry: 662379532
- Sigstore integration time:
-
Permalink:
erdoai/erdo-python-sdk@f043cd884c6799567b2e8b645e9244453f0d146d -
Branch / Tag:
refs/tags/v0.1.9 - Owner: https://github.com/erdoai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f043cd884c6799567b2e8b645e9244453f0d146d -
Trigger Event:
push
-
Statement type: