from upsonic import Agent, Task, DurableExecution
from upsonic.durable import FileDurableStorage
# Create storage backend
storage = FileDurableStorage("./durable_checkpoints")
# Create durable execution
durable = DurableExecution(
storage=storage,
auto_cleanup=False,
debug=True
)
# Create agent and task
agent = Agent("openai/gpt-4o")
task = Task(
description="Process large dataset and generate report",
durable_execution=durable
)
# Execute with checkpointing
result = agent.do(task)
print(f"Execution ID: {task.durable_execution_id}")
print(result)
# If execution fails, resume from checkpoint
# result = agent.continue_durable(
# durable_execution_id=task.durable_execution_id,
# storage=storage
# )