laya-delegate
Sends file reads and shell commands to a worker model, and briefs your agent.
Result
Total cost
−13.9%
per trial · quality unchanged
Author's benchmark Claude Opus 5.5 · 48 trials per arm
rtk pipeline add github:aeppling/rtk-pipeline-laya-delegate@6452459d550853f14fac8a400fb6704cea983900 Try it first without changing anything
rtk pipeline add github:aeppling/rtk-pipeline-laya-delegate@6452459d550853f14fac8a400fb6704cea983900 --shadow
Records what it would have done. Then rtk pipeline eval laya-delegate shows the numbers; promote or --discard.
Benchmark
| Task | stock Claude Code | laya-delegate | Change | reward |
|---|---|---|---|---|
| parallel-tfidf-search | $1.34 | $0.95 | −29.7% | 1 → 1 |
| python-scala-translation | $1.00 | $0.87 | −13.5% | 1 → 1 |
| fix-visual-stability | $0.54 | $0.45 | −16.7% | 0.25 → 0.25 |
| fix-build-google-auto | $0.32 | $0.30 | −5% | 1 → 1 |
| fix-erlang-ssh-cve | $0.20 | $0.19 | −3.5% | 1 → 1 |
| debug-trl-grpo | $0.18 | $0.33 | +80% | 0.6 → 0.6 |
| All tasks, mean per trial | $3.59 | $3.09 | −13.9% | 0.81 → 0.81 |
SkillsBench · Claude Code on Claude Opus 5.5 · 48 trials per arm · Oct 18–19, 2026. Declared by the author in benchmark.toml, not reproduced by RTK
· Write-up · Per-trial data
How it works
Based on RTK's standard output compression (rtk:posthook), RTK's large-read delegation (rtk:delegate-reads).
Before a file read, if the file is over 350 lines, the whole file is read and the need decision step scores at most 0.65: hands it to the bulk-read task, summarised by Anthropic (claude-haiku-5-5).
Exact condition
file_lines_gt=350, whole_file=true, score.need_lte=0.65Before a file read, if the recent calls match a pattern and the task was labelled write or data: hands it to the bulk-read task, summarised by Anthropic (claude-haiku-5-5).
Exact condition
recent_calls_matches="^(Bash|Read|Grep|Glob) [^|]*( \\| (Bash|Read|Grep|Glob) [^|]*)?$", class.kind_in=["write", "data"]Before a shell command, if the command matches a pattern, the recent calls match a pattern and the task was labelled write or data: hands it to the investigate task, digested by Anthropic (claude-haiku-5-5).
Exact condition
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"]
- Switches the built-in rule
shunt-large-readfromrtk:delegate-readson or off. This changes when calls are redirected.
Uses 2 decision steps (need and kind), answered by a local service on 127.0.0.1, to decide when the rules above apply.
Where your data goes
| Service | Model | Where it runs | Key it reads |
|---|---|---|---|
judge | laya | On your machine · 127.0.0.1 | RTK_LAYA_TOKEN pipeline-specific key |
haiku | claude-haiku-5-5 | Anthropic's API | ANTHROPIC_API_KEY (your usual key) |
What it tells your agent
- Standing instruction to your agentexplore-in-subagent
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.
- Message your agent sees when a call is redirectedused by 2 rules: delegate-investigation-read, delegate-investigation
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.
Prompts for helper models5 texts, never shown to your agent
- Instructions for a helper modelbulk-read
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.)
- Question a decision step asks a modelneed
How much of this file's exact text does the agent need for its next step?
- Scoring guide of a decision stepneed
none: a short summary is enough a few exact lines most of the file verbatim
- Question a decision step asks a modelkind
What kind of work is this coding task?
- Possible answers of a decision stepkind
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
pipeline.toml
Exact file at commit 6452459, reviewed Oct 23, 2026. Comments are the author's own; numbers in them are self-reported.
View on GitHub
# 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."