AgentBuilder, AgentExecutor, ToolRegistry and
resumeAfterApproval(): the lower-level API the SDK started with. Those exports keep
working and this page does not remove them; if you stay on them, see
The executor API. The reason to move is that one
createAgent() call wires tools, stores, approvals, sessions, retries and
compaction, where the executor makes you assemble each of them and pass them to every
call.
createAgent() does not take every option the executor takes yet; see
What createAgent() does not take yet before you
start.
Before and after
One agent with a tool that needs approval, first with the executor API, then withcreateAgent(). Both use a scripted model, so they run offline and end with the same
text, Sent the report to Sam., after the same pause.
defineTool() result in both. The agent keeps its own registry,
approval store and provider, so deciding the pause needs only the approval id.
Mapping
What createAgent() does not take yet
TheseExecuteOptions have no createAgent() option. Where there is a supported
alternative it is named; otherwise keep that call on AgentExecutor.execute().
A run uses one API or the other: an agent that needs one of the “None” rows keeps that
call on the executor, and can use
createAgent() for the rest of the code.
Behavior differences
send()is one turn. A conversation is a separate object,agent.session(), which keeps the transcript and sends it with each turn; see Sessions. Code that built a message history by hand moves to a session.- A paused run resolves. A
send()that reaches aneedsApprovaltool resolves withfinishReason: 'awaiting-approval'and anapprovalId; it does not throw. The pause stays with the agent, soagent.approvals.list()shows it andresolve()continues it without the registry or provider. - The default approval store is per agent and in memory. A pause survives a restart only
with a durable
storeorapprovalStore; see Choosing a store. - Retries are on by default for a
modelstring: two retries of a failed model call. Aproviderinstance you pass is not wrapped unless you setretry. See Provider retries and fallback.
Migrating step by step
- Tools first. Keep the
defineTool()tools; drop theToolRegistryand anyaddTool(key, config)call, and list the tools intools. - Replace
AgentBuilderwithcreateAgent({ name, instructions, tools }), and passmodelor theprovideryou already pass toexecute(). - Replace each
AgentExecutor.execute()withagent.send()and eachstream()withagent.stream(). MovemaxSteps,limitsand the other shared options tocreateAgent(). Keep a call on the executor if it needs an option from the “does not take yet” list. - Replace
resumeAfterApproval()withagent.approvals.resolve(). If approvals must outlive the process, pass the store you used asapprovalStore. - Move
checkpointStoreand itssessionIdtostore, and passsessionIdtosend(). Useagent.session()where you kept a history yourself. - Replace
onEventwithExecutionEventby anAgentEventlistener, then moveHookRegistryhooks intohooks.