Meu-Agent / agent
AGENTS.md0 starsChanged 10 days agoMITView on GitHub
Applies on top of the root AGENTS.md (prompt-caching invariant, facade + siblings rules). run_agent.py is the public facade: AIAgent is assembled from mixins (agent/turn_facade.py, client_lifecycle.py, stream_delivery.py, session_persistence.py, compression_facade.py, ...). Construction runs agent/agent_init.py::init_agent; a turn is agent/conversation_loop.py::run_conversation, which AIAgent.run_conversation forwards to after taking the session turn lease (turn_facade_lease.py). AIAgent.__init__ takes ~60 parameters (credentials, routing, callbacks, session context, budget, credential pool, ...) — read run_agent.py for the list; the subset you usually touch: base_url, api_key, provider, api_mode ("chat_completions" | "codex_responses" | ...),…
1 other project uses a version of this.
Adopted by
Most recently taken up by
- NousResearch/hermes-agentword for word, first seen Oct 2, 2026
Other versions1 project uses a version of this.
Word for word · 1
- NousResearch/hermes-agent★ 262k100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
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,439 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 repository57 other files it gives its agents.
- AGENTS.mdAGENTS.md
- cron/AGENTS.mdAGENTS.md
- gateway/AGENTS.mdAGENTS.md
- hermes_cli/AGENTS.mdAGENTS.md
- hermes_platform/AGENTS.mdAGENTS.md
- plugins/AGENTS.mdAGENTS.md
- pm/AGENTS.mdAGENTS.md
- skills/AGENTS.mdAGENTS.md
- tests/AGENTS.mdAGENTS.md
- tools/AGENTS.mdAGENTS.md
- tui_gateway/AGENTS.mdAGENTS.md
- web/AGENTS.mdAGENTS.md
- apple-notesSkill
- apple-remindersSkill
- findmySkill
- imessageSkill
- claude-codeSkill
- codexSkill
- computer-useSkill
- hermes-agentSkill
- architecture-diagramSkill
- ascii-videoSkill
- baoyu-infographicSkill
- claude-designSkill
- humanizerSkill
- local-pngSkill
- manim-videoSkill
- p5jsSkill
- popular-web-designsSkill
- songwriting-and-ai-musicSkill
- sdlc-reviewSkill
- email-inbox-triageSkill
- himalayaSkill
- youtube-contentSkill
- obsidianSkill
- document-to-action-itemsSkill
- google-workspaceSkill
- mapsSkill
- meeting-action-itemsSkill
- microsoft-officeSkill
- pdfSkill
- product-price-monitorSkill
- teams-meeting-pipelineSkill
- weekly-review-planningSkill
- arxivSkill
- competitor-news-monitorSkill
- grounded-citationsSkill
- xurlSkill
- codebase-inspectionSkill
- dogfoodSkill
- githubSkill
- requesting-code-reviewSkill
- simplify-codeSkill
- spikeSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- blocked-page-recoverySkill
The file
We split this AGENTS.md into the rules it gives an agent
4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 57
Prompt caching must not break: Never alter past context, change toolsets, reload memories, or rebuild the system prompt mid-conversation.
- Distinctive: line 64
Strict role alternation: Never two same-role messages in a row.
- Very specific: line 71
Never load an install-tree AGENTS.md as project context (PR #64611).
- Very specific: line 102
Every physical attempt funnels through _relay_sync_completion / _relay_async_completion / _relay_sync_stream, where …
≈ “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
agent/ — AIAgent, turn loop, prompt, compression
Applies on top of the root AGENTS.md (prompt-caching invariant, facade + siblings rules).
Shape
run_agent.py is the public facade: AIAgent is assembled from mixins (agent/turn_facade.py,
client_lifecycle.py, stream_delivery.py, session_persistence.py, compression_facade.py, ...).
Construction runs agent/agent_init.py::init_agent; a turn is
agent/conversation_loop.py::run_conversation, which AIAgent.run_conversation forwards to after
taking the session turn lease (turn_facade_lease.py). AIAgent.__init__ takes ~60 parameters
(credentials, routing, callbacks, session context, budget, credential pool, ...) — read
run_agent.py for the list; the subset you usually touch: base_url, api_key, provider,
api_mode ("chat_completions" | "codex_responses" | ...), model (empty → resolved from
config/provider later), max_iterations (default 500, shared with subagents),
enabled_toolsets/disabled_toolsets, quiet_mode, save_trajectories, platform
("cli", "telegram", ...), session_id, skip_context_files, skip_memory, credential_pool.
chat(message) -> str is the simple interface; run_conversation(user_message, system_message=None,
conversation_history=None, task_id=None) -> dict returns final_response + messages.
Agent loop (agent/conversation_loop.py + agent/turn_*.py)
Entirely synchronous, with interrupt checks, budget tracking, and a one-turn grace call:
while (api_call_count < self.max_iterations and self.iteration_budget.remaining > 0) \
or self._budget_grace_call:
if self._interrupt_requested: break
response = client.chat.completions.create(model=model, messages=messages, tools=tool_schemas)
if response.tool_calls:
for tc in response.tool_calls:
messages.append(tool_result_message(handle_function_call(tc.name, tc.args, task_id)))
api_call_count += 1
else:
return response.contentEach phase of an iteration is its own sibling, so a change to (say) overflow handling touches one
~600-line file: turn_preflight*, turn_iteration_prep, turn_request_assembly/turn_api_request,
turn_api_call, turn_api_error, turn_response_intake/turn_response_check,
turn_empty_response, turn_tool_round/turn_tool_validation, turn_overflow,
turn_truncation, turn_scripted_prelude (tool calls a prompt built-in plays before the first model
call), turn_context_compaction, turn_recovery, turn_recovery_autorecover
(post-exhaustion wait-and-retry ladder), turn_retry_state,
turn_stop_gates, turn_liveness, turn_usage, turn_final_response, turn_finalizer,
turn_summary. Find the phase with grep -rn "def X" agent/turn_*.py.
Messages use OpenAI format {"role": "system|user|assistant|tool", ...}; reasoning content is stored
in assistant_msg["reasoning"].
Agent-level tools (todo, memory, ...) are intercepted by agent/tool_executor.py through the
INLINE_TOOL_EXECUTORS table in agent/inline_tool_executors.py before handle_function_call().
Adding one: register in that table (no if name == ... chain); tools/todo_tool.py is the pattern.
Message-flow invariants (every change is reviewed against these)
- Prompt caching must not break. Never alter past context, change toolsets, reload memories,
or rebuild the system prompt mid-conversation. The system prompt is byte-stable for the life of
a conversation; the ONLY context mutation is compression. Anything that must inject content
mid-conversation rides a user message or tool result, never the system prompt: skill slash
commands (
agent/skill_commands.py) inject as a user message; subdirectoryAGENTS.mdhints (agent/subdirectory_hints.py) append to the tool result (head+tail truncated past_MAX_HINT_CHARS = 32_000; the truncation is logged, never queued as a chat status warning —context_file_max_charsdoes not raise that cap). - Strict role alternation. Never two same-role messages in a row; never a synthetic user
message injected mid-loop. The one exception is
/steer, delivered as a standalone user row after a tool result (assistant(tool_calls) → tool → useris legal on every provider path) — never smeared onto the already-persisted tool row, which append-only persistence would leave divergent from the live request. Cron deliveries live in their own session for this reason. - Context files (
agent/prompt_builder.py) load from the CWD only at startup and are capped (CONTEXT_FILE_MAX_CHARS/ dynamic cap from the context window /context_file_max_chars). Never load an install-treeAGENTS.mdas project context (PR #64611); subdirectory hints reject paths outside the working dir so~/.codex/AGENTS.md/~/.claude/CLAUDE.mdnever mix in. _last_resolved_tool_namesis a process-global inmodel_tools.py._run_single_child()intools/delegate_tool.pysaves/restores it around subagent execution; code reading it may see a temporarily stale value during child runs.
Compression (agent/compression_facade.py, conversation_compression.py, turn_context_compaction.py)
Manual /compress on every surface (CLI, gateway, TUI, ACP) runs through
agent/conversation_compression_manual.py::compress_now (one parser for here [N] / focus /
--preview / --aggressive; surfaces only parse their own argv, install after_messages and render).
Two layers: gateway session hygiene (85% threshold) and the agent ContextCompressor (50%,
configurable; per-model overrides; failure cooldown after provider-proven overflow). The algorithm
prunes old tool results first (no LLM call), then picks boundaries, then generates a structured
summary with the auxiliary compression model. In-place compaction keeps a single stable session
id; native Responses/Codex compaction paths are provider-specific. A stalled summary stream retries
once on auxiliary.compression.fallback_chain, and a repeated stall (a stall-class failure already on
the cooldown ladder) ends with the deterministic fallback summary through the same pipeline — never a
prune committed outside the lease/fence. Compression is the sanctioned
cache break — keep it the only one. Full detail:
website/docs/developer-guide/context-compression-and-caching.md.
Model and provider resolution
- Runtime provider/model resolution and its precedence:
website/docs/developer-guide/provider-runtime.md. Provider profiles are plugins (plugins/model-providers/<name>/, seeplugins/AGENTS.md);agent/model_metadata.pyholds context lengths and capabilities. - Auxiliary (side-LLM) work — curator, vision, embedding, title generation, session_search,
compression — resolves through
agent/auxiliary_client.py::_resolve_auto_route; each task can pin its ownprovider/model/base_url/reasoning_effortunderauxiliary:in config.yaml. Every physical attempt funnels through_relay_sync_completion/_relay_async_completion/_relay_sync_stream, whereagent/auxiliary_hooks.pyemitspre_auxiliary_call/post_auxiliary_call(observer-only, fail-open,aux_taskset); the main-looppre/post_api_requestevents must NOT fire for aux calls (#79733). - Fallback models and credential pools are resolution-chain code: E2E them with real imports
against a temp
HERMES_HOME, not mocks (root rubric).
i18n (agent/i18n.py + i18n_layers.py + i18n_languages.py)
t(key) resolves plugin packs (last registered wins) → user overlay <home>/locales/<lang>.yaml
(profile-scoped) → bundled locales/<lang>.yaml → the same for en → bare key; every layer is flat
dotted keys and may be partial. One merged dict per (home, lang) is cached; reset_language_cache()
(called by every pack registration and by config set display.language) drops everything.
supported_languages() is the live set (bundled ∪ overlay ∪ packs) and is what display.language
validation and _normalize_lang accept; SUPPORTED_LANGUAGES stays the bundled tuple. .tui.yaml /
.desktop.yaml pack files are opaque here beyond parse/flatten/serve (surface_catalog, RPC
i18n.catalog); for the tui surface the bundled locales/<lang>.tui.yaml is the bottom layer of what
surface_catalog serves (the TUI ships English only in TS). Endonyms for bundled ids live in i18n_languages.py and must agree with
apps/shared/src/i18n.ts.
Memory, context engines, curator
agent/memory_provider.py (ABC) + agent/memory_manager.py (orchestrator) drive memory-provider
plugins; agent/context_engine.py drives context-engine plugins; agent/image_gen_provider.py
image-gen plugins (all in plugins/AGENTS.md). agent/curator.py + curator_backup.py implement
the skill curator (skills/AGENTS.md). Cron sessions pass skip_memory=True by default — memory
providers intentionally do not run during cron.
- End-of-session memory extraction and provider
on_session_endrun wherever the session ends — turn, eviction, shutdown,tui_gatewayteardown — and the CALLER binds the owning profile's scope first (_run_release_in_profile_scope,_session_profile_runtime_scope); the agent never derives its home fromos.environat flush time (Path(_session_db.db_path).parentis the ground truth). Provider background work starts throughmemory_provider.py::spawn_context_thread(copies the contextvars), never a barethreading.Thread;title_generator.pyis the shape. agent/secret_scope.py::get_secretfails closed (UnscopedSecretError) only afterset_multiplex_active(True); the gateway, cron, migrate andserveset it. A new multi-home host must too, or every guard is silently off. Isolation is BETWEEN profiles; children inherit viacopy_context; a child'sUnscopedSecretErroris a spawn-site bug, never grounds for anos.getenvfallthrough. Delegated children carrydelegation_context.py:: DELEGATED_CHILD_ENV_MARKERvalued as the fenced Kanban board root, not a bare flag.
Tests
Loop/phase tests go in tests/agent/; patch the binding the phase actually reads (siblings often
from run_agent import X inside the function — root "patch where production reads"). Assert
message-shape invariants (alternation, byte-stable system prompt) rather than snapshotting prompt
text.
Long-form: website/docs/developer-guide/agent-loop.md, prompt-assembly.md,
context-compression-and-caching.md, provider-runtime.md, session-storage.md,
subagent-lifecycle-api.md.
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.

