createReactAgent
:
tool
function. For more advanced tool usage and customization, check the tools page.thread_id
— a unique identifier for the conversation (session):
checkpointSaver
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.MemorySaver
).
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.
responseFormat
parameter. The schema can be defined with a Zod
schema. The result will be accessible via the structuredResponse
field.
responseFormat
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 an object { prompt, schema }
, e.g., responseFormat: { prompt, schema: WeatherResponse }
.