Skip to main content

Actions

Actions are the fundamental building blocks that define what each step in your agent workflow actually does. They represent specific operations that can be performed, from LLM calls to code execution to memory operations.

What is an Action?

An action specifies:
  • The type of operation to perform (LLM, code, memory, etc.)
  • The parameters needed for the operation
  • The expected outputs and data format
  • How to handle errors and edge cases

LLM Actions

Generate text, analyze content, and make AI-powered decisions

Code Execution

Run Python code for data processing and calculations

Memory Actions

Store, search, and retrieve knowledge and data

Integration Actions

Connect with external APIs, tools, and services

Action Types

LLM Actions

Language model actions for AI-powered text generation and analysis:
from erdo import state
from erdo.actions import llm
from erdo.template import TemplateString

# Basic message generation
basic_llm = llm.message(
    model="claude-sonnet-4",
    query=f"Analyze this data: {state.input_data}",
    system_prompt="You are a data analysis expert"
)

# Structured response with JSON schema
structured_llm = llm.message(
    model="claude-sonnet-4",
    query=f"Extract key insights from: {state.document}",
    response_format={
        "Type": "json_schema",
        "Schema": {
            "schema": {
                "type": "object",
                "properties": {
                    "summary": {"type": "string"},
                    "key_points": {
                        "type": "array",
                        "items": {"type": "string"}
                    },
                    "sentiment": {"type": "string"},
                    "confidence": {"type": "number"}
                }
            }
        }
    }
)

# LLM with tools
llm_with_tools = llm.message(
    model="claude-sonnet-4",
    query=f"Research and analyze {state.topic}",
    tools=[
        Tool(
            name="web_search",
            description="Search for information",
            actiontype="websearch.search",
            parameters={"query": state.query}
        ),
        Tool(
            name="calculator",
            description="Perform calculations",
            actiontype="codeexec.execute",
            parameters={"code": state.calculation}
        )
    ]
)

Code Execution Actions

Execute Python code for data processing and calculations:
from erdo import state
from erdo.actions import codeexec

# Basic code execution
basic_code = codeexec.execute(
    code=f"""
# Process the input data
data = {state.input_data}
result = process_data(data)
print(f"Processed {{len(data)}} items")
"""
)

# Advanced data analysis
analysis_code = codeexec.execute(
    code=f"""
import pandas as pd
import numpy as np

# Load and analyze data
df = pd.read_csv('{state.file_path}')
summary = df.describe()
insights = analyze_trends(df)

results = {{
    'summary': summary.to_dict(),
    'insights': insights
}}
"""
)

Memory Actions

Store, search, and retrieve knowledge and information:
from erdo import state
from erdo.actions import memory

# Store information
store_memory = memory.store(
    memory={
        "content": state.analysis_results,
        "tags": ["analysis", state.project_name],
        "searchable_texts": [state.key_findings]
    }
)

# Search for relevant information
search_memory = memory.search(
    query=state.search_query,
    limit=10,
    organization_scope="specific"
)

Web Research Actions

Search and parse web content:
from erdo import state
from erdo.actions import websearch, webparser

# Web search
web_search = websearch.search(
    query=f"{state.search_term} latest developments",
    num_results=10,
    time_filter="past_month"
)

# Parse website content
parse_content = webparser.parse(
    url=state.target_url,
    extract_format="markdown",
    include_links=True,
    include_images=False
)

# Comprehensive research action
research_action = websearch.search(
    query=state.research_topic,
    sites=["arxiv.org", "scholar.google.com", "nature.com"],
    content_type="academic"
)

Bot Integration Actions

Invoke pre-built bots and other agents:
from erdo import state
from erdo.actions import bot

# Invoke data analyst bot
data_analysis = bot.invoke(
    bot_name="data analyst",
    parameters={
        "query": state.analysis_request,
        "data_source": state.data_connection
    }
)

# Security check
security_check = bot.invoke(
    bot_name="security checker",
    parameters={
        "code": state.code_to_check,
        "scan_type": "comprehensive"
    }
)

# Chain multiple bots
quality_check = bot.invoke(
    bot_name="data quality checker",
    parameters={
        "output": state.previous_analysis,
        "validation_rules": state.quality_rules
    }
)

Utility Actions

Helper actions for workflow control and data manipulation:
from erdo import state
from erdo.actions import utils
from erdo.template import TemplateString

