Smart delegation pipeline for AI agents (up to 15-20% on costs) A shared RTK pipeline named laya-delegate cut mean cost per trial 13.9% across 48 SkillsBench trials on Claude Opus 5.5 run on 2026-10-18 and 2026-10-19, with reward unchanged at 0.81, according to self-reported numbers from the pipeline's author that RTK states it does not verify. The pipeline routes write and data tasks to a Haiku Explore sub-agent via a local Laya classifier served at http://127.0.0.1:41733/v1/systemone, and savings ranged from -30% on parallel-tfidf-search ($1.345 to $0.946) to +80% on debug-trl-grpo ($0.185 to $0.333). Across the 48 trials it logged 29 refusals, 28 Haiku sub-agent hand-offs in 24 trials, and 77.5K tokens removed by RTK output filtering, 14% of filtered command output. Numbers on this card are self-reported by the author's own rtk. rtk verifies nothing. rtk pipeline add github:aeppling/rtk-pipeline-laya-delegate rtk shows this pipeline's rules and asks before anything installs, and pins the install to a commit. A pipeline can rewrite the commands your agent runs, filter and replace what it reads, and send content to any upstream it declares — review the rules and install only what you trust. RTK does not review or endorse shared pipelines; the author is responsible for this repo, and you are responsible for what you install. - before read — delegate - bulk-read when file lines gt=350, score.need lte=0.65, whole file=true - before read — delegate - bulk-read when class.kind in= "write", "data" , recent calls matches='^ Bash|Read|Grep|Glob ^| | Bash|Read|Grep|Glob ^| ?$' - before shell — delegate - investigate when class.kind in= "write", "data" , command matches='^ cd ^;& + ;|&& ? ls|cat|head|tail|grep|rg|find|tree|pwd|echo|which|wc|file|stat|du|for|while|awk|nl|xxd|git|sed -n \b', recent calls matches='^ Bash|Read|Grep|Glob ^| | Bash|Read|Grep|Glob ^| ?$' - before shell — rewrite - rtk - after read — compress lockfile when basename in= "package-lock.json", "Cargo.lock", "yarn.lock", "pnpm-lock.yaml" - after shell — compress term when is rtk command=false - after search — compress matches when format="matches" - after web — compress web - proxy tool result — compress ansi, progress, dedup No recorded activity yet — run some sessions with this pipeline active, then re-run rtk pipeline share . laya-delegate — RTK output filtering + Laya-routed delegation to a Haiku sub-agent. Best gains Claude Opus 5.5, SkillsBench, 48 trials per arm vs stock Claude Code : -30% cost on parallel-tfidf-search, -19.5% on the full suite in one day, -13.9% over both days, reward unchanged. PREREQUISITE: Laya running locally. The routing decisions come from Laya @receptron/laya, a small local classifier; Node 20+, ~1.7 GB model download on first start , served at http://127.0.0.1:41733/v1/systemone rtk's classifier wire format , with RTK LAYA TOKEN exported. Without it, every Laya-gated rule stays silent and only RTK's output filtering applies. What it does - Laya labels the task: bug / setup / write / data. - On write and data tasks, RTK refuses the agent's first looking command or file read call 2 or 3 and asks it to hand the investigation to the Explore sub-agent on Haiku; the agent then works from the sub-agent's report. - Bug and setup tasks are left alone. - Whole-file reads over 350 lines that need little exact text are answered by a Haiku summary needs an Anthropic API key; skipped on subscription logins . - Everything else is standard RTK output filtering. Benchmark — SkillsBench, Claude Opus 5.5, 6 tasks, 4 trials per arm, run on two days 2026-10-18, 2026-10-19 with OFF stock Claude Code in the same batch: 48 trials per arm. Mean cost per trial, both days averaged: task OFF laya-delegate parallel-tfidf-search $1.345 $0.946 -30% python-scala-translation $1.002 $0.867 -13% fix-visual-stability $0.538 $0.448 -17% fix-build-google-auto $0.319 $0.303 -5% fix-erlang-ssh-cve $0.198 $0.191 -4% debug-trl-grpo $0.185 $0.333 +80% total $3.587 $3.088 -13.9% reward 0.81 - 0.81 Actions triggered over the 48 trials: 29 refusals, 28 Haiku sub-agent hand-offs 24 trials delegated , 77.5K tokens removed by RTK filtering 14% of filtered command output . Savings come from write/port tasks; on short bug tasks the agent's own path dominates debug-trl-grpo: one or two long trials per day . Details: RESULTS.md, results.tsv. schema version = 1 pipeline name = "laya-delegate" extends = "rtk:posthook", "rtk:delegate-reads" upstream.judge provider = "laya" model = "laya" base url = "http://127.0.0.1:41733/v1/systemone" api key env = "RTK LAYA TOKEN" timeout secs = 60 upstream.haiku provider = "anthropic" model = "claude-haiku-5-5" timeout secs = 90 classifier.need upstream = "judge" question = "score" instructions = "How much of this file's exact text does the agent need for its next step?" rubric = "none: a short summary is enough", "a few exact lines", "most of the file verbatim" input chars = 2000 classifier.kind upstream = "judge" question = "choice" instructions = "What kind of work is this coding task?" input chars = 2000 min confidence = 0.0 classifier.kind.labels bug = "find and fix a bug by reading source code closely" setup = "understand or repair a build, configuration, dependency or environment" write = "write new code, a script or a port" data = "analyse data or files and report results" task.investigate kind = "digest" upstream = "haiku" temperature = 0 context = true task.bulk-read kind = "summarize" upstream = "haiku" temperature = 0 context = true instructions = "You read a file for a coding agent that will NOT see it, only your reply. First answer what the agent needs for its current step, in a few terse lines, with exact identifiers. Then map the file: one line on what it is; every class, function and method with its exact signature, in file order. Then quote verbatim, grouped under the name of the function that contains them, the lines whose exact text the agent would most need for its step non-obvious arithmetic, constants, conditions, error handling, config values . Never give line numbers. Never paraphrase code you quote. No advice, no headings. End with exactly: Exact text: grep -n a quoted line, then Read that file with offset and limit, at most 350 lines. " override.shunt-large-read enabled = false hook.before tool.read name = "answer-big-reads" when = { file lines gt = 350, whole file = true, "score.need lte" = 0.65 } action = "route" task = "bulk-read" mode = "answer" directive name = "explore-in-subagent" text = """ When RTK asks you to hand an investigation to the Explore sub-agent, call it on the haiku model Agent tool: subagent type "Explore", model "haiku" with one precise question built from the task, ask it for file paths, line numbers and the exact lines you will need, and work from its report instead of repeating its searches. """ hook.before tool.shell name = "delegate-investigation" when = { command matches = "^ cd ^;& + ;|&& ? ls|cat|head|tail|grep|rg|find|tree|pwd|echo|which|wc|file|stat|du|for|while|awk|nl|xxd|git|sed -n \\b", recent calls matches = "^ Bash|Read|Grep|Glob ^| \\| Bash|Read|Grep|Glob ^| ?$", "class.kind in" = "write", "data" } action = "route" task = "investigate" mode = "suggest" message = "Do not run this search or open these files yourself: hand the investigation to the Explore sub-agent Agent tool: subagent type \"Explore\", model \"haiku\" with one precise question, and ask it for file paths, line numbers and the exact lines you will need. Then work from its report." hook.before tool.read name = "delegate-investigation-read" when = { recent calls matches = "^ Bash|Read|Grep|Glob ^| \\| Bash|Read|Grep|Glob ^| ?$", "class.kind in" = "write", "data" } action = "route" task = "bulk-read" mode = "suggest" message = "Do not run this search or open these files yourself: hand the investigation to the Explore sub-agent Agent tool: subagent type \"Explore\", model \"haiku\" with one precise question, and ask it for file paths, line numbers and the exact lines you will need. Then work from its report." Measured by rtk https://github.com/rtk-ai/rtk v1.0.1 on 2026-10-19. Install this pipeline: rtk pipeline add