The Agent Platform SDK enables you to use advanced features to execute complex workflows, such as running batch operations as well as selecting and using specific agents.
Batch operations
The Agent Platform SDK enables you to run multiple tasks simultaneously in very few steps.
Use the following command to configure multiple tasks:
const tasks = await agent.runBatch([
{ objective: 'Check weather for New York', startUrl: 'https://weather.com' },
{ objective: 'Get latest Bitcoin price', startUrl: 'https://coinbase.com' },
{ objective: 'Find top 3 TypeScript articles', startUrl: 'https://dev.to' }
]);
Keep in mind, running parallel actions works best for lightweight, independent actions. We recommend avoiding tasks that are overly complicated or intersect too much when running batch operations using the Agent Platform JavaScript SDK platform.
Step 2: Wait for completion
It may take a few moments for the task to complete.
await agent.waitForAllComplete(tasks);
console.log('All tasks completed!');
Step 3: View task results (Optional)
You can view task results by monitoring events.
tasks.forEach((task) => {
// Track status changes
task.onStatusChange((status) => {
console.log(`Task ${task.id} status:`, status);
});
// Track chat messages
task.onChatMessage((message) => {
console.log(`Task ${task.id} message:`, message.data.content);
});
// Track web actions
task.onWebAction((action) => {
console.log(`Task ${task.id} action:`, action.data.action.action_type);
});
// Track errors
task.onError((error) => {
console.error(`Task ${task.id} error:`, error);
});
});