# Echo/pass-through data
echo_action = utils.echo(
    data={"processed": True, "timestamp": TemplateString("{{system.current_time}}")}
)

# Send status updates
status_update = utils.send_status(
    status="processing",
    message=f"Analyzing data batch {state.batch_number}",
    details={
        "progress": state.progress_percentage,
        "eta": state.estimated_completion
    }
)

# Capture exceptions
exception_handler = utils.capture_exception(
    message=f"Analysis failed for dataset {state.dataset_name}",
    exception=state.error_details
)

# Checkpoint for long-running processes
checkpoint_action = utils.checkpoint_attempt(
    loops=state.loop_count,
    attempts=state.attempt_number
)

Action Configuration

Response Formats

Configure how actions return data:
structured_response = llm.message(
    model="claude-sonnet-4",
    query=state.query,
    response_format={
        "Type": "json_schema",
        "Schema": {
            "schema": {
                "type": "object",
                "required": ["summary", "recommendations"],
                "properties": {
                    "summary": {
                        "type": "string",
                        "description": "Brief summary of findings"
                    },
                    "recommendations": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "action": {"type": "string"},
                                "priority": {"type": "string"},
                                "impact": {"type": "number"}
                            }
                        }
                    },
                    "confidence": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 1
                    }
                }
            }
        }
    }
)

Error Handling

Configure how actions handle errors:
# Action with retry configuration
resilient_action = llm.message(
    model="claude-sonnet-4",
    query="{{query}}",
    retry_config={
        "max_attempts": 3,
        "backoff_factor": 2,
        "retry_on": ["timeout", "rate_limit", "server_error"]
    },
    timeout=60
)

# Action with fallback
fallback_action = llm.message(
    model="claude-sonnet-4",
    query="{{query}}",
    fallback_model="gpt-4o",
    fallback_on_error=True
)

Performance Optimization

Optimize action performance:
# Cached action
cached_action = memory.search(
    query="{{query}}",
    cache_ttl=3600,  # Cache for 1 hour
    cache_key="search_{{query_hash}}"
)

# Parallelizable action
parallel_action = codeexec.execute(
    code="{{processing_code}}",
    parallel=True,
    max_workers=4
)

# Resource-limited action
limited_action = codeexec.execute(
    code="{{heavy_computation}}",
    memory_limit="2GB",
    cpu_limit="1 core",
    timeout=300
)

Advanced Action Patterns

Conditional Actions

Actions that execute based on conditions:
# Action with execution condition
conditional_action = llm.message(
    model="claude-sonnet-4",
    query="{{specialized_query}}",
    execution_condition="{{data_type}} == 'complex'"
)

# Multi-path action
multi_path_action = codeexec.execute(
    code="""
if {{condition_a}}:
    result = process_path_a({{data}})
elif {{condition_b}}:
    result = process_path_b({{data}})
else:
    result = default_processing({{data}})
"""
)

Dynamic Actions

Actions that adapt based on runtime data:
# Dynamic model selection
dynamic_llm = llm.message(
    model="{{selected_model}}",  # Determined at runtime
    query="{{dynamic_query}}",
    system_prompt="{{context_specific_prompt}}"
)

# Dynamic code generation
dynamic_code = codeexec.execute(
    code=generate_code_template("{{operation_type}}", "{{parameters}}")
)

Composite Actions

Combine multiple actions:
# Action sequence
def composite_analysis(data):
    # Step 1: Preprocess
    preprocessed = codeexec.execute(
        code=f"preprocess_data({data})"
    )

    # Step 2: Analyze
    analysis = llm.message(
        model="claude-sonnet-4",
        query=f"Analyze: {preprocessed}"
    )

    # Step 3: Store results
    stored = memory.store(memory=
        memory={
            "content": analysis,
            "source_data": data
        }
    )

    return stored

Best Practices

Single Responsibility: Each action should have one clear purposeError Handling: Always plan for failure scenariosDocumentation: Clearly describe what the action does and expects
Resource Management: Set appropriate timeouts and limitsCaching: Cache expensive operations where appropriateMonitoring: Track action performance and resource usage
Input Validation: Validate all parameters and inputsSecret Management: Use secure methods for sensitive dataAccess Control: Implement appropriate permissions

Action Reference

For complete documentation of all available actions, see: