Copied to clipboard
Problem Syntax Enforcement Install Integrations Use Cases GitHub Read Spec
Declarative Agent Governance · Open Standard

Define Agent Behavior. Enforce It Everywhere.

A declarative specification language for AI agent capabilities, constraints, and permissions. Like OpenAPI, but for agent behavior.

agent:
agent: customer_service constraints: max_tokens: 2000 forbidden: [delete_account, modify_billing] permissions: data_access: "assigned_region"
The Problem

AI Agents Without Specifications
Are Unpredictable

Every deployed agent is a black box of scattered logic, undocumented capabilities, and implicit constraints. Teams build agents fast, but govern them not at all.

Undocumented Behavior

What can this agent actually do? Without a formal spec, nobody knows -- not even the developers who built it. Capabilities live in scattered code, config files, and tribal knowledge.

Impossible to Audit

Security teams cannot review what they cannot see. Agent capabilities are implicit, buried in prompt templates, tool registrations, and runtime configurations that no one tracks.

Manual Enforcement

Constraints are code comments and hope. There is no runtime that actually prevents spec violations. When an agent misbehaves, you find out from your users, not your monitoring.

No Inheritance

Every agent starts from scratch. There is no way to define a base policy and extend it. Teams copy-paste constraints, drift apart, and end up with inconsistent governance across their fleet.

The Solution

One Spec. Every Agent.
Automatic Enforcement.

AgentSpec is a declarative YAML language for defining what an agent can do, what it cannot do, and who decides. Write it once, enforce it everywhere.

Write YAML Spec Define capabilities, constraints, and permissions in plain YAML
Load into Enforcer The runtime enforcer validates every action against the spec
Agent Runs Safely Violations are blocked. Compliance is automatic. Audit trails are built in.

Human-Readable YAML

Write specs anyone on your team can understand. Version them in git. Review them in pull requests. No DSL to learn -- just structured YAML with clear semantics.

Runtime Enforcement

The enforcer wraps your agent and validates every action against the spec in real time. Forbidden tool calls are blocked. Token limits are enforced. No exceptions.

Composable & Inheritable

Build a base spec and extend it for each agent type. Override specific fields. Share constraints across your entire fleet. Specifications compose like object-oriented classes.

Elegant Syntax

Simple to Write. Powerful to Enforce.

A complete agent specification in fewer lines than a Kubernetes deployment. Every field is meaningful, every constraint is enforceable.

customer_service_bot.agent.yaml
# Agent: Customer Service Bot
# Version: 2.1.0

agent: customer_service_bot
version: "2.1.0"
description: "Handles customer inquiries and support tickets"

capabilities:
  tools:
    - name: search_knowledge_base
      description: "Search internal documentation"
      rate_limit: 100/minute

    - name: send_email
      description: "Send email to customer"
      constraints:
        max_recipients: 5
        require_approval_if: "refund > $100"

    - name: create_ticket
      description: "Create support ticket"
      priority_levels: [low, medium, high]

restrictions:
  forbidden_tools:
    - delete_customer_data
    - modify_billing
    - access_admin_panel

  token_limits:
    max_response: 2000
    max_context: 8000

  content_policy:
    no_profanity: true
    no_competitor_mentions: true

permissions:
  data_access:
    scope: "customers_in_assigned_region"
    pii_handling: "mask_after_use"

  escalation:
    auto_escalate_after: 3 failed_attempts
    human_review_required: ["account_deletion", "legal_request"]

inherits: base_support_agent
1
Capabilities
Explicitly declare every tool an agent can use, with rate limits and constraints per tool.
2
Restrictions
Forbidden tools, token limits, and content policies enforced at runtime. No exceptions.
3
Permissions
Scoped data access with PII handling rules and automatic escalation triggers.
4
Inheritance
Extend base specs. Override only what changes. Share governance across your fleet.
How It Works

Four Steps to Governed Agents

From YAML file to runtime enforcement in under five minutes. No infrastructure required.

1

Write

Define your agent's capabilities, constraints, and permissions in a YAML file.

