Skip to main content

django-spec-agents

CI PyPI Python versions Django versions Docs Coverage Ruff License

Pydantic-AI agents for Django, in two halves. The agent host takes an AgentConfig and a tool registry and returns a built pydantic_ai.Agent, with an audit trail over every tool call, a server-side approval gate for destructive tools, a failure policy, conversation and attachment stores, and an opt-in store app. It reads no Django settings of its own: a transport such as django-ag-ui owns its settings, builds the config and hands it down. spec_tools, behind the [specs] extra, serves django-service-specs specs to an agent as tools, in process, with each spec's own validation, permissions and rendering: SpecToolset, and SpecCapability over it.

The host was published as django-pydantic-agent and spec_tools as djangorestframework-pydantic-ai. This package carries both under one import path, django_spec_agents, and the root never imports spec_tools, so the host installs and runs without the extra.

Install

pip install django-spec-agents            # the agent host
pip install "django-spec-agents[specs]"   # and specs as agent tools

Python 3.10 or later and Django 4.2 or later. [specs] adds django-service-specs. The other extras: [drf-mcp] bridges a djangorestframework-mcp-server registry as a toolset, [harness] adds the pydantic-ai-harness capabilities, and [anthropic], [openai] and [google] add a model provider.

The store app is opt-in. To persist conversations, attachments, steps and memory in the database, add it to INSTALLED_APPS, where its label is django_spec_agents_store, and run migrate:

INSTALLED_APPS = [
    # ...
    "django_spec_agents.contrib.store",
]

Quickstart

An agent over tools you register:

from django_spec_agents import AgentConfig, AgentDeps, ToolRegistry, build_agent, tool

registry = ToolRegistry()


@tool(registry)
def list_orders(status: str) -> list[dict]:
    """List orders with the given status."""
    ...


agent = build_agent(registry, AgentConfig(model="anthropic:claude-sonnet-4-5"))
result = await agent.run("what is still pending?", deps=AgentDeps(user=request.user))

The same agent calling your specs beside the registry's tools, with [specs] installed. Each key is a tool name, distinct from the registry's; the description, the parameter schema and the return schema come from the spec. Each spec declares its permissions, which the toolset refuses to go without, because nothing over HTTP gates a call made in process:

from django_spec_agents.spec_tools import SpecToolset

toolset = SpecToolset({"list_invoices": list_invoices_spec, "create_invoice": create_invoice_spec})
agent = build_agent(registry, AgentConfig(model="anthropic:claude-sonnet-4-5", toolsets=[toolset]))

Documentation

https://artui.github.io/django-spec-agents/

  • Concepts: how a config becomes an agent, and what belongs here versus in a transport.
  • Tools: registering tools and what their metadata does.
  • Storage: the store contracts, owner scoping and the store app.
  • Policy: audit, the approval gate and the failure policy.
  • Integrations: specs and MCP tools as agent tools.
  • Spec tools: SpecToolset and SpecCapability in depth.
  • Reference: the public API.

License

MIT. See LICENSE.

Metadata

Release files for django-spec-agents 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-spec-agents 0.2.1
File Size Uploaded Provenance Actions
django_spec_agents-0.2.1.tar.gz 626.6 kB With provenance Details for django_spec_agents-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-spec-agents 0.2.1
File Interpreter ABI Platform Actions
django_spec_agents-0.2.1-py3-none-any.whl Python 3 none any Details for django_spec_agents-0.2.1-py3-none-any.whl

Total release size: 816.9 kB

Release files / django_spec_agents-0.2.1.tar.gz

Download URL django_spec_agents-0.2.1.tar.gz
Size 626.6 kB
Tags Source
SHA-256 checksum
How to use checksums
16e1ce74fb02a99564b7beb0bd69adc1c40517a6114230d49528e16e2c89aae2
BLAKE2b-256 checksum
How to use checksums
ccd649323e3d1c57004f7132131c75f502f9fda633002e18a7f9cc01fb803a49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Release files / django_spec_agents-0.2.1-py3-none-any.whl

Download URL django_spec_agents-0.2.1-py3-none-any.whl
Size 190.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f584bdc8a94c9394bfeb836a078ee486577265d5127ea2d8e6724e56b2d4900b
BLAKE2b-256 checksum
How to use checksums
a5be34fd51c77772ba0e676b0dd62e385cfb3892538cc56a1d2e82bc0a55a5ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

Security for django-spec-agents 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_spec_agents-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page