create_react_agent
:
thread_id
— a unique identifier for the conversation (session):
checkpointer
allows the agent to store its state at every step in the tool calling loop. This enables short-term memory and human-in-the-loop capabilities.thread_id
to be able to resume the same conversation on future agent invocations.InMemorySaver
).
Note that in the above example, when the agent is invoked the second time with the same thread_id
, the original message history from the first conversation is automatically included, together with the new user input.
For more information, see Memory.
response_format
parameter. The schema can be defined with a Pydantic
model or TypedDict
. The result will be accessible via the structured_response
field.
response_format
is provided, a separate step is added at the end of the agent loop: agent message history is passed to an LLM with structured output to generate a structured response.
To provide a system prompt to this LLM, use a tuple (prompt, schema)
, e.g., response_format=(prompt, WeatherResponse)
.