Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

django-reststroke

Agent actions rest until a human lets them play.

Accept or refuse each tool call of an AI agent before it goes out, by a rule or by a person, in Django, and audit every decision.

PyPI version Python versions Django versions Documentation status CI License

Status: alpha. The API, the settings and the database schema can change between releases, and the changelog lists each breaking change. Not for production use yet.

What it does

An AI agent that calls tools can act on your systems: read data, send messages, change records. With reststroke, the agent sends each tool call to the gate, a separate process that holds the keys of your tools, and the gate asks your Django project if the call may pass. A rule that you write accepts or refuses the call at once, or the call waits until a person with the right to decide sees its exact arguments and accepts or refuses it. The gate sends only an accepted call to its tool. Each status change of a call gets an audit entry.

Use cases

  • An instruction hidden in a document asks the agent to send your data out. The agent obeys: it asks a tool that sends messages to send your list of clients to an outside address. Mark that tool "sends data out", and no rule can accept a call to it: only a person can let it pass. The person sees the exact arguments next to the message of the user, as the agent passed it on, and refuses. The tool never gets the call.
  • Routine calls do not wait for a person. A rule accepts at once the calls to a read tool that the requester has the right to use, up to the daily budget that you give it; past the budget, the next calls of the day wait for a person. When the tool list that the gate gets shows a changed definition of a tool, no rule accepts a call to that tool until a person reviews the new definition.
  • What the person accepted is what goes out, once. reststroke keeps the fingerprint of the call that the person accepted. The gate sends that exact call to its tool once, and a call that changed after the acceptance does not go out: it waits again, and a person can only refuse it.
  • Your agent holds no tool key. Only the gate holds the keys of the tools, and no tool key reaches the agent or reststroke. Django keeps only the hashes of the keys of the gate and of each agent. In the demo, the agent shares a network only with the gate, and a script checks that it reaches the gate and not the tools, the web app or the database.
  • A second person activates each new rule text. A rule that a person adds or edits in the admin acts only after a second person activates it. A superuser may activate their own text, and the record of the activation marks it. Deleting a rule needs no second person; only a superuser deletes a "refuse" or "ask" rule in force. The models and the admin of reststroke refuse to change or delete the activation records and the audit entries.

How a tool call passes

The agent is your AI program. It runs outside Django and acts for a requester: the user of your Django project in whose name it makes the call, from the users and groups that the agent may act for. The agent sends each tool call to the gate, with its own key. The gate asks reststroke, which checks the keys, the call and the rights of the requester. A check or a rule answers at once. If not, the call waits for a person who decides: a user with the right to decide the calls to that tool, who accepts or refuses it before its deadline. Past the deadline, the call gets no. reststroke checks the call and the rights again before the gate sends an accepted call to its tool.

Activity diagram of the path of one tool call, with one lane for each part and the key that each part holds

Requirements

  • Python 3.12 or later.
  • Django 6.1.
  • PostgreSQL: the demo and the CI tests run on it.

Quick start

In your Django project:

  1. Install the package: pip install django-reststroke. On the machine where the gate runs: pip install "django-reststroke[gate]".
  2. Add "reststroke" to INSTALLED_APPS.
  3. In the root URL configuration, include the interface of the gate and the inbox: path("reststroke/", include("reststroke.urls")) and path("inbox/", include("reststroke.inbox_urls")).
  4. Create the tables: python manage.py migrate.
  5. Make the key of the gate with python manage.py new_gate_key gate.key, and add the hash that it prints to the setting RESTSTROKE_GATE_KEY_HASHES.

Then follow Install in your project for the other steps, the cron line of expire_calls included, and Run the gate and add an agent.

Try the demo

The demo runs in Docker: a Django project with reststroke, the gate, demo tools and a scripted agent that obeys an instruction hidden in a note. You need git and Docker; the tutorial gives the versions and the ports. The demo is in French.

git clone https://github.com/tryph0n/django-reststroke.git
cd django-reststroke
cp .env.example .env
docker compose up -d --wait
docker compose exec web python manage.py seed_demo
docker compose exec agent python -m scripted_agent --gate-url http://gate:8100/mcp

The last command then waits for a person. The tutorial shows how to refuse that call as bob in the admin, and what the agent logs then.

About the name

Named after the rest stroke, the gypsy jazz picking technique Django Reinhardt used: the pick comes to rest on the next string before the note moves on.

Metadata

Release files for django-reststroke 0.1.0a2

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-reststroke 0.1.0a2
File Size Uploaded Provenance Actions
django_reststroke-0.1.0a2.tar.gz 110.3 kB With provenance Details for django_reststroke-0.1.0a2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-reststroke 0.1.0a2
File Interpreter ABI Platform Actions
django_reststroke-0.1.0a2-py3-none-any.whl Python 3 none any Details for django_reststroke-0.1.0a2-py3-none-any.whl

Total release size: 243.9 kB

Release files / django_reststroke-0.1.0a2.tar.gz

Download URL django_reststroke-0.1.0a2.tar.gz
Size 110.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e0b86dc3b36ce0a7138e9071e96b29b6bbb59d1824f6fb97e6d3d50b7dd9e92f
BLAKE2b-256 checksum
How to use checksums
e45aa1fa1fb8abe22903e907933db35f8d1537911d020a2731cdf28fd0194154
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 2, 2026.

Transparency log

Release files / django_reststroke-0.1.0a2-py3-none-any.whl

Download URL django_reststroke-0.1.0a2-py3-none-any.whl
Size 133.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d3d5155e28cdee21b8365656c207851db035a2aa2164816ba91b572fe7d6f363
BLAKE2b-256 checksum
How to use checksums
00534cd53323fd025f2fff02fecb11f9538a4dbcfa8eb4e47cdacbce1bca337e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 2, 2026.

Transparency log

Security for django-reststroke 0.1.0a2

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_reststroke-0.1.0a2.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 Dec 2, 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.

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