-
Notifications
You must be signed in to change notification settings - Fork 0
TanStack AI Integration
Christian Pojoni edited this page May 2, 2026
·
1 revision
The package exposes routing and worker execution as TanStack AI server tools.
import {
createSubagentRouter,
createSubagentRouterTool,
} from '@5queezer/tanstack-ai-subagents'
const route = createSubagentRouter({
intents: {
incident: ['incident', 'outage', 'sev1'],
},
})
export const routeTool = createSubagentRouterTool({ router: route })Without a custom router, createSubagentRouterTool() uses the default deterministic router.
import { chat } from '@tanstack/ai'
import { createRunSubagentsTool } from '@5queezer/tanstack-ai-subagents'
export const runTool = createRunSubagentsTool({
chat,
getAdapter: getChatModel,
tools,
profiles,
maxWorkers: 4,
})run_subagents only executes when the routing action allows it:
spawn_one_specialistspawn_multiple_specialists
Other actions are rejected before worker execution.
The package does not ship concrete worker tools. Your app owns the tool registry.
const tools = {
github_search: githubSearch,
github_get: githubGet,
test_runner: testRunner,
}Worker briefs reference tools by name. If a worker asks for a missing or nullish tool implementation, validation fails before the worker runs.
Profiles define reusable worker capabilities.
const profiles = {
verify: {
toolNames: ['test_runner'],
systemPrompt: 'Verify the assigned task and report exact commands and evidence.',
model: 'provider/verification-model',
},
}A worker can use profile: 'verify' instead of listing toolNames directly.
-
spawn_one_specialistrequires exactly one worker. -
spawn_multiple_specialistsrequires at least two workers. - Default maximum: four workers.
- Override with
maxWorkers.
createRunSubagentsTool({
chat,
getAdapter,
tools,
maxWorkers: 8,
})Lifecycle callbacks are observability hooks. Callback failures are ignored so they cannot change worker outcomes.
createRunSubagentsTool({
chat,
getAdapter,
tools,
onWorkerStart: (brief) => logStart(brief),
onWorkerFail: (brief, error) => logFailure(brief, error),
onWorkerFinish: (result, brief) => logFinish(brief, result),
})