agentleFS
theagentplanetheagentplane/tokenops/AGENTS.md

tokenops

AGENTS.md84 starsChanged 29 days agoMITView on GitHub

TokenOps is the governance layer of the AgentPlane suite: it decides, inside an agent's own process, whether the next LLM call may happen (budgets, caps, halts, steering), using Chronicle hooks and the control plane's ledger. It is being reworked into the governors only; it will stop carrying its own control plane, run model, store and UI (issue 162). This file is read by AI coding agents (Claude Code, Codex, Cursor, Copilot and others). Humans may find it useful too. -…

  • Installs packages
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 31,700 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository5 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before changing architecture,: read the ADRs: structure, public interfaces, data formats, dependencies or anything shared with another …

    line 28
  2. Distinctive:

    Do not invent reasoning: If you do not know why something was decided or which alternatives were weighed, ask.

    line 34
  3. Very specific:

    Must work on Windows and Linux.

    line 59
  4. Distinctive:

    Dollars are written in micro-USD from one price source: Do not add a second price table.

    line 72
  5. Distinctive:

    Keep one change as one thing: Do not mix unrelated changes into a pull request.

    line 81

≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Agent instructions

TokenOps is the governance layer of the AgentPlane suite: it decides, inside an agent's own process, whether the next LLM call may happen (budgets, caps, halts, steering), using Chronicle hooks and the control plane's ledger. It is being reworked into the governors only; it will stop carrying its own control plane, run model, store and UI (issue 162).

This file is read by AI coding agents (Claude Code, Codex, Cursor, Copilot and others). Humans may find it useful too.

Source of truth

  • The rework plan and the decisions already taken are in issue 162. Do not re-litigate them; if the code and the plan disagree, stop and ask.
  • The entities (Trace, Span, Envelope, Usage) come from agentplane-primitives. Never define a local copy of an entity. A run is a Chronicle trace: the only identifier is trace_id, there is no run_id.
  • Governance configuration lives in the control plane database and is pulled with an ETag. A gap in Chronicle or the control plane is an issue in that repository, not a workaround here.

Architecture decisions

Decisions that shape this repository are recorded as ADRs in docs/adr/.

  • Before changing architecture, read the ADRs: structure, public interfaces, data formats, dependencies or anything shared with another repository. Do not undo an accepted decision silently. If a change conflicts with one, say so and propose a new ADR that supersedes it.
  • When asked to record a decision, or when you make one that meets the criteria in docs/adr/README.md, write an ADR: copy docs/adr/template.md, use the next free number, keep it to about a page, and add it to the index.
  • Do not invent reasoning. If you do not know why something was decided or which alternatives were weighed, ask. Leave the status as Proposed: the people named as deciders accept it.
  • Never rewrite an accepted ADR. Supersede it with a new one.

Layers

Each layer imports only from the ones above it; tests/test_layering.py enforces it. The 1.0 package tokenops.control was removed in 2.0; import from the layers.

LayerPackageRule
Primitivesagentplane_primitives (external)Data only.
Frameworktokenops.frameworkIn-process machinery: policies, pricing, governor. No network.
Repositoriestokenops.repositoriesThe only place that does I/O: the control-plane client.
Capabilitiestokenops.capabilitiesGoverned-run workflows.
Interfacestokenops.interfaces, tokenops.__init__What the developer touches.

Code layout and style

  • src layout, typed package (py.typed), Python 3.10 to 3.13 (no syntax newer than 3.10).
  • One concept per file, with a module docstring that says what it is. Folders are named for what they hold; helper modules are suffixed for what they are (*_utils.py, *_types.py, *_repository.py). __init__.py re-exports the public names with __all__.
  • Types and models, and functions, live apart: no functions in model modules, no models in utils.
  • Must work on Windows and Linux. On Windows use python -m pytest.
  • Tooling: ruff (line length 100), mypy, pytest. Developer tools are the dev dependency group (pip install --group dev), not a published extra. Run the checks listed in CONTRIBUTING.md before you finish.

Invariants (do not break)

  • Fail-safe is explicit: what happens when the control plane is unreachable is a documented, tested behaviour, never an accident of an exception.
  • No double counting: ledger events are not deduplicated by the plane, so a retry must never be able to write the same spend twice.
  • A halt stops the next call, not the current one: governors act by raising chronicle.AbortCall before a call; they never swallow or rewrite the caller's real result.
  • Dollars are written in micro-USD from one price source. Do not add a second price table.

Change size

  • Estimate before writing code: lines added plus removed, not counting generated files, lockfiles, golden test data or pure moves, renames and deletions.
  • If the estimate is above 400 lines, stop and plan. Propose to the user a short plan that splits the work into logical components (each reviewable on its own, passing CI, in order), and wait for agreement before implementing. Open one pull request per component.
  • Keep one change as one thing. Do not mix unrelated changes into a pull request.
  • Staying above 400 lines is acceptable for boilerplate, mechanical changes or generated code, or when the maintainer has decided on one change, but say why in the pull request description.

Related repositories

chronicle (edge SDK: record, save, replay) · primitives (shared schemas) · control-plane (storage, query, UI) · tokenops (cost governance)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.