agent: my_agent
version: "1.0.0"
2

Validate

AgentSpec validates your spec for correctness, completeness, and policy compliance.

$ agentspec validate
Spec valid (23 rules)
3

Enforce

The runtime enforcer wraps your agent and blocks any action that violates the spec.

from agentspec import enforce
agent = enforce(agent, "spec.yaml")
4

Audit

Review structured violation logs and compliance reports for every agent interaction.

$ agentspec audit --last 24h
0 violations | 1,247 actions
The Difference

Night and Day

A side-by-side look at agent governance before and after AgentSpec.

Aspect Without AgentSpec With AgentSpec
Documentation Comments in code Formal YAML specification
Enforcement Hope and manual checks Automatic runtime enforcer
Auditability Dig through source code Structured spec + audit logs
Versioning Git commit messages Semantic spec versions
Inheritance Copy-paste between agents inherits: base_spec
Team Communication Tribal knowledge Shared, versioned specification
Security Review Manual code audit Automated spec scanning
Onboarding "Ask the original author" Read the spec file
Use Cases

Built for Every Team That Ships Agents

Whether you are a startup with one agent or an enterprise with hundreds, AgentSpec scales to meet your governance needs.

Responsible AI Teams

Document and enforce ethical guardrails across your entire agent fleet. Prove compliance to stakeholders with formal, versioned specifications that map directly to your AI ethics policy.

Regulated Industries

Meet compliance requirements in healthcare, finance, and legal with auditable, versioned behavior specifications. Every agent action is traceable back to an approved spec revision.

Multi-Agent Systems

Coordinate capabilities and constraints across agent networks. Define which agents can communicate, share data, or delegate tasks to each other through composable specifications.

Enterprise IT / Security

Audit, approve, and enforce agent policies before deployment. Security teams review YAML specs in pull requests, not scattered code. Policy changes are tracked like infrastructure-as-code.

Open Source Projects

Let contributors understand exactly what each agent should and should not do. Spec files serve as living documentation that is always in sync with actual agent behavior.

Composable Specifications

Build Once, Extend Everywhere

Define base policies for your organization and extend them per team, per role, per agent. Specifications compose like well-designed software.

base_agent.yaml base
  |-- support_agent.yaml extends base
  |    |-- tier1_support.yaml extends support
  |    |-- tier2_support.yaml extends support
  |-- sales_agent.yaml extends base
      |-- enterprise_sales.yaml extends sales
tier1_support.agent.yaml
# Inherits all base_support_agent rules # Override only what's different for Tier 1 agent: tier1_support inherits: support_agent restrictions: token_limits: max_response: 1000 # Lower than parent forbidden_tools: - issue_refund # Tier 1 can't refund - modify_subscription # Must escalate permissions: escalation: escalate_to: tier2_support auto_escalate_after: 2 failed_attempts
Features

Everything You Need to Govern Agents

A complete toolkit for defining, validating, enforcing, and auditing agent behavior at any scale.

YAML Syntax

Human-readable agent specifications that anyone on your team can write, review, and understand.

Runtime Enforcer

Wrap any agent with a spec-aware enforcer that blocks violations in real time.

Permission Model

Fine-grained data access scoping, PII handling rules, and role-based capabilities.

Audit Logging

Structured violation logs and compliance reports for every agent interaction and decision.

Inheritance System

Extend base specs and override specific fields. Compose governance like object-oriented code.

Validation Engine

Catch errors before deployment. Schema validation ensures your specs are correct and complete.

TypeScript SDK

First-class TypeScript support with full type definitions, validation helpers, and enforcer middleware.

Python SDK

Native Python package with Pydantic models, async support, and seamless framework integration.

Quick Start

Up and Running in Minutes

Install the Python package or the TypeScript SDK. Parse, validate, lint, and enforce specs with just a few lines of code.

$ pip install agentspec
quickstart.py
from agentspec import parse_spec, validate_spec, lint_spec, Enforcer, create_context

# Parse and validate a spec from YAML
spec = parse_spec(yaml_content)
result = validate_spec(spec)

