Properties
When initialized, returns a number of properties to check, update, and manage the state.
The main one is newRequest
function that’s used instead of agent.run
to run the agent…
it takes the same arguments and provides better state management.
Props
Used to send a new message to the agent or run it. works the same way as agent.run.
Returns AgentResponse or undefined
in case of errors. notice that the
onError
was made to be used with this to capture any errors.
If the agent is working and you call the newRequest
before it finishes, it will wait until the previous run is finished before processing the new one.
A list of previous messages in the current session.
Used for streaming. while the agent is generating tokens and calling tools, this will contain the agent response while it gets updated in real-time.
When the agent is not working this will be undefined
.
Please see this page to understand how it works.
Wether the agent is generating tokens or not (working or idle).
Wether the agent is loading (started the run but still did not start to generate tokens).
The agent status, if the agent is idle it’s undefined
, if loading it’s "Thinking"
, or if it’s
calling a tool it’s "Talking with <TOOL_NAME>"
.
You can use this to display the agent status directly to the end user.
The current session ID.
Change the session. just provide another session ID, and it will load its history and update the state.
When you provide a session_id
in initialization or call changeSession
, We need to load the session history (messages),
and while the session history is loading this will be set to true
, otherwise it’s false
.
Was this page helpful?