A rendering convention for AI agents — append /agents to any FastAPI route and get a fully structured agent workspace with state, capabilities, RBAC, and navigation.
Project description
AgentML
AgentML is a universal rendering convention for AI agents. The same way browsers render HTML into a visual experience for humans, AgentML renders a complete agent-page/workspace for AI — context, state, permissions, actions, guidance, navigation — everything an agent needs to understand where it is and what it can do, in one response.
Quickstart
1. Install
pip install agentml
2. Setup in 3 Lines
from fastapi import FastAPI
from agentML import AgentML
app = FastAPI()
agent = AgentML(app)
agent.add_middleware() # Enables mutation response semantics
1. Mutation Enriched Response (POST /patients)
When an agent performs an action (e.g. POST /patients) and sends the header Accept: application/vnd.agentml+json, AgentML intercepts the response to tell the agent exactly what changed (delta), where the resource now lives (agent_resource), and what it can do next (actions) and where it can go (navigation):
POST /patients
Accept: application/vnd.agentml+json
Content-Type: application/json
{
"name": "Aanya Sharma",
"age": 34
}
Response:
{
"result": {
"id": 42,
"name": "Aanya Sharma",
"age": 34
},
"delta": {
"name": "Aanya Sharma",
"age": 34
},
"agent_resource": "/patients/42/agents",
"actions": [
{
"name": "UpdatePatientDetails",
"agent_endpoint": "/patients/42/agents"
},
{
"name": "ViewPatientDetails",
"agent_endpoint": "/patients/42/agents"
},
{
"name": "ArchivePatient",
"agent_endpoint": "/patients/42/agents"
}
],
"navigation": [
{
"label": "Appointments",
"agent_endpoint": "/patients/42/appointments/agents"
},
{
"label": "Billing",
"agent_endpoint": "/billing/agents"
},
{
"label": "Home",
"agent_endpoint": "/agents"
}
]
}
2. Resource Workspace (GET /patients/42/agents)
When an agent navigates to the resulting agent_resource, they receive a complete state-aware workspace:
GET /patients/42/agents
Response:
{
"agentML": "0.1",
"workspace": {
"title": "Patients Instance Agent Workspace",
"resource": "/patients/42",
"agent_resource": "/patients/42/agents",
"breadcrumb": ["Home", "Patients", "Patient 42"]
},
"identity": {
"role": "doctor",
"user_id": "doc_88"
},
"state": {
"id": 42,
"name": "Aanya Sharma",
"age": 34,
"archived": false
},
"capabilities": [
{
"name": "UpdatePatientDetails",
"description": "Modify name or age of an existing patient",
"fields": [
{
"name": "name",
"type": "string",
"required": true,
"current": "Aanya Sharma"
},
{
"name": "age",
"type": "integer",
"required": true,
"current": 34,
"constraints": {
"ge": 0,
"le": 120
}
}
]
}
],
"unavailable": [],
"navigation": [
{
"label": "Appointments",
"agent_endpoint": "/patients/42/appointments/agents"
},
{
"label": "Billing",
"agent_endpoint": "/billing/agents"
},
{
"label": "Home",
"agent_endpoint": "/agents"
}
],
"alerts": [],
"guidance": []
}
Understanding the Workspace Blocks
workspace: Native location context containing the human URL, the agent URL, and path breadcrumbs.identity: The dynamic security credentials and role context for the current request.state: The serialized current resource state fetched in-process.capabilities: Permitted business-language actions (never HTTP verbs) with dynamic schema validation rules and pre-filled current values.unavailable: Actions that are temporarily disabled due to the current resource state, complete with explanations.navigation: Context-aware sibling and sub-resource links matching the instance's active ID.alerts: Banner notifications or warning details generated dynamically based on state.
Philosophy: HTML for Humans, AgentML for AI
The web was built for human eyes. AI agents are currently forced to parse layout-heavy HTML, guess dynamic form flows, and reverse-engineer endpoints.
AgentML introduces a simple, universal web rendering convention: append /agents to any HTTP resource.
A browser requests a resource and gets human-friendly HTML. An AI agent requests the same resource + /agents (or issues mutations requesting the vnd.agentml+json payload) and gets a structured, action-ready Agent Workspace.
Core Features
- Relational Navigation: Context-aware nested resources (e.g.
/patients/42/agentslinks to/patients/42/appointments/agentssubstituting the identifier automatically). - Mutation Semantics (v0.4): Mutation writes return execution feedback, updated state deltas, and structured action and navigation lists to eliminate agent state blindness.
- Invisible-by-Design RBAC: Permissions are evaluated at render-time; capabilities the agent is unauthorized to perform are completely absent.
- Zero HTTP Verbs: All actions are presented in clean business terminology (e.g.
RegisterPatientinstead ofPOST /patients). - Fail-Closed Safety: Dynamic safety check hooks (
unavailable_fn) default to blocked state on exceptions. - Pydantic Validation: Auto-extracts field types, constraints (
ge,le, patterns, enums) and pre-fills current state values.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentml-0.1.0.tar.gz.
File metadata
- Download URL: agentml-0.1.0.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17b2c039f527ba5eac10a446d796fdfc48266d7ec314cbcfb257bc33ed24e93c
|
|
| MD5 |
0452dda5c1b63be1b540d29d5131d37b
|
|
| BLAKE2b-256 |
88b796fd56d8e07da709e64c67a075f9ca6287b165dc29ad555347e9d6df5d6f
|
File details
Details for the file agentml-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agentml-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f62a1ed1283d5f549e973d9e3916039ccb34d8bf32b85dfaa612481c66b62d97
|
|
| MD5 |
1569d243cb79855ee0499cbc4ff43d2b
|
|
| BLAKE2b-256 |
da5774bfb7819539c13d1d7b3b10754761e331b98ce81bd9d10320ca06a46b70
|