A message a plugin injects started a turn that superseded the session's
running background review and plugin forks at once, the same as a turn a
person started: the user's own self-learning review ended with no result.
A turn the gateway runs for a plugin's FIFO admission now waits up to 120 s
for the review and the launched forks already running on that session, then
cancels whatever is still running. An interrupt of the session agent ends
the wait early. A person's turn is unchanged and supersedes them at once.
Running the turn alongside the review instead is not an option: they share
the session id, so their usage would be counted twice.
The plugin LLM access guide says plugins should not rely on an injected
turn to cancel background work.
fork_session documents its aggregate input budget as the background review's
(auxiliary.background_review.max_input_tokens) with input_budget only able to lower
it. The ceiling was read from the fork's own routing block instead: {} without
task= (so the user's bound was ignored for the 75%-of-context default), and the
plugin's own register_auxiliary_task defaults with one, where max_input_tokens: 0
made the fork unlimited.
The bound is now the smallest of the fork's computed budget, the user's
background_review bound, and input_budget.
Tool Search defers every plugin tool by default, so the session's tools[] carry the
tool_search / tool_describe / tool_call bridges instead of the tool, and a fork naming
its own tool was refused tools_not_in_session.
A requested tool is now in the session when its captured tools[] advertise it, or when
those tools[] carry tool_call and the name is in the session's deferred catalog (the
classification the session's own tool_call unwrap uses). For a deferred tool, core
appends one line to the prompt: call it through tool_call, with the tool's parameters.
tools[] stay the session's, byte for byte. Inside the fork tool_call is only a carrier:
the dispatch guard sees its unwrapped target, so a tool_call to an unrequested, foreign,
core or connector tool is denied, and tool_search / tool_describe stay refused.
handle.actions lists the carried tool.
Fork ownership came from the plugin registration ledger by exact name, but
the dispatcher serves some names before the tool registry: connector names
(connectors__<connector>__<tool>), the session's memory-provider tools, its
context-engine tools, agent-level tools, legacy aliases and the Tool Search
bridge. A plugin that registered such a name had it admitted to its fork
while the call reached a connector, memory provider or context engine.
pre_registry_route() in agent/inline_tool_executors.py now answers which
seam serves a name before the registry, using the dispatcher's own checks;
the sequential and concurrent paths read the memory-provider and
context-engine membership through the same helpers. The fork allowlist
admits a name only when that predicate returns None and the plugin owns
the live registration: at request time against the lease's session agent
(token unspent on refusal), and when the fork starts against both the
session agent and the fork that dispatches.
_launch registered the job and marked it launched before building and starting
the worker, outside any exception handling. When spawn_context_thread or
Thread.start raised, the exception crossed fork_session's no-raise boundary,
the handle stayed running, the job stayed in the parent's registry and its
request exit was never published, so every later live turn spent the full
cancellation deadline waiting on a run that could never acknowledge. The
launcher now unregisters the job under the registry lock, publishes its
request exit and settles the handle error:spawn; fork_session returns that
settled handle.
A name deny list cannot classify tools it has never seen: another plugin's
a2a_call or meet_join starts a remote agent task or a detached worker, and an
MCP tool can trigger server-initiated sampling, all outside the fork thread's
tool whitelist and auto-denied approvals. The fork allowlist is now built from
ownership instead: the tools whose live registration is the requesting
plugin's (newest active ledger entry per name), plus core tools marked
fork-safe in FORK_SAFE_CORE_TOOLS (empty). A name dispatch reroutes before the
registry (inline agent tools, legacy aliases, the Tool Search bridge) never
counts as the plugin's own. Naming any other tool returns None with the token
unspent, and the dispatch guard reads the allowlist again when the fork starts.
background_review extra_tools is operator-configured and goes back to its
previous behavior; the consent text says the fork uses the plugin's own tools.
The worker closed the fork's auxiliary hook attempt on exit but left _loop_aux_task set,
so a fork object kept after the run still marked itself as auxiliary work. It is now
cleared in the same finally block, on every exit.
Only launched forks were registered on the parent, so the next turn's interrupt missed a
fork still queued for machine idle (the idle dispatcher launched it later) and one between
_launch's cancel check and its registration. Every fork is now registered on its parent
from the moment it is deferred or launched; the interrupt fences all of them, settling a
never-launched fork as cancelled, releasing its idle-queue slot and publishing its request
exit. _launch checks and registers under the same lock, and the interrupt records the turn
it fenced, so a fork of that turn reaching registration afterwards is refused.
delegate_task, message_agent, cronjob_manage and the Kanban moves that hand a task to a
dispatched worker run their loop outside the fork thread's dispatch guard: a delegate
child is built from the parent's toolsets and its worker enters through a copied context
that carries neither the thread-local whitelist nor the auto-deny approval callback.
fork_session now refuses a tools= list naming one (None, token unspent), the fork's
dispatch whitelist drops them however the job was built, and background_review
extra_tools ignores them with a warning.
Hermes' own background review (fork the live agent after a turn, run a
bounded multi-step prompt with a narrow tool list, cancel on the next live
turn) is now open to plugins as ctx.fork_session(token, prompt, *, tools=(),
max_iterations=8, input_budget=None, task=None, timeout=None), gated by the
new consent-only capability llm.session_fork.
Reused, not copied:
- Lease: post_llm_call's side_question_token backs a side question OR a fork
(side_question_lease.take_lease; same TTL, turn_moved_on, profile fence,
no token for unattended turns, one redemption per turn). The payload field
keeps its name for compatibility.
- Fork: build_cache_parity_fork(write_origin="plugin_fork:<id>") on a
context-bound thread in the captured turn context; same-model forks replay
the captured system prompt and tools[] byte-for-byte; routed forks get the
history digest. Persistence stays fully detached.
- Guardrails: the thread tool whitelist is the requested names (each must
already be in the session's tools[]); approvals auto-deny; the review's
input budget (a plugin can only lower it) and iteration cap (<= 16);
_BackgroundReviewRun admission so cancel_background_review_for_live_turn
interrupts plugin forks with the review under one bounded wait;
review_idle_queue deferral on the managed local runtime (enqueue takes a
dispatch callable; a newer fork of the same plugin supersedes the queued
one).
- Routing: task must be one of the plugin's register_auxiliary_task lanes,
resolved like auxiliary.background_review.
- Usage and hooks: release_cache_parity_fork bills the parent session as
plugin_fork:<id>; each fork loop request reports pre/post_auxiliary_call
(aux_task="plugin_fork", plugin_id) instead of pre/post_api_request.
Tool handlers inside the fork receive turn_origin="plugin_fork:<id>"
(live calls get no new kwarg), so a plugin can refuse calls from the live
agent. The handle exposes done/cancelled/outcome/result/actions/wait/cancel,
never the fork agent. Fails closed (None) without the capability, on a bad,
expired, spent or foreign token, a tool the session does not advertise, or
a task the plugin does not own.