Options
Listening to flow events
You can listen to flow events by passing onFlowStart and onFlowFinish options to execute function.
const onFlowStart = (flow, context) => { console.log('Flow started', flow.agent.name)}
const onFlowFinish = (flow, result) => { console.log('Flow finished', flow.agent.name, result)}
execute(flow, { onFlowStart, onFlowFinish})Changing default model
You can configure the model for all built-in agents by passing model option to execute function. By default, all built-in agents use gpt-4o model.
import { openai } from '@ai-sdk/openai'
const result = await execute(flow, { agents: { sequenceAgent: myCustomAgent, }, model: openai('gpt-4o')})Overriding built-in agents
If, for some reason, you want to override the built-in agents, you can do so by simply including them in the agents object.
const result = await execute(flow, { agents: { sequenceAgent: myCustomAgent, },})