agentdescent
AGENTS.md203 starsChanged 6 days agoMITView on GitHub
Instructions for AI coding agents working on ThinkFlowLab/agentdescent. Human contributors: CONTRIBUTING.md has the same rules with more background. The owner and only maintainer is Danyang (GitHub Birfy). 1. Read LESSONS.md. Open lessons are constraints. 2. Read CODE_STANDARDS.md: Verifier honesty, tests that fail on main, offline tests, generated files, the merge gate. 3. Keep the Hard rules below. One issue → one fresh clone → one branch → one PR → green CI → review → merge by tier. 1. Issue.…
- Reads credentials
- 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,774 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 repository3 other files it gives its agents.
- docs/agents.mdAGENTS.md
- fix-issueSkill
- review-prSkill
The file
We split this AGENTS.md into the rules it gives an agent
12 rules. About 0 are common, 5 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 9
Read LESSONS.md. Open lessons are constraints.
- Very specific: line 10
Read CODE_STANDARDS.md: Verifier honesty, tests that fail on main, offline tests, generated files, the merge gate.
- Distinctive: line 12
Keep the Hard rules below.
- Very specific: line 39
When a class of mistake repeats, date a lesson in LESSONS.md (Seen N×).
- Very specific: line 64
Every tier: never --admin, never use the ruleset's admin bypass, never push to main, never force-push, never delete a remote branch by hand …
- Very specific: line 89
Only Danyang or the maintenance routine (acting as Birfy) sets agent-ready, with a triage comment, and only when (1) every design conflict …
- Very specific: line 98
Before work: skip an issue someone else is assigned to.
- Very specific: line 120
No secrets: Never write, print or commit an API key or token.
- Very specific: line 124
The suite stays offline and deterministic: No network or model API in pytest -q.
- Distinctive: line 173
Follow the code around your change.
- Distinctive: line 175
Commit messages in English, imperative subject, the reason in the body.
- Distinctive: line 176
Keep a change to one subject.
≈ “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.
Files
AGENTS.md
Instructions for AI coding agents working on ThinkFlowLab/agentdescent. Human
contributors: CONTRIBUTING.md has the same rules with more
background. The owner and only maintainer is Danyang (GitHub Birfy).
Before you code
- Read LESSONS.md. Open lessons are constraints.
- Read CODE_STANDARDS.md: Verifier honesty, tests that
fail on
main, offline tests, generated files, the merge gate. - Keep the Hard rules below.
Pipeline contract
One issue → one fresh clone → one branch → one PR → green CI → review → merge by tier.
- Issue. Work one
agent-readyissue per session, in a fresh clone (git clone https://github.com/ThinkFlowLab/agentdescent <run-dir>/repo), never in a shared or stale checkout. - Branch from the latest
origin/main. Write a test that fails onmain, then fix the class of bug, not the one sample. - Verify locally at the tip:
pip install -e ".[dev]",pytest -q, andmkdocs build --strictwhendocs/ormkdocs.ymlchanged (see Commands). - PR to
main. Imperative English title (fix(runstore): …,feat(cli): …, as ingit log),Fixes #Nin the body, and the PR template'sTip SHA:/Ran:/Not run:lines. A user-visible change adds one fragmentchangelog.d/<issue>-<slug>.md(changelog.d/README.md); never editCHANGELOG.mdin a PR. Squash is the only merge method and the squash commit is the PR title + body, so keep the body short. - CI. The required checks are
build(docs) andtest (3.9)…test (3.13). Never merge around a red or pending check.risk tierandreviewed tipare report-only and are not required. - Review and merge by tier; see Merge policy.
- Stop and hand over to Danyang on a security-sensitive change, an unresolved design decision, or when you cannot get a green tip.
When a class of mistake repeats, date a lesson in LESSONS.md (Seen N×); after
≥3 days promote the durable rule into CODE_STANDARDS.md / CONTRIBUTING.md.
Merge policy
The tier comes from the diff, never from the PR text:
python3 .github/scripts/risk_gate.py --pr <n> --repo ThinkFlowLab/agentdescent, and the
controller sets the risk:T* label within ~30 minutes. Rules:
.github/agent/risk-rules.json (docs T0; tests,
examples and changelog.d/ T1; other package code and unknown paths T2; the
core loop, model adapters, installers, release files, .github/** and these
process docs T3; a PR over its tier's size cap is T3).
T0 / T1: once the required checks are green at the tip, post a self-review PASS at that tip (review-pr;
Birfymay PASS its own PR), then enable auto-merge pinned to that tip:gh pr merge <n> -R ThinkFlowLab/agentdescent --auto --squash --match-head-commit <sha>- T2 / T3: green checks + a PASS at the tip (self-PASS counts), then add
awaiting-approvaland stop. Danyang merges with an explicit click in the GitHub UI. An agent never merges a T2/T3 PR, and an approval typed in chat is not a click. - Every tier: never
--admin, never use the ruleset's admin bypass, never push tomain, never force-push, never delete a remote branch by hand (merged branches are deleted automatically), never edit protection or rulesets as part of a PR's work. Any new commit voids the PASS: re-review the new tip.python3 .github/scripts/review_gate.py --pr <n>tells you whether the current head carries a PASS that counts.
Labels
Source of truth: .github/labels.json, synced by the
labels workflow on main (create and update only, never delete).
- Type, exactly one:
bug,enhancement,documentation,chore. - Area, one or more:
area:evolve,area:meta,area:runstore,area:audit,area:agents,area:plugins,area:cli,area:ports,area:bench,area:docs,area:ci. - Source:
self-test(filed by the self-test routine; issues only). - State:
needs-info(spec unclear),needs-human(needs Danyang's decision; the last comment says what),agent-ready,agent-working,agent-pr,awaiting-approval(green T2/T3 PR waiting for a PASS and Danyang's click),hold(automation leaves the item alone). - Risk:
risk:T0…risk:T3, set by the controller only, never by hand.
Triage: when an issue is agent-ready
Only Danyang or the maintenance routine (acting as Birfy) sets agent-ready,
with a triage comment, and only when (1) every design conflict is resolved
(recorded owner decisions, other open issues and PRs), (2) the expected
behavior and scope are clear, and (3) it is not hold and not an umbrella or
tracking issue. Otherwise label needs-info or needs-human and name the
question in a comment. Agents develop only agent-ready issues.
Claim, PR, release
- Before work: skip an issue someone else is assigned to. Otherwise assign
Birfy, addagent-working, and comment naming the branch. - Stopping without a PR: unassign, remove
agent-working, say why. - The PR says
Fixes #N, is assigned toBirfy, labeledagent-prplus its type and area. Agent branches start withagent/.
Controller
.github/workflows/controller.yml runs every
30 minutes with the built-in GITHUB_TOKEN only (no GitHub App, no secrets) and
changes labels and nothing else: it sets risk:T* and agent-pr on open PRs,
removes agent-ready/agent-working when a non-maintainer set or edited an
issue after it was approved, and expires a claim after 6 h with no linked push.
It never adds agent-ready, never merges, comments or closes.
| Repository variable | Effect |
CONTROLLER_LIVE | exactly true → labels are applied; anything else → dry run (plan in the job summary) |
AGENT_PAUSE | true → kill switch: the controller reads and changes nothing. Agents and routines also stop when it is true |
Hard rules
- No secrets. Never write, print or commit an API key or token. Real-model
tests read the key from the environment only (
ARK_API_KEYfor Volcengine Ark, throughapi_key_env=/ the sharedFORWARDED_ENVlist); never put a key in a spec, a test, a log or a PR. - The suite stays offline and deterministic. No network or model API in
pytest -q; a real-model or Docker check is gated behind a flag or an env var and reported underNot run:when skipped. - Faithful ports stay faithful. An algorithm port under
examples/<algorithm>/follows the source repo's released code; where code and paper disagree, follow the code and say so (porting checklist). - Generated files are regenerated, never hand-edited.
docs/api.mdcomes frompython -m tools.gen_api_docs;CHANGELOG.mdis folded fromchangelog.d/at release time (python -m tools.changelog_fragments release), not in a PR. The version lives only inagentdescent/__init__.py. - Git hygiene. Fresh clone per task, branch from
origin/main, never pushmain, never force-push, never delete a remote branch by hand. Clean up the run directory when done.
Commands
pip install -e ".[dev,mcp]" # what CI installs (mcp needs Python >= 3.10)
pytest -q # the offline suite CI runs on 3.9-3.13
python -m tools.gen_api_docs # regenerate docs/api.md after a public-API change
python -m tools.gen_api_docs --check # what tests/test_api_reference.py runs
python -m tools.changelog_fragments check # validate changelog.d/ fragments
pip install -e ".[docs]" && mkdocs build --strict # the `build` check, for docs changes
python -m build --wheel && bash scripts/smoke-wheel.sh dist/*.whl # the wheel gate in CIReal model, only when the change needs it and the key is in your environment
(export ARK_API_KEY=… is done by the person, not written by you):
openai_compatible("deepseek-v4-flash", api_key_env="ARK_API_KEY",
default_base_url="https://ark.cn-beijing.volces.com/api/coding/v3"). It costs
tokens; say in the PR what ran and at which tip.
Layout
agentdescent/: the package.evolution.py/async_evolve.pyare the loop;aggregator.py,population.py,policies.py,strategies.pythe pieces it composes;meta*.pythe meta-evolution stack;runstore.py,ledger.py,checkpoint.pypersistence;audit/the audit and oracle calibration;agents.pythe model adapters;cli.pyandmcp.pythe command line and MCP server;integrations/the host installers.integrations/: the host plugins (Claude Code, DSH).examples/: one folder per faithful algorithm port plus the framework demos.bench/: A/B and matrix runs.tools/: generators and checks.tests/: the offline suite.docs/: the MkDocs site (every page must be inmkdocs.yml's nav)..github/agent/: risk rules, review policy, controller config.
Style
- Follow the code around your change; match its comment density. Comments say why (a constraint, a measured trap, an issue number), not what.
- Commit messages in English, imperative subject, the reason in the body.
- Keep a change to one subject.
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
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.

