.invoke()
/ await .ainvoke()
for full responses, or .stream()
/ .astream()
for incremental streaming output. This section explains how to provide input, interpret output, enable streaming, and control execution limits.
.invoke()
or .stream()
await .ainvoke()
or async for
with .astream()
messages
as an input. Therefore, agent inputs and outputs are stored as a list of messages
under the messages
key in the agent state.
messages
key. Supported formats are:
Format | Example |
---|---|
String | {"messages": "Hello"} — Interpreted as a HumanMessage |
Message dictionary | {"messages": {"role": "user", "content": "Hello"}} |
List of messages | {"messages": [{"role": "user", "content": "Hello"}]} |
With custom state | {"messages": [{"role": "user", "content": "Hello"}], "user_name": "Alice"} — If using a custom state_schema |
messages
is converted to a HumanMessage. This behavior differs from the prompt
parameter in create_react_agent
, which is interpreted as a SystemMessage when passed as a string.messages
: A list of all messages exchanged during execution (user input, assistant replies, tool invocations).structured_response
if structured output is configured.state_schema
, additional keys corresponding to your defined fields may also be present in the output. These can hold updated state values from tool execution or prompt logic.GraphRecursionError
. You can configure recursion_limit
at runtime or when defining agent via .with_config()
: