runTask
Runs a multi-step, tool-use loop: the platform calls the model, executes the tool calls it requests, and feeds the results back until the output matches outputSchema, validated and repaired on every turn. A run that cannot converge on a valid shape rejects rather than returning malformed output. It runs slowly, so most callers invoke it without awaiting and write the result back when it resolves; cron and email triggers await it instead, since no session is left to catch a later failure. Give it a capable model and a tight schema, since both shape how well it stays on task. Each tool result is capped at maxToolOutputChars (50,000 characters of JSON by default); past the cap, the model gets a truncation record instead. Results are resent every turn, so a tool that pages or summarizes works better than a higher cap.
const result = await mindstudio.runTask({ prompt: 'Research this restaurant and save it. Write in a warm, plain voice.', input: { name }, tools: [ 'searchGoogle', // SDK action { method: 'generateImage', defaults: { imageModelOverride: { model: 'seedream-4.5' } } }, { appMethod: 'saveRestaurant', description: 'Persist the researched restaurant, once, at the end.' }, { name: 'checkExisting', description: 'Look up whether we already track this name.', inputSchema: { type: 'object', properties: { name: { type: 'string' } }, required: ['name'] }, execute: async (i) => Restaurants.findByName(String(i.name)) }, ], outputSchema: { type: 'object', properties: { name: { type: 'string' }, url: { type: ['string', 'null'] }, photoUrl: { type: 'string' } }, required: ['name', 'url', 'photoUrl'], }, model: 'claude-5-sonnet', }); result.output.name; // typed from the schema