Skip to main content
The agent definition file. Must export a default ToolLoopAgent and optionally accepts for payment gating and capabilities for A2A agent card configuration.
app/agent.ts
import { openai } from "@ai-sdk/openai";
import { stepCountIs, ToolLoopAgent } from "ai";
import type { Accepts } from "aixyz/accepts";
import type { Capabilities } from "aixyz/app/plugins/a2a";
import weather from "./tools/weather";

export const accepts: Accepts = {
  scheme: "exact",
  price: "$0.005",
};

export const capabilities: Capabilities = {
  streaming: false,
  pushNotifications: false,
};

export default new ToolLoopAgent({
  model: openai("gpt-4o-mini"),
  instructions: "You are a helpful weather assistant.",
  tools: { weather },
  stopWhen: stepCountIs(10),
});

Exports

ExportTypeRequiredDescription
defaultToolLoopAgentYesThe agent instance
acceptsAcceptsNoPayment config — gates the A2A /agent route
capabilitiesCapabilitiesNoA2A capabilities — controls streaming and push notification support
When accepts is exported, the /agent endpoint requires x402 payment. Without it, the agent is not registered on the A2A endpoint. accepts can also be an array of payment entries for multi-network support.

Capabilities

The optional capabilities export controls the A2A agent card’s capabilities field and the executor’s behavior:
import type { Capabilities } from "aixyz/app/plugins/a2a";

export const capabilities: Capabilities = {
  streaming: false, // default: true
  pushNotifications: false, // default: false
  stateTransitionHistory: false, // default: undefined
};
FieldTypeDefaultDescription
streamingbooleantrueWhether the agent streams responses via textStream
pushNotificationsbooleanfalseWhether the agent supports push notifications
stateTransitionHistorybooleanundefinedWhether the agent exposes state transition history
When streaming is set to false, the executor uses agent.generate() instead of agent.stream(), returning the full response as a single artifact rather than streaming chunks. This is useful for agents backed by models or APIs that don’t support streaming.