# Lint for quality and best practices
lint = lint_spec(spec)
print(f"Score: {lint.score}/100")

# Runtime enforcement
enforcer = Enforcer(spec)
ctx = create_context(
    agent_id="agent-1",
    action="read",
    input_data="query"
)
result = enforcer.enforce(ctx)
quickstart.ts
import { parseSpec, validateSpec, lintSpec } from '@anthropic/agentspec-core';
import { Enforcer, createContext } from '@anthropic/agentspec-sdk';

// Parse and validate a spec from YAML
const spec = parseSpec(yamlContent);
const result = validateSpec(spec);

// Lint for quality and best practices
const lint = lintSpec(spec);
console.log(`Score: ${lint.score}/100`);

// Runtime enforcement
const enforcer = new Enforcer(spec);
const ctx = createContext({
  agentId: "agent-1",
  action: "read",
  inputData: "query"
});
const enforcement = enforcer.enforce(ctx);
$ npm install @anthropic/agentspec-core @anthropic/agentspec-sdk
package.json (relevant fields)
{
  "dependencies": {
    "@anthropic/agentspec-core": "^0.1.0",
    "@anthropic/agentspec-sdk": "^0.1.0"
  }
}
Ecosystem

Integrates With Your Stack

Drop-in guards for the most popular agent frameworks. Add spec enforcement with a single import.

CrewAI

Enforce AgentSpec constraints on every CrewAI agent and task. The guard wraps your crew and validates each action against the spec before execution.

from agentspec.integrations.crewai import AgentSpecCrewAIGuard guard = AgentSpecCrewAIGuard(spec) crew = guard.wrap(my_crew) crew.kickoff() # Spec-enforced

LangChain

Add AgentSpec enforcement as LangChain middleware. Works with chains, agents, and any runnable. Violations are caught before they reach the LLM.

from agentspec.integrations.langchain import AgentSpecLangChainGuard guard = AgentSpecLangChainGuard(spec) chain = guard.wrap(my_chain) chain.invoke(input) # Spec-enforced

OpenAI

Wrap the OpenAI API client with spec enforcement. Every chat completion request is validated against your AgentSpec before it is sent to the model.

from agentspec.integrations.openai import AgentSpecOpenAIGuard guard = AgentSpecOpenAIGuard(spec, api_key="...") response = guard.chat(messages) # Spec-enforced
AI Platforms

ChatGPT Skills & Claude MCP

Connect AgentSpec to the platforms you already use. Expose your spec-governed agents via OpenAPI for ChatGPT or as MCP tools for Claude.

ChatGPT Custom GPT

OpenAPI Actions

Use the AgentSpec OpenAPI specification to create ChatGPT Custom GPT Actions. Your GPT can validate, lint, and enforce specs through a standard API.

  • 1 Open ChatGPT, go to My GPTs, and create or edit a GPT
  • 2 Under Actions, import the OpenAPI schema from spec/openapi.yaml
  • 3 Your GPT can now validate and enforce AgentSpec files directly in conversation
# spec/openapi.yaml openapi: "3.1.0" info: title: "AgentSpec API" version: "0.1.0" paths: /validate: ... /lint: ... /enforce: ...
View OpenAPI Spec
Claude Desktop

MCP Integration

Run AgentSpec as a Model Context Protocol (MCP) server. Claude can parse, validate, lint, and enforce specs as native tools inside any conversation.

  • 1 Install the MCP server package: npm install @anthropic/agentspec-mcp
  • 2 Add it to your Claude Desktop MCP configuration file
  • 3 Claude can now use AgentSpec tools: validate, lint, enforce
// claude_desktop_config.json { "mcpServers": { "agentspec": { "command": "npx", "args": ["@anthropic/agentspec-mcp"] } } }
View MCP Docs
By the Numbers

A Complete Specification
Language

0
Enums
0
Lint Rules
0
Framework Guards
0
SDKs
Get Started

Ready to Specify
Your Agents?

Open source. Framework-agnostic. Production-ready.

$ pip install agentspec