Agent APIs
The canonical APIs for finite, persistent, and provider-backed TechFabric Harness agents.
TechFabric Harness has one public builder for each agent lifecycle:
| Lifecycle | API |
|---|---|
| Finite, run-once agent | defineAgent({ ... }) |
| Persistent, addressable agent | createAgent(AgentFunction, staticConfig?) |
| Databricks-backed finite agent | defineDatabricksAgent({ ... }) |
| Azure-backed finite agent | defineAzureAgent({ ... }) |
| Cloudflare-backed finite agent | defineCloudflareAgent({ ... }) |
Finite definitions receive the typed AgentRunContext with lazy session, prompt, skill,
task, shell, and invoke helpers.
import { defineAgent } from '@fabric-harness/sdk';
export default defineAgent<{ question: string }, string>({
run: ({ input, prompt }) => prompt(input.question),
});Persistent definitions use a synchronous function and hooks. The returned string is the current instruction; static policy and durability remain visible to the host before the function renders.
import { createAgent, useModel, useSandbox } from '@fabric-harness/sdk';
function Assistant() {
useModel('anthropic/claude-sonnet-4-6');
useSandbox('virtual');
return 'Resolve the request, verify the answer, and explain the next step.';
}
export default createAgent(Assistant, {
durability: { maxAttempts: 5, timeoutMs: 60 * 60_000 },
});Provider definers accept typed custom control flow and inject their resolved bundle.
import { defineDatabricksAgent } from '@fabric-harness/databricks';
export default defineDatabricksAgent<{ question: string }, string>({
run: async ({ databricks, input, prompt }) => {
console.log(`Using ${databricks.tools.length} governed Databricks tools`);
return prompt(input.question);
},
});Omitting run uses the provider definer's question-and-answer behavior. Explicit provider configuration is
resolved first; otherwise the definer uses request environment variables and supports
FABRIC_MOCK=1. Definition tools override same-named bundle tools, policies compose as security
floors, and all standard definition fields, including target, subscriptions, middleware, and
init, are forwarded consistently.
Provider bundle factories remain separate and composable. Use databricks(), azure(),
cloudflare(), node(), docker(), or another backend factory when you want to assemble the
runtime yourself. pnpm examples:check prevents removed aliases from returning to public examples
or scaffolds, and smoke-tests a freshly packed fh init --model mock/test-model --store memory
scaffold: the generated project's own npm run run must return a mock response with no --mock
flag (the gate skips cleanly when the npm registry is unreachable).