Platform
Agent AI agents with model configuration, tool access, memory, and usage tracking for autonomous operations.
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' ,
})
Field Type Required Description namestring Yes Display name of the agent slugstring (unique, indexed) No URL-safe identifier (e.g. onboarding-agent, support-bot) descriptionstring No What this agent does and its area of expertise avatarstring No URL to the agent's avatar image organization-> Organization No Organization that owns this agent owner-> Contact No Person responsible for this agent modelstring No LLM model identifier (e.g. claude-opus-4-6, gpt-4o) systemPromptstring No System prompt that defines the agent's core behavior instructionsstring No Additional instructions appended to conversations personastring No Personality and communication style description typeenum No Assistant, Autonomous, Workflow, Specialist, or Router statusenum No Draft, Active, Deployed, Paused, Stopped, Retired, or Archived visibilityenum No Private, Team, Organization, or Public temperaturenumber No LLM temperature setting (0-2) maxTokensnumber No Maximum tokens per response toolsjson No Array of MCP tools the agent can use functionsjson No Custom function definitions the agent can call knowledgeBasesjson No Array of knowledge base references for RAG memoryenum No None, Session, or Persistent memoryWindownumber No Number of previous messages to include in context totalTokensnumber No Cumulative token usage across all invocations totalCostnumber No Cumulative cost in USD averageLatencynumber No Average response time in milliseconds successRatenumber No Percentage of successful invocations (0-100) ratingnumber No Average user rating (0-5) ratingCountnumber No Number of ratings received versionnumber No Version number, incremented on configuration changes publishedAtdatetime No When the agent was first published tagsstring No Comma-separated tags for categorization
Field Direction Target Description organization-> Organization The organization that owns this agent owner-> Contact The person responsible for maintaining this agent
Verb Event Description 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
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' ,
})
})
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
Type Description Use Case Assistant Interactive agent that responds to questions Support chatbot, internal help desk Autonomous Self-directed agent that operates without prompting Background monitoring, data enrichment Workflow Triggered by events, executes predefined steps Lead qualification, onboarding sequences Specialist Deep expertise in a single domain Contract review, code analysis, financial modeling Router Routes requests to the appropriate specialist agent Triage agent, intent classification
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' ,
},
})
})
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` )
}
{
"type" : "Agent" ,
"filter" : { "status" : "Deployed" , "type" : "Specialist" },
"sort" : { "successRate" : "desc" },
"limit" : 10
}
{ "type" : "Agent" , "id" : "agent_mR4nVkTw" }
const agents = await $.Agent. find ({ status: 'Deployed' })
await $.Agent. invoke ( 'agent_mR4nVkTw' )
await $.Agent. pause ( 'agent_mR4nVkTw' )
# 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