Agents SDK
Build agent graphs on top of your BeforeQuery knowledge base
What is Agents SDK?
The @beforequery/agents SDK is an open-source TypeScript library for building agent graphs — coordinator and specialist agent structures that can call BeforeQuery's search, MCP server, and external tools. It works in Node.js and edge runtimes and is MIT licensed.
How BeforeQuery works with Agents SDK
Everything you can do once the integration is connected.
defineAgent and runAgent primitives
Define agent graphs with typed inputs and outputs using defineAgent. Execute them with runAgent, which handles LLM orchestration, tool calls, and human approval pauses.
Built-in MCP and A2A clients
The SDK ships with mcpClient (for connecting to BeforeQuery's MCP server or any MCP endpoint) and a2aClient (for agent-to-agent communication following the A2A protocol).
Human approval integration
Pause agent execution pending human review. The approval queue in the BeforeQuery dashboard surfaces pending decisions, and the SDK resumes execution after approval or rejection.
Observability and tracing
Every agent run is traced in BeforeQuery's observability dashboard. Inspect LLM calls, tool invocations, latency, and costs per agent step.
How to set it up
Install: npm install @beforequery/agents
Define an agent graph using defineAgent, specifying specialist agents, their tools, and the coordinator logic.
Run the agent with runAgent, passing your BeforeQuery API key. Agent traces appear in the BeforeQuery dashboard automatically.
Related integrations
The BeforeQuery web widget embeds in any HTML page. One script tag, full style customization, mobile-ready, WCAG AA accessible.
Install @beforequery/react for a <BeforeQueryChat /> drop-in or the useBeforeQueryChat headless hook for a fully custom UI.
@beforequery/sdk works in Vue, Svelte, React Native, vanilla JS, and Node.js — a single API for search and chat.
Ready to connect Agents SDK?
Start free. No credit card required. Connect your first integration in under 5 minutes.