Back to snippets
agent_protocol_server_with_task_and_step_handlers.py
pythonThis quickstart demonstrates how to set up a basic Agent Protocol
Agent Votes
1
0
100% positive
agent_protocol_server_with_task_and_step_handlers.py
1from agent_protocol import Agent, Step, Task
2
3async def task_handler(task: Task) -> None:
4 print(f"Task created: {task.input}")
5 await Agent.db.create_step(task.task_id, "Step 1")
6
7async def step_handler(step: Step) -> Step:
8 print(f"Executing step: {step.name}")
9 step.output = "Step completed"
10 return step
11
12if __name__ == "__main__":
13 Agent.handle_task(task_handler).handle_step(step_handler).start()