from erdo import Agent, state
from erdo.actions import llm, memory, utils
from erdo.conditions import IsSuccess, IsError, GreaterThan, TextContains
agent = Agent(name="analysis_agent")
analysis_step = agent.step(
llm.message(
model="claude-sonnet-4",
query=f"Analyze this data: {state.input_data}",
response_format={
"Type": "json_schema",
"Schema": {
"type": "object",
"properties": {
"confidence": {"type": "number"},
"insights": {"type": "array"},
"risk_level": {"type": "string"}
}
}
}
)
)
# Handle successful results
analysis_step.on(
IsSuccess() & GreaterThan("confidence", "0.8"),
memory.store(memory={
"content": analysis_step.output.insights,
"type": "high_confidence_analysis",
"tags": ["analysis", "validated"]
})
)
# Handle errors
analysis_step.on(
IsError(),
utils.send_status(
status="failed",
message=f"Analysis failed: {analysis_step.error.message}"
)
)