Three subagents, three identical system prompts: Hermes now makes them share one cache


You open the usage dashboard and yesterday cost more than twice the usual. The workload was ordinary: you asked Hermes to fan out three subagents over three documents. The tasks were different, but a large part of each child’s system prompt was byte-for-byte the same — the core instructions, the skills index, the tool definitions. On the bill, that shared block was written three times.

Nothing was misconfigured. The cache breakpoints were simply in the wrong places. Two PRs merged on November 12 (#153385 and #153275) fixed that: sibling subagents now share one cache prefix.

What prompt caching is actually charging you for

Most model providers do the same thing. If the first N bytes of this request match a previous request exactly, that stretch is billed as a cache read — a fraction of normal input price. The first time it appears it is billed as a cache write, slightly above plain input.

One constraint decides everything: the prefix has to match byte for byte. Insert a sentence in the middle and nothing after that point counts as a hit.

Hermes built a child’s system prompt out of three pieces, in order: the core text, the rest of the session prompt (skills index, footer), and the per-task text that delegate_task appends at API time. Two breakpoints sat in it — one after the core text, one at the very end. The catch: the per-task text differs for almost every child, so the second breakpoint covered bytes no sibling shared. Each child read the tools and core text from cache, then re-wrote the skills index, which was identical for all of them.

Change one: the task moves into the child’s first user turn

This is the structural fix. A child’s system prompt now carries only what siblings genuinely share: the subagent line, the workspace path, the project context files (AGENTS.md / CLAUDE.md), and the completion instructions.

The task itself — the context the parent supplies plus the goal — becomes the child’s first user turn, context first:

CONTEXT:
<background material from the parent>

TASK:
<the specific job>

The order is deliberate. A parent often hands the same brief to several children and only varies the goal, so putting the context first and registering it as the message’s stable prefix gives it a cache breakpoint of its own — the part every sibling hits. One more detail matters: that first turn is now pinned through compaction (ContextCompressor.pin_task_turn). Before, the compressor stopped protecting early turns after its first pass, so a steered child could lose its brief at the second one.

Change two: one cache scope per parent’s children

The second miss was subtler. On OpenAI-family models, automatic caching matches only inside the cache scope the client sends; on the Codex backend the scope is literally the session_id request header. Every child used to send its own session id, so even byte-identical prompts shared nothing.

Now every child of one parent shares a scope derived from the parent’s:

sub_<sha256(parent_scope)[:24]>

It keys prompt_cache_key, and on the Codex backend it replaces the child’s own session_id header. It is deliberately not the parent’s scope: a delegation tree adds one cache bucket instead of joining its parent’s. Slot-keyed routes (xAI) ignore it and behave as before.

Change three: move the skills-index breakpoint one slot earlier

The third piece (#153275) fixes the other end — the session prompt itself. A session with appended text now sends its system prompt as three parts: static tier, rest of the session prompt, appended text.

A request only has so many breakpoints (four on most providers). A first call has just one message to mark, so it has one spare — and that spare is now spent at the end of the session prompt, exactly where the skills index ends. Every later sibling reads that copy instead of writing it.

The numbers, on a 147-skill library, for a child whose task text differs from its sibling’s:

Metric Before After
First-call cache read 16,214 tokens 22,154 tokens
First-call cache write 10,781 tokens 4,839 tokens
Saved per such child — 5,940 tokens written

Real delegate_task children, first call, context differing from a sibling’s:

Route, model Before: read of prompt After: read of prompt
Nous, gpt-5.6-luna 0 of 7,622 7,574 of 7,627
Codex subscription, gpt-5.6-luna 0 of 7,631 7,424 of 7,631
Nous, claude-fable-5.2 6,354 of 11,904 11,761 of 11,909

That last row is the interesting one: Claude children used to share roughly half their prompt. Now they share nearly all of it, because no per-task text sits in the system prompt cutting the prefix short.

What you have to do: nothing at all

No new config key, no flag. It is a path optimisation, not a feature toggle:

  • Upgrade past these two PRs and parallel delegate_task fan-out benefits automatically.
  • The gain scales with two things: how big your skills library is (longer index) and how many children you spawn at once (more reads of the same prefix).
  • Moving the brief into the first user turn applies to every session that adds text at API time, not only subagents: a CLI or gateway personality, API-server instructions — same path.
  • Untouched: the direct-Anthropic layout that spends a breakpoint on the tools array.

If you are counting tokens, read this alongside two related posts: context token optimisation covers how much history survives compression, while multi-profile cache sharing is the other scope problem — paying twice after a gateway restart, rather than siblings rewriting the same block. Both show up on the same invoice.

Release status

Both PRs merged into main on November 12, 2026. v0.23.1 shipped on November 10 — two days earlier — so it is not in that release. Either wait for the next one or install from main. To check whether your install has it, spawn two children with different task text and look at the first call’s cache read versus write counts.

Update (2026-11-17): these changes shipped in v0.23.2 (November 16) — hermes update brings them in. The “not in v0.23.1” wording above is a snapshot from publication time.

If you already run remote subagent orchestration, pair this with live subagent orchestration and subagent failure wake so that saving money and not losing results are handled together.