Skip to main content

django-auto-agent

Django reusable app that turns opted-in DRF endpoints into a LangGraph supervisor, with optional long-term memory, admin views, and evals.

Import name: ai_agent.

Install

pip install django-auto-agent

Redis-backed memory store (optional):

pip install "django-auto-agent[redis]"

From a clone of this repository:

pip install -e .
pip install -e ".[redis]"

Host wiring

INSTALLED_APPS = [
    # ...
    "ai_agent",
    "catalog",  # your domain app
]

AI_AGENT = {
    "SUPERVISOR_MODEL": "openai:gpt-4.1-mini",
    "SUBAGENT_MODEL": "openai:gpt-4.1-nano",
    "AUTHENTICATE_TOKEN": "myproject.auth.authenticate_access_token",
    "PLATFORM_NAME": "Acme",
    "PLATFORM_DOMAINS": ("catalog", "billing"),
    "EVAL_MODULE": "catalog.evals",
}

AUTHENTICATE_TOKEN is required. It must be a callable (or dotted path to one) that accepts a bearer token and returns a user object with .pk.

Optional evals — point EVAL_MODULE at a host module that defines:

  • seed_eval_world() -> EvalWorld (users plus prompt_vars for case prompts)
  • snapshot_world(world, kind) -> dict (optional; used by mutation cases)
  • CASES: list[EvalCase] (or partitioned ROUTING_CASES / TOOL_CASES / MUTATION_CASES / E2E_CASES)

The library always includes safety routing cases (off-policy greeting, jailbreaks). Domain tool and mutation cases come from the host module. See dummy/evals.py in this repo.

HTTP_TRUSTED_PROXY_COUNT (default 0) controls whether the CopilotKit HTTP throttle reads X-Forwarded-For. Leave it at 0 unless the app sits behind that many trusted reverse proxies; otherwise clients can rotate a spoofed header and bypass the limit.

Include the chat/memory HTTP API:

urlpatterns = [
    path("api/agent/", include("ai_agent.urls")),
]

Opt a host app into the agent by setting flags on its AppConfig:

class CatalogConfig(AppConfig):
    name = "catalog"
    agent_expose = True
    agent_description = "List and create catalog items for the authenticated user."
    agent_exclude = ("internal_webhook",)
    agent_memory_profile = "catalog.memory_schemas.CatalogProfile"
    agent_memory_collections = (
        "ai_agent.memory.schemas.SemanticFact",
        "catalog.memory_schemas.CatalogAccount",
    )

Mark individual views even when the app is off:

from ai_agent.expose import agent_expose, agent_exclude

@agent_expose
def public_note(request):
    ...

LangGraph Agent Server

This package is not a host Docker image. Install django-auto-agent and your Django project into the Agent Server image, then point langgraph.json at the library entrypoints (see the example langgraph.json in this repo):

  • graphs: ai_agent.studio:graph, ai_agent.studio:memory
  • auth: ai_agent.auth:auth
  • HTTP app: ai_agent.studio:app

Set DJANGO_SETTINGS_MODULE (or AI_AGENT_STUDIO_DJANGO_SETTINGS) to your settings module before starting Studio.

The example langgraph.json uses cors.allow_origins: ["*"]. Auth is Bearer-token based (not cookies), so CSRF exposure is limited; restrict origins in production.

Tests

From this repo:

python manage.py test ai_agent

The dummy and notes apps plus tests/settings.py are a sample host. They are not installed with the wheel.

Metadata

Release files for django-auto-agent 0.1.0

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-auto-agent 0.1.0
File Size Uploaded
django_auto_agent-0.1.0.tar.gz 101.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-auto-agent 0.1.0
File Interpreter ABI Platform
django_auto_agent-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 230.8 kB

Release files / django_auto_agent-0.1.0.tar.gz

Download URL django_auto_agent-0.1.0.tar.gz
Size 101.6 kB
Tags Source
SHA-256 checksum
How to use checksums
d0251e6b09da6606b1fecf796ef9900c9ca264e05790e7579841e3f575d94784
BLAKE2b-256 checksum
How to use checksums
f5ba61f8d7636b545a8a74d4dbd17d2ce25c5edb2a4c449a333bc15d23a0ebac
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 Sep 16, 2026.

Transparency log

Release files / django_auto_agent-0.1.0-py3-none-any.whl

Download URL django_auto_agent-0.1.0-py3-none-any.whl
Size 129.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a4ce924986892a7cca90776efaad3684b8b5e058c4c43f1ea3d8740479afbbf
BLAKE2b-256 checksum
How to use checksums
39016c457bfb12e70f2a7fe5041c5e48481f0910e6e67446404b2daebd314224
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 Sep 16, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

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