agents.examples.agentic_generative_ui
Agentic Generative UI example.
Demonstrates an agent that generates UI through plans and steps. The agent creates a plan with multiple steps, and can update individual steps as progress is made.
Features:
- State snapshot events for full plan creation
- State delta events for incremental step updates
- JSON Patch (RFC 6902) for efficient updates
This pattern is useful for:
- Progress tracking
- Multi-step workflows
- Task management
- Project planning
Step Objects
class Step(BaseModel)
A step in a plan.
Plan Objects
class Plan(BaseModel)
A plan with multiple steps.
JSONPatchOp Objects
class JSONPatchOp(BaseModel)
A JSON Patch operation (RFC 6902).
create_plan
@agent.tool_plain
async def create_plan(steps: list[str]) -> StateSnapshotEvent
Create a plan with multiple steps.
This initializes the shared state with a new plan.
Arguments:
steps- List of step descriptions to create the plan.
Returns:
StateSnapshotEvent containing the initial plan state.
update_plan_step
@agent.tool_plain
async def update_plan_step(
index: int,
description: Optional[str] = None,
status: Optional[StepStatus] = None) -> StateDeltaEvent
Update a specific step in the plan.
Uses JSON Patch (RFC 6902) for efficient incremental updates.
Arguments:
index- The index of the step to update (0-based).description- New description for the step (optional).status- New status for the step (optional).
Returns:
StateDeltaEvent containing the JSON Patch operations.