AgentWatchClient
Hold the configuration once, then hand out wrappers from it.
Functionally identical to calling watch() directly — the client just keeps you from repeating apiKey and agentId at every call site, which is also one fewer place for them to drift apart.
import { AgentWatchClient } from '@agentwatch-beta/sdk'
const aw = new AgentWatchClient({
apiKey: 'aw_live_...',
agentId: '<agent-uuid>',
})
const runAgent = aw.watch(myAgentFn)Constructor
Takes the same options object as watch(). Every option set here becomes the default for wrappers produced by this instance.
apiKeystringrequiredYour AgentWatch API key (aw_live_...).
agentIdstringrequiredUUID of the agent registered in your project.
agentInstructionsstringWhat this agent is meant to do — scored against, not just stored.
The rest — metadata, maxPreviewLength, timeoutMs, debug — are documented on Configuration.
Methods
aw.watch(fn)(fn) => typeof fnWraps a function using this client's config. Identical to the standalone watch() with the options already filled in.
aw.trace(payload)(payload) => Promise<TraceResult>Submits one trace directly, for integrations a wrapper cannot reach. Resolves to { accepted, reason } rather than throwing. See Manual traces.
One client per agent
agentId is fixed on the instance, so an app monitoring several agents wants a client each. That is the intended shape: separate agents get separate baselines, and a shared client would file both agents' traces under one of them.
const support = new AgentWatchClient({ apiKey, agentId: SUPPORT_AGENT_ID })
const rag = new AgentWatchClient({ apiKey, agentId: RAG_AGENT_ID })
export const runSupportBot = support.watch(supportBotFn)
export const runRagPipeline = rag.watch(ragPipelineFn)