checkpointer
when creating an agent.
AgentState
to manage short term memory, specifically the conversation history via a messages
key.
Users can subclass AgentState
to add additional fields to the state.
This custom state can then be accessed via tools and dynamic prompt / model functions.
strategy
(e.g., keep the last maxTokens
) to use for handling the boundary.
To trim message history in an agent, use stateModifier
with the trimMessages
function:
RemoveMessage
. For RemoveMessage
to work, you need to use a state key with messagesStateReducer
reducer, like MessagesZodState
.
To remove specific messages:
user
messageassistant
messages with tool calls to be followed by corresponding tool
result messages.InjectedState
annotation.
This annotation hides the state from the tool signature (so the model doesn’t see it), but the tool can access it.