after_model(
func: _CallableWithStateAndRuntime[StateT, ContextT] | None = None,
*,
state_schema: type| Name | Type | Description |
|---|---|---|
func | _CallableWithStateAndRuntime[StateT, ContextT] | None | Default: NoneThe function to be decorated. Must accept: |
state_schema | type[StateT] | None | Default: NoneOptional custom state schema type. If not provided, uses the default |
tools | list[BaseTool] | None | Default: None |
can_jump_to | list[JumpTo] | None | Default: None |
name | str | None | Default: None |
Decorator used to dynamically create a middleware with the after_model hook.
The decorated function should return:
dict[str, Any] - State updates to merge into the agent stateCommand - A command to control flow (e.g., jump to different node)None - No state updates or flow controlOptional list of additional tools to register with this middleware.
Optional list of valid jump destinations for conditional edges.
Valid values are: 'tools', 'model', 'end'
Optional name for the generated middleware class.
If not provided, uses the decorated function's name.