agentleFS
samugit83samugit83/redamon/skills/agent-in-the-loop/SKILL.md

agent-in-the-loop

Skill3.4k starsChanged 8 months agoMITView on GitHub

Agent in the Loop: the pseudo-model loop/mcp makes every model call of a chat run a step that an external MCP client (Claude Code, Codex) answers over the inbound MCP server. A loop model must answer only inside its own run scope, never wait outside one, never be retried, and never let the outside brain approve its own dangerous actions. Trigger: editing agentic/agent_in_the_loop/; adding a model call site or a retry loop in the agent; adding a path that builds an LLM from a model id; editing webapp/src/lib/mcp/loop*.ts, webapp/src/lib/agentInTheLoop.ts, or the LOOP_STATUS handling in the chat drawer.

Trending

More talk lately.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 1 mentionJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 10 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the samugit83/redamon repository that our weekly crawl found: only 11 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Who's talking about samugit83/redamon

The biggest 5 of 11 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 11

Talked about on GitHub and Bluesky (11 times).

On GitHub · 10

5 more on GitHub

On Bluesky · 1

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    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
  1. Very specific:

    Keep LOOP_STEP_DEADLINE_S above LOOP_NO_DRIVER_GRACE_S: the deadline counts from the step's opening, so a lower one ends a pause first.

    line 52
  2. Very specific:

    A loop step belongs to the person, never the tenant: Run scopes and steps are keyed by the session's person (get_identifiers.

    line 73

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill 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
SKILL.md

When to Use

  • Changing the step broker, the adapter, the prompt document or the /loop/* routes.
  • Adding a model call to the agent, or a loop that retries model calls.
  • Adding any endpoint, job or feature that builds a chat model from a model id.
  • Changing the loop MCP tools, their scope, the driver-token rule, or the drawer's loop status.

Critical Rules

  • A loop model answers ONLY inside a live run scope of its session that uses the loop. Its identity comes from get_broker().scope_for_session(current_log_session_id), never from current_user_id, current_project_id or current_session_id: initialize_node calls the guardrail and the classifier before any node sets those (model.py, agent_context.py).
  • A new path that builds an LLM from a model id refuses loop/ with refuse_loop_model() / LoopModelNotSupportedHere (code loop_model_not_supported_here): no chat run, no driver, a wait that never ends (llm_builder.py, the api.py builders). Feature pickers filter it with excludeLoop, saves refuse it.
  • Loop errors are never retried. They carry no_retry = True and their messages contain no transient phrase (timeout, connection, a bare 5xx); is_transient_llm_error checks the marker first. A new loop that retries on ANY exception must break on getattr(e, "no_retry", False) (errors.py, phase.py is the example).
  • A limit that can end a run is told to both sides. An interactive driver makes no call while its person talks to it, so the driver reads runEndsIfSilentSeconds on every step and the pack tells it never to end its turn while a run is live; the drawer gets noDriverEndsInSeconds and shows the clock time the run ends. A new timer or cap that ends a run goes into both, or a driver that read only deadlineInSeconds believes it has longer. Keep LOOP_STEP_DEADLINE_S above LOOP_NO_DRIVER_GRACE_S: the deadline counts from the step's opening, so a lower one ends a pause first.
  • A run that ends for want of an answer keeps what it found. The report node's fallback is built from state alone (last Fireteam wave, session findings, how to resume), since after a lost driver every later step, the report included, fails at once (generate_response_node.py).
  • A new model call site gets an llm_purpose(...) label, or its step reaches the driver as other with a text answer format (purpose.py).
  • A loop run follows the project's REQUIRE_TOOL_CONFIRMATION, and an unattended run shows it. The gates read the setting as in a provider run; _stream_graph passes it to run_scope(tool_confirmation=...), the drawer's loop_status carries it as toolConfirmation, and false puts a red risk icon next to the Agent in the Loop chip (loopStatus.ts). It stays out of the driver's view and the step (a step change bumps contractVersion).
  • Only a person answers approvals, questions and dangerous-tool confirmations, and only one who may take that decision. No MCP tool may answer them (loopTools.ts). Before anything runs or is saved the socket checks the answer twice: _refused_without against the ticket's cap, then _refused_now, which asks the webapp again and refuses when it cannot be reached; an admitted answer is saved with decision_actor() (sub, act under act-as), as _record_decision does (websocket_api.py). A new kind of answer takes all three.
  • A loop step belongs to the person, never the tenant. Run scopes and steps are keyed by the session's person (get_identifiers; the token's user on the MCP side); the project's owner is only the graph tenant (get_tenant_id). A driver reaches a shared project only at agent:loop's level through mcpProjectAccess (loopProjects in loopTools.ts).
  • A driver token holds no write or exec scope besides agent:loop. Compute it from MCP_SCOPE_COPY with loopTokenProblem, never a hand list; the loop tools refuse wider tokens (loopScopes.ts).
  • A person picks the brain. MCP writes, presets, imports and user defaults never set a loop model (loopModelRefusal, the preset checks, rememberedDefaults).
  • Any change to the step shape bumps contractVersion (agent CONTRACT_VERSION, the skill pack's LOOP_CONTRACT_VERSION), so a client's out-of-date skill says so.
  • A new loop tool joins LOOP_TOOL_NAMES (withdrawn while the switch is off), every MCP test that stubs MCP_KALI_EXEC_ENABLED also stubs AGENT_IN_THE_LOOP_ENABLED, then npm run docs:mcp (the mcp-server-tools skill).
  • loop_status and the step views carry no prompt or answer text; the WebSocket frame is sent, never persisted.

Where things live

ConcernFile
Switch, tunables, is_loop_model, is_loop_llmagentic/agent_in_the_loop/__init__.py
Steps, leases, deadlines, no-driver rule, dedup, pruningagentic/agent_in_the_loop/broker.py
Run scope around every streaming graph loopAgentOrchestrator._stream_graph in agentic/orchestrator.py
MCP tools, client, driver-token rulewebapp/src/lib/mcp/loopTools.ts, loopClient.ts, loopScopes.ts
Skill pack per clientwebapp/src/lib/mcp/loopSkill.ts
Drawer status stringswebapp/src/app/graph/components/AIAssistantDrawer/hooks/loopStatus.ts
Fallback report when a loop step failsagentic/orchestrator_helpers/nodes/generate_response_node.py

Resources

  • docs/readmes/README.MCP.SERVER.md - the inbound MCP server and its security model
  • The wiki page Agent-in-the-Loop - setup for Claude Code and Codex, how it works, limits
  • Related skills: llm-provider-integration, mcp-server-tools, rbac-authz, redamon-testing

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.