AI agents
Run a bounded support agent with replay-safe model and tool work.
Runlane can coordinate an AI support agent inside a TypeScript task. The agent can search product documentation, request approval before a refund, and return a typed response. Your application supplies the model, tools, credentials, approval policy, and conversation state.
Run one durable support turn
The Runlane calls below are real. The marked runSupportAgent() call is pseudocode for your model and tool implementation:
import { task } from '@runlane/core'
import * as z from 'zod'
const messageSchema = z.object({
content: z.string(),
role: z.enum(['assistant', 'user']),
})
const supportResultSchema = z.object({
reply: z.string(),
toolCalls: z.array(z.enum(['refundOrder', 'searchDocs'])),
})
export const supportAgent = task({
id: 'agent.support',
schema: z.object({ messages: z.array(messageSchema).min(1).max(50) }),
output: supportResultSchema,
retry: { maxAttempts: 3 },
async run({ messages }, context) {
return context.step.run('support-turn', { output: supportResultSchema }, async ({ token }) => {
//////////////////////////////////
// MAKE YOUR API CALLS HERE
//////////////////////////////////
const result = await runSupportAgent({
approvalRequiredFor: ['refundOrder'],
idempotencyKey: token,
messages,
signal: context.signal,
tools: ['refundOrder', 'searchDocs'],
})
return supportResultSchema.parse(result)
})
},
})The durable step stores the completed support turn. If a later attempt reaches the same step, Runlane returns the stored result instead of intentionally running the agent again. Pass the step token to providers that support idempotency.
approvalRequiredFor describes a tool policy owned by your agent integration; it is not a Runlane API. Use a wait token when approval should end the current attempt and resume the run later.
Choose the right task shape
| Pattern | Runlane approach | Limit |
|---|---|---|
| Support turn | Save one bounded turn as a durable step | The step replays as one unit |
| Prompt chain | Use one validated step per stage | Changing a step key creates new work |
| Parallel calls | Use Promise.all() inside one attempt | It is not a durable child-run join |
| Tool loop | Use stable step keys for costly calls | Cap turns, cost, and tool calls |
| Human review | Wait on a durable token | Your app owns authentication and the review UI |
Runlane does not include an agent SDK, prompt store, chat session, or live frontend stream. A long in-memory loop holds a worker slot.
Before production
- Put model rate limits on a bounded queue.
- Keep secrets and full conversations outside run metadata.
- Validate every saved model or tool result.
- Require authorization before tools perform sensitive actions.
- Test a retry after a completed step and confirm the provider is not called again.
Read save step results, limit concurrency, and human in the loop.