Standards Docs
Guides

AI Agents

Create an agent definition, attach tools, and trigger it from the UI.

This guide walks through creating an agent definition, attaching tools, and triggering it from the UI.

AI provider env vars

  • ANTHROPIC_API_KEY — required for Claude models (anthropic provider)
  • OPENAI_API_KEY — required for OpenAI models (openai provider)

Supported providers: anthropic, openai, google, mistral.

Define an agent

An agent definition stores its name, system prompt, model, and the list of tools it can call. Use useCreateAgentDefinition from @stndrds/react to create one from the UI.

// @noverify
import { useCreateAgentDefinition } from "@stndrds/react";

function NewAgent() {
  const create = useCreateAgentDefinition();
  return (
    <button
      onClick={() =>
        create.mutate({
          name: "support-triage",
          systemPrompt: "You triage incoming support requests…",
          model: { provider: "anthropic", model: "claude-3-5-sonnet" },
          tools: ["search_contacts", "create_note"],
        })
      }
    >
      Create
    </button>
  );
}

model is an object { provider, model } — not a plain string. The tools array lists tool names by identifier.

Optional fields: description, icon, config (execution settings), schedule (cron), canDelegate, maxDepth, maxTreeCostUsd.

Tools

Tools are typed functions registered in the agent runtime. The agent calls them with typed inputs; the runtime validates arguments and routes calls through standards' adapters. You register tools server-side — the tools array in the definition references them by name. Tools can read records, call external APIs, create notes, or trigger other agents.

Trigger

You can start an agent session in three ways:

  • UI button — call useCreateAgentSession with the definition ID and any initial message.
  • Webhook — POST to the agent session endpoint from an external system.
  • Record event — attach an AgentTrigger to an object so the agent fires automatically when records are created or updated.
// @noverify
import { useCreateAgentSession } from "@stndrds/react";

function RunAgent({ definitionId }: { definitionId: string }) {
  const create = useCreateAgentSession();
  return (
    <button
      onClick={() =>
        create.mutate({
          agentDefinitionId: definitionId,
          mode: "autonomous",
        })
      }
    >
      Run
    </button>
  );
}

Never set tool-call limits on spawned subagents — let them run to natural completion.

Background agents are opt-in. The agents block on SchemaModule.forRoot must be set explicitly (agents: { enabled: true, ... }) and BullMQ/Redis must be wired — otherwise the module stays disabled to avoid a startup crash when Redis is missing.

On this page