Loop Pipeline Router logo

Loop Pipeline Router

Community
AnthonyAlcaraz
loop-pipeline-router

The conditional-edge routing that turns a validate node into a bounded self-correcting loop (Ch5 Loop Pipeline + Error-handling strategies, Examples 5-6/5-9). Consumes a validation result, an error severity (correctable vs fundamental), and a retry budget, and returns exactly one of: proceed, refine (loop back with a remaining retry), fallback (alternative strategy once retries are exhausted), or terminate-with-partial (fundamental error). The finite retry budget is the explicit bound that prevents infinite loops. Use when first-attempt success is unrealistic and validation can identify correctable errors — plan refinement, documentation-gap re-requests, transient-failure recovery. NOT for strict sequential pipelines with no feedback (use a sequential pipeline), NOT for parallel branch reconciliation (that is a merge/tree concern), NOT as a substitute for the validator itself (this routes on the validator's output; it does not validate).

Overview

PublisherAnthonyAlcaraz
Repositoryagentic-graph-rag-skills
Skill nameloop-pipeline-router
Stars
29
Forks
9
Bundled files
2
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by AnthonyAlcaraz on GitHub. Read the source before you install it.

Installation

Install the Loop Pipeline Router AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills/tree/main/skills/reasoning-planning/loop-pipeline-router
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills.git /tmp/agentic-graph-rag-skills
mkdir -p .claude/skills
cp -r /tmp/agentic-graph-rag-skills/skills/reasoning-planning/loop-pipeline-router .claude/skills/loop-pipeline-router
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Loop Pipeline Router in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Loop Pipeline Router on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Loop Pipeline Router is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Loop Pipeline Router

Overview

Loop pipelines introduce feedback for self-correction when perfect first-attempt reasoning is unrealistic. The decision that makes a loop a loop is the conditional edge after the validate node. Naively this is "valid -> proceed, else -> retry" (Example 5-6), but production needs the nuance of Example 5-9: distinguish correctable errors (refine) from fundamental ones (stop), and handle the retries-exhausted case (fall back to an alternative strategy) so the loop neither terminates prematurely nor spins forever.

The unified decision table:

valid                            -> proceed
correctable + retries remaining  -> refine (retry_count += 1, loop back)
correctable + retries exhausted  -> fallback_strategy
fundamental                      -> terminate_with_partial

The finite retry budget (Example 5-6's retry_count < 3 / recursion_limit) is the explicit termination guarantee. An invalid result with no error diagnostic is treated as fundamental — you cannot safely refine what you cannot diagnose.

In the DevOps latency investigation (account 123456789012), document verification on a related claim returns "incomplete" — the operative report lacks anesthesia-time records. That is a correctable error: refine (request the specific missing documentation, re-verify), bounded to three request cycles before escalating. A schema-level contradiction in the plan ("synchronous AND event-driven for the same operation") is fundamental: terminate with partial results rather than burn the retry budget on an unfixable error.

When to Use

  • First-attempt success is unrealistic and a validator can flag correctable errors
  • Documentation-gap re-requests, plan refinement, transient-failure recovery
  • You need a guaranteed-terminating self-correction loop with an audit trace

Phrases: "loop pipeline", "refine and re-validate", "retry with feedback", "correctable vs fundamental error", "fallback planner", "recursion limit".

When NOT to Use

  • Strict sequential pipeline with no feedback (use a sequential pipeline)
  • Parallel-branch reconciliation (that is a merge/tree concern)
  • The validator does not distinguish error kinds (then add severity to the validator first; routing on undifferentiated errors collapses to blind retry)

Process

StepInputActionOutputVerification
1is_valid, error, retry_count, max_retrieslib.route_after_validation(...)RouteResult(decision, retry_count, rationale)valid->proceed; correctable+budget->refine(+1); correctable+exhausted->fallback; fundamental->terminate
2attempt_fn, validate_fn, max_retries, fallback_fnlib.run_loop(...)dict (decision, candidate, iterations, trace)loop always terminates; iterations <= max_retries
3run_loop traceinspect traceper-iteration routing decisionseach refine increments retry_count; one terminal decision

Rationalizations

Agent rationalizationDocumented rebuttal
"Just retry until it passes."Unbounded retry is the infinite-loop failure mode. The chapter bounds it explicitly (retry_count < 3, recursion_limit=10). After the budget, fall back — do not spin.
"Any failure should retry."No — fundamental errors do not become correct by retrying (Example 5-9 routes them to terminate_with_partial). Retrying a schema contradiction wastes the whole budget on an unfixable error.
"If retries run out, just give up entirely."Exhausted correctable retries route to a fallback strategy, not termination. The chapter distinguishes "retries exhausted" (try another approach) from "fundamental" (stop).
"An invalid result with no error detail — I'll guess and refine."You cannot safely refine what you cannot diagnose. Treat missing-diagnostic-on-invalid as fundamental and terminate with partial; surfacing it beats guessing.

Red Flags

  • Every error is classified correctable. The validator is not detecting fundamental errors; the loop will exhaust the budget then fall back on genuinely unfixable inputs.
  • iterations regularly hits max_retries then falls back. The refine step is not actually improving the candidate — the feedback is not making it back into attempt_fn.
  • No terminal proceed across many runs. The validator threshold may be unsatisfiable, or refine is a no-op; the loop is theatre.

Non-Negotiable Verification

  1. Run the benchmark battery. python cli.py benchmark must report:
    • valid -> proceed; fundamental -> terminate_with_partial
    • correctable with budget -> refine and increments retry_count
    • correctable with budget exhausted -> fallback_strategy
    • invalid-with-no-error -> terminate_with_partial
    • run_loop terminates and never exceeds max_retries iterations
    • a candidate that becomes valid after N refines yields proceed at N
  2. Verify CLI help. Exits 0 and prints the SKILL.md description.

Security Posture

  • Prompt injection. Validation results and error diagnostics are untrusted input (often produced by an LLM validator over untrusted content). The router only maps them onto a fixed decision table; a spoofed severity can bias routing - mislabeling "fundamental" as "correctable" burns retries, the reverse suppresses recovery - but nothing is executed.
  • Data exfiltration. No network calls, no file writes. Candidates and error details pass through in-process; the routing trace goes to stdout and the caller owns downstream piping.
  • Privilege escalation. No shell invocation, no eval. The bounded retry budget is also a resource-abuse guard: an adversary who can keep validation failing cannot force an infinite loop, and the fallback path must not carry more privilege than the primary path.

Source Attribution

Distilled from Agentic GraphRAG (O'Reilly, by Anthony Alcaraz and Sam Julien) Ch5 — Reasoning & Planning: "Loop Pipeline: Iterative Refinement" (Example 5-6, check_plan_validity) and "Error-handling strategies" (Example 5-9, route_after_validation). The bounded-loop / recursion_limit guarantee is from Example 5-6.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Loop Pipeline Router AI skill do?

The conditional-edge routing that turns a validate node into a bounded self-correcting loop (Ch5 Loop Pipeline + Error-handling strategies, Examples 5-6/5-9). Consumes a validation result, an error severity (correctable vs fundamental), and a retry budget, and returns exactly one of: proceed, refine (loop back with a remaining retry), fallback (alternative strategy once retries are exhausted), or terminate-with-partial (fundamental error). The finite retry budget is the explicit bound that prevents infinite loops. Use when first-attempt success is unrealistic and validation can identify cor...

Why use Loop Pipeline Router on TypingMind?

Because you install it once and use it with any model. Loop Pipeline Router is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Loop Pipeline Router in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills/tree/main/skills/reasoning-planning/loop-pipeline-router. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Loop Pipeline Router?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Loop Pipeline Router?

As many as you like. As long as a model supports skills, you can use Loop Pipeline Router with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Loop Pipeline Router AI skill free?

Yes. It is published on GitHub by AnthonyAlcaraz under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