from upsonic import Agent, Task, DurableExecution
from upsonic.durable import FileDurableStorage
# Create storage
storage = FileDurableStorage("./checkpoints")
# Create durable execution
durable = DurableExecution(storage=storage)
# Create agent and task
agent = Agent("openai/gpt-4o")
task = Task(
description="Analyze quarterly financial reports",
durable_execution=durable
)
# Execute with automatic checkpointing
try:
result = agent.do(task)
print(result)
except Exception as e:
# Resume from checkpoint
result = agent.continue_durable(
durable_execution_id=task.durable_execution_id,
storage=storage
)
print(result)