Headlessly
Platform

Agent

AI agents with model configuration, tool access, memory, and usage tracking for autonomous operations.

Schema

import { Noun } from 'digital-objects'

export const Agent = Noun('Agent', {
  name: 'string!',
  slug: 'string##',
  description: 'string',
  avatar: 'string',
  organization: '-> Organization',
  owner: '-> Contact',
  model: 'string',
  systemPrompt: 'string',
  instructions: 'string',
  persona: 'string',
  type: 'Assistant | Autonomous | Workflow | Specialist | Router',
  status: 'Draft | Active | Deployed | Paused | Stopped | Retired | Archived',
  visibility: 'Private | Team | Organization | Public',
  temperature: 'number',
  maxTokens: 'number',
  tools: 'json',
  functions: 'json',
  knowledgeBases: 'json',
  memory: 'None | Session | Persistent',
  memoryWindow: 'number',
  totalTokens: 'number',
  totalCost: 'number',
  averageLatency: 'number',
  successRate: 'number',
  rating: 'number',
  ratingCount: 'number',
  version: 'number',
  publishedAt: 'datetime',
  tags: 'string',
  do: 'Done',
  ask: 'Asked',
  decide: 'Decided',
  approve: 'Approved',
  notify: 'Notified',
  delegate: 'Delegated',
  escalate: 'Escalated',
  learn: 'Learned',
  reflect: 'Reflected',
  invoke: 'Invoked',
  deploy: 'Deployed',
  pause: 'Paused',
  stop: 'Stopped',
  retire: 'Retired',
})

Fields

FieldTypeRequiredDescription
namestringYesDisplay name of the agent
slugstring (unique, indexed)NoURL-safe identifier (e.g. onboarding-agent, support-bot)
descriptionstringNoWhat this agent does and its area of expertise
avatarstringNoURL to the agent's avatar image
organization-> OrganizationNoOrganization that owns this agent
owner-> ContactNoPerson responsible for this agent
modelstringNoLLM model identifier (e.g. claude-opus-4-6, gpt-4o)
systemPromptstringNoSystem prompt that defines the agent's core behavior
instructionsstringNoAdditional instructions appended to conversations
personastringNoPersonality and communication style description
typeenumNoAssistant, Autonomous, Workflow, Specialist, or Router
statusenumNoDraft, Active, Deployed, Paused, Stopped, Retired, or Archived
visibilityenumNoPrivate, Team, Organization, or Public
temperaturenumberNoLLM temperature setting (0-2)
maxTokensnumberNoMaximum tokens per response
toolsjsonNoArray of MCP tools the agent can use
functionsjsonNoCustom function definitions the agent can call
knowledgeBasesjsonNoArray of knowledge base references for RAG
memoryenumNoNone, Session, or Persistent
memoryWindownumberNoNumber of previous messages to include in context
totalTokensnumberNoCumulative token usage across all invocations
totalCostnumberNoCumulative cost in USD
averageLatencynumberNoAverage response time in milliseconds
successRatenumberNoPercentage of successful invocations (0-100)
ratingnumberNoAverage user rating (0-5)
ratingCountnumberNoNumber of ratings received
versionnumberNoVersion number, incremented on configuration changes
publishedAtdatetimeNoWhen the agent was first published
tagsstringNoComma-separated tags for categorization

Relationships

FieldDirectionTargetDescription
organization->OrganizationThe organization that owns this agent
owner->ContactThe person responsible for maintaining this agent

Verbs

VerbEventDescription
createCreatedCreate a new agent
updateUpdatedUpdate agent configuration
deleteDeletedDelete an agent
doDoneExecute a task autonomously
askAskedAsk the agent a question and receive a response
decideDecidedRequest the agent to make a decision
approveApprovedAgent approves a pending action
notifyNotifiedSend a notification through the agent
delegateDelegatedDelegate a task to another agent or human
escalateEscalatedEscalate an issue to a human or higher-authority agent
learnLearnedIncorporate new knowledge from feedback or data
reflectReflectedAnalyze past actions and adjust behavior
invokeInvokedInvoke the agent programmatically from a workflow
deployDeployedDeploy the agent to production
pausePausedTemporarily suspend the agent
stopStoppedPermanently stop the agent
retireRetiredRetire the agent, marking it as end-of-life

Verb Lifecycle

import { Agent } from '@headlessly/platform'

// BEFORE hook -- validate before deployment
Agent.deploying(agent => {
  if (!agent.systemPrompt) {
    throw new Error('System prompt required before deployment')
  }
  if (!agent.tools || agent.tools.length === 0) {
    throw new Error('At least one tool must be configured')
  }
})

// Execute -- deploy the agent
await Agent.deploy('agent_mR4nVkTw')

// AFTER hook -- notify and track
Agent.deployed((agent, $) => {
  $.Event.create({
    type: 'agent.deployed',
    data: {
      agent: agent.$id,
      model: agent.model,
      type: agent.type,
      version: agent.version,
    },
  })
  $.Activity.create({
    subject: `Agent deployed: ${agent.name}`,
    type: 'Task',
    contact: agent.owner,
    status: 'Completed',
  })
})

