Example: Basic Usage
1
Import the trajectory extension
Import
TrajectoryExtensionServer and TrajectoryExtensionSpec from agentstack_sdk.a2a.extensions.2
Inject the extension
Add a trajectory parameter to your agent function using the
Annotated type hint
with TrajectoryExtensionSpec().3
Yield trajectory metadata
Call
yield trajectory.trajectory_metadata() with a title and content to
add a step to the trajectory.Markdown Support
Thecontent field of trajectory_metadata supports Markdown, which is rendered directly in the UI.
Supported elements include:
- Headers
- Bold and italic text
- Ordered and unordered lists
- Tables
- Code blocks
- Links
- Checklists
Grouping Trajectories
Use thegroup_id parameter to update trajectory content in the UI. Each update replaces the previous content (and title, if defined) for the same group_id: