RunContext is an object that can be referenced in pre- and post-hooks, tools, and other parts of the run.
See Agent State for examples of how to use the RunContext in your code.
RunContext Attributes
| Attribute | Type | Description |
|---|---|---|
run_id | str | Run ID |
session_id | str | Session ID for the run |
user_id | Optional[str] | User ID associated with the run |
workflow_id | Optional[str] | ID of the workflow this run belongs to, when executed inside a workflow |
workflow_name | Optional[str] | Name of the workflow this run belongs to, when executed inside a workflow |
dependencies | Optional[Dict[str, Any]] | Dependencies for the run |
knowledge_filters | Optional[Union[Dict[str, Any], List[FilterExpr]]] | Knowledge filters for the run |
metadata | Optional[Dict[str, Any]] | Metadata associated with the run |
session_state | Optional[Dict[str, Any]] | Session state for the run |
output_schema | Optional[Union[Type[BaseModel], Dict[str, Any]]] | Output schema for the run, as a Pydantic model or JSON schema dict |
messages | Optional[List[Message]] | Live reference to the current run’s message list. Hooks receive a shallow copy; individual Message objects are shared references |
tools | Optional[List[Any]] | Tools resolved for the run, including results of callable tool factories |
knowledge | Optional[Any] | Knowledge instance resolved for the run |
members | Optional[List[Any]] | Team members resolved for the run |
client_tools | Optional[List[Any]] | Per-run additive tools from the client (e.g. AG-UI frontend tools). Merged after agent.tools during tool resolution |