Status State Machine

Draft --> Active --> Deployed --> Paused --> Deployed
                        |            |
                        v            v
                     Stopped     Stopped
                        |            |
                        v            v
                     Retired --> Archived
  • Draft: Agent is being configured, not yet ready
  • Active: Configuration complete, ready for deployment
  • Deployed: Running in production, handling requests
  • Paused: Temporarily suspended, not handling requests
  • Stopped: Permanently halted, configuration preserved
  • Retired: End-of-life, replaced by a newer version
  • Archived: Historical record, fully decommissioned

Agent Types

TypeDescriptionUse Case
AssistantInteractive agent that responds to questionsSupport chatbot, internal help desk
AutonomousSelf-directed agent that operates without promptingBackground monitoring, data enrichment
WorkflowTriggered by events, executes predefined stepsLead qualification, onboarding sequences
SpecialistDeep expertise in a single domainContract review, code analysis, financial modeling
RouterRoutes requests to the appropriate specialist agentTriage agent, intent classification

Cross-Domain Patterns

Agent is the autonomous operations layer that can interact with every domain:

  • CRM: Agents qualify leads, enrich contacts, and progress deals autonomously. A sales agent can score leads, draft outreach, and schedule follow-ups.
  • Billing: Agents monitor subscription health, flag at-risk accounts, and suggest upsells based on usage patterns.
  • Support: Agents handle first-line support, classify tickets, draft responses, and escalate complex issues to humans.
  • Content: Agents generate drafts, optimize copy, and manage content calendars.
  • Marketing: Agents segment audiences, personalize campaigns, and analyze campaign performance.
  • Experimentation: Agents run prompt experiments to optimize their own behavior.
  • Platform: Agents can invoke other agents (delegation), trigger workflows, and manage integrations.
import { Agent } from '@headlessly/platform'

// When an agent escalates, create a ticket
Agent.escalated((agent, $) => {
  $.Ticket.create({
    subject: `Escalation from ${agent.name}`,
    description: 'Agent could not resolve this issue autonomously',
    priority: 'High',
    status: 'Open',
  })
})

// When an agent learns from feedback, log the improvement
Agent.learned((agent, $) => {
  $.Event.create({
    type: 'agent.learned',
    data: {
      agent: agent.$id,
      successRate: agent.successRate,
      rating: agent.rating,
    },
  })
})

// Delegation pattern -- router agent delegates to specialists
Agent.delegated((router, $) => {
  $.Event.create({
    type: 'agent.delegated',
    data: {
      from: router.$id,
      reason: 'Routing to domain specialist',
    },
  })
})

Query Examples

SDK

import { Agent } from '@headlessly/platform'

// Find all deployed agents
const deployed = await Agent.find({ status: 'Deployed' })

// Get a specific agent
const agent = await Agent.get('agent_mR4nVkTw')

// Create a support agent
const supportAgent = await Agent.create({
  name: 'Support Agent',
  slug: 'support-agent',
  type: 'Specialist',
  model: 'claude-opus-4-6',
  systemPrompt: 'You are a customer support agent for headless.ly. Help users with setup, billing, and technical questions.',
  tools: ['search', 'fetch', 'do'],
  memory: 'Session',
  memoryWindow: 20,
  visibility: 'Organization',
})
await Agent.deploy(supportAgent.$id)

// Ask the agent a question
await Agent.ask('agent_mR4nVkTw', {
  message: 'How do I set up Stripe integration?',
})

// Check agent health metrics
const agents = await Agent.find({ status: 'Deployed' })
for (const a of agents) {
  console.log(`${a.name}: ${a.successRate}% success, ${a.averageLatency}ms avg latency, $${a.totalCost} total cost`)
}

MCP

headless.ly/mcp#search
{
  "type": "Agent",
  "filter": { "status": "Deployed", "type": "Specialist" },
  "sort": { "successRate": "desc" },
  "limit": 10
}
headless.ly/mcp#fetch
{ "type": "Agent", "id": "agent_mR4nVkTw" }
headless.ly/mcp#do
const agents = await $.Agent.find({ status: 'Deployed' })
await $.Agent.invoke('agent_mR4nVkTw')
await $.Agent.pause('agent_mR4nVkTw')

REST

# List deployed agents
curl https://automate.headless.ly/~acme/agents?status=Deployed

# Get a specific agent
curl https://automate.headless.ly/~acme/agents/agent_mR4nVkTw

# Create an agent
curl -X POST https://automate.headless.ly/~acme/agents \
  -H 'Content-Type: application/json' \
  -d '{"name": "Support Agent", "type": "Specialist", "model": "claude-opus-4-6"}'

# Deploy an agent
curl -X POST https://automate.headless.ly/~acme/agents/agent_mR4nVkTw/deploy

# Invoke an agent
curl -X POST https://automate.headless.ly/~acme/agents/agent_mR4nVkTw/invoke

# Pause an agent
curl -X POST https://automate.headless.ly/~acme/agents/agent_mR4nVkTw/pause

# Retire an agent
curl -X POST https://automate.headless.ly/~acme/agents/agent_mR4nVkTw/retire

On this page