2026-11-26 15:48 UTC

Author-reported 13.9% cost reduction from a Haiku-delegation pipeline; evidence is preliminary

state: watchingheat: mediumuncertainty: mediumrelevance: mediumtoken-optimization agent-delegation cost-reduction rtk-pipeline laya-classifier haiku-subagentadriencloud (HN poster)aeppling (GitHub repo owner)

What is this?

A GitHub pipeline shared by a Hacker News poster combines RTK output filtering with a local Laya classifier that routes some coding-agent reads and investigations to a Haiku sub-agent. Its author reports a SkillsBench test on Claude Opus 5.5: mean cost per trial fell 13.9% across six tasks, with reported reward unchanged; individual task results ranged from 30% lower cost to 80% higher. These are author-reported results, and the pipeline page says RTK does not verify them. A web result also points to prior disagreement over whether RTK lowers costs, so the claimed benefit remains uncertain.

Why it matters

An interesting, reproducible-in-principle approach to lowering coding-agent costs: combine output compression with a local task classifier that delegates selected work to a cheaper Haiku sub-agent. The author’s benchmark is small and self-reported, with sharply mixed task results, so it is a promising experiment—not established evidence that the pipeline reliably saves money. It also requires local setup and, for some features, an Anthropic API key.

Current assessment

The repository describes an RTK pipeline that uses a local Laya classifier to route some write/data investigations and large-file reads to a Haiku sub-agent, while applying RTK output filtering. Its author reports a Claude Opus 5.5 SkillsBench comparison across six tasks, four trials per arm on each of two days (48 trials per arm): mean cost per trial fell from $3.587 to $3.088, or 13.9%, with reward unchanged at 0.81. Results varied substantially: reported costs fell 30% on parallel-tfidf-search, while debug-trl-grpo rose 80%. The author also reports 28 Haiku hand-offs across 24 trials and 77.5K tokens removed by filtering. These figures are self-reported; the pipeline page explicitly says RTK verifies nothing, and the supplied evidence does not establish statistical significance or independent replication. A supplied web result points to prior RTK benchmark criticism: a Quesma report says reduced input per turn did not translate to lower total input when turns increased; a separate search snippet describes a reported RTK follow-up saving as not statistically established (p=0.305). Those results concern RTK more broadly, not this specific pipeline, but underline that token reduction and total cost savings are not equivalent. Track whether independent tests reproduce the cost and reward results, and whether delegation overhead or task mix changes the outcome. The pipeline requires Laya running locally; its large-read summarization feature needs an Anthropic API key and is skipped on subscription logins. The repository also warns that shared pipelines can rewrite commands, filter content, or send content to declared upstreams, so users should review rules before installing.

Measured heat

now 0 pts/hpeak 0 pts/hcomments 0/hpeers p10momentum: steady1 platformsage 893h
points/hour across evidence · reading as of 2026-11-27 02:23:58.509736+11:00 · deterministic, not a model opinion

How the heat travelled

10-20 10:30⭐ origin directly observedSmart delegation pipeline for AI agents (up to 15-20% on costs)
adriencloud on hacker news
—
10-20 10:30amplified on hacker news 👑hn.story.50164018
adriencloud
peak 1 · 3 comments · 99% of case engagement
10-20 11:21our radar first saw it · +0.8hdiscovery anchor: hn.story.50164018—
pace: p34 vs 879 stories at the 720h mark (now 893h old) — ahead of agentprobe-failure-injection-agent-testing (1.3x), behind agentplay-coding-agent-cost-dashboard (0.8x)

Evidence (1) — ⭐ canonical anchor

sourceobjectauthorscorecomments
🟧 hn ⭐Smart delegation pipeline for AI agents (up to 15-20% on costs)
Retrieved article excerpt

Open article · Retrieved 2026-10-20T11:26:57.620391+00:00

# rtk pipeline · laya-delegate

Numbers on this card are self-reported by the author's own rtk. rtk verifies nothing.

## Install

```
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.

## What it does

- **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`.*

## user pipeline.toml

```
# 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 <url-of-this-card>`
adriencloud13

Interpretation history

Decision trace