packages/ai-harness
| Name | Last commit message | Last commit date |
|---|---|---|
| .. | ||
README.md
@tanstack/ai-harness#
Build agent harnesses on TanStack AI: long-lived sessions, typed agents, and plugins.
Warning
The harness is experimental. @tanstack/ai-harness and @tanstack/ai-harness-cli are on 0.x, and a minor release can change the API. Pin the exact version you install.
chat() answers one request. A harness keeps one conversation open across many turns. It takes new messages while it works, runs typed agents from code, and loads plugins that add tools, prompts, and middleware.
Installation#
npm install @tanstack/ai @tanstack/ai-harness @tanstack/ai-persistence @tanstack/ai-openai zod
Usage#
import { defineAgent } from '@tanstack/ai'
import { createHarnessHost, defineHarness } from '@tanstack/ai-harness'
import { memoryPersistence } from '@tanstack/ai-persistence'
import { openaiText } from '@tanstack/ai-openai'
import { z } from 'zod'
const pricer = defineAgent({
name: 'pricer',
description: 'Looks up the price of a vendor plan',
inputSchema: z.object({ vendor: z.string() }),
run: async (ctx) => ({ vendor: ctx.input.vendor, cents: 1200 }),
})
const assistant = defineHarness({
name: 'acme/assistant',
adapter: openaiText('gpt-6.1-sol'),
agents: [pricer],
})
const host = createHarnessHost({ persistence: memoryPersistence() })
const session = await host.open(assistant, { threadId: 'thread-1' })
const turn = await session.send('Hello!')
console.log(turn.text)
const price = await session.agents.pricer.run({ vendor: 'acme' })
console.log(price.cents)
Documentation#
Read Build your first harness.
License#
MIT