Commit Graph

377 Commits

Author SHA1 Message Date
Teknium
3ae67dc3d6 fix(delegation): stopping a turn no longer kills background subagents
Ctrl+C, Esc, the Desktop/TUI Stop button, a message that interrupts and
an ACP cancel end the current turn. They also called
async_delegation.interrupt_for_session, so every background subagent the
session had dispatched died with the turn: one Ctrl+C took down a running
/review and both of its sub-reviewers. A background subagent is
independent of the chat that spawned it (Teknium ruling), so a turn stop
now hard-cancels only the turn:

- gateway SessionAuthority.interrupt (Desktop, Ink, classic CLI view,
  ACP-through-gateway, messaging interrupts, api_server run cancel)
- tui_gateway session.interrupt (legacy Desktop/TUI stop)
- acp_adapter cancel

The explicit /stop command still ends them (CLI and Ink process.stop,
gateway /stop busy and idle paths), and so does closing or resetting the
session. Reverses the turn-stop half of b71359066c and 659e55ac71d;
tests/gateway/test_canonical_stop_hard_cancel.py now pins the delegation
surviving a canonical Stop.
2026-10-25 18:33:24 -07:00
Teknium
f219708926 feat(tts): fold voice search into text_to_speech's ElevenLabs schema (find_voices)
Teknium: the ElevenLabs variant of text_to_speech is where voice search belongs, not a
separate tts_voices tool. The ElevenLabs schema now carries voice_id plus a find_voices
object (text optional there); other providers' schema is byte-identical to main.

Live search findings folded in: the library is the default source and sorts by a year of
usage (most-used first); use_case (e.g. characters_animation) and sort filters; library
voices with a custom credit rate show credit_rate; the description tells the model the
library matches words literally, so a role word that finds nothing ('dwarf') falls back to
describing the sound ('gravelly old' + filters).
2026-10-25 15:58:23 -07:00
Teknium
c975831fbc feat(tts): let the agent pick ElevenLabs voices (voice_id + paginated tts_voices search)
With tts.provider: elevenlabs, text_to_speech gains an optional voice_id and a new
tts_voices tool searches the user's account voices (/v2/voices) or the public
Voice Library (/v1/shared-voices) with query/gender/age/accent/language filters and
an opaque next_page cursor. Both are gated on the ElevenLabs provider (dynamic
schema override + check_fn), so every other provider's surface is unchanged. A
per-call voice_id never rewrites config; a stale one sent under another provider is
ignored with a warning.
2026-10-25 15:58:23 -07:00
unsupportedpastels
04f52d6bed fix(acp): an equal snapshot no longer cancels a pending picker update
Review F1 (P2): _project_config recorded every observation before
comparing, so a snapshot with the same settings that landed while an
earlier projection was building its model catalog (a typed /model's own
session.resume on the same provider) replaced the slot and returned; the
first projection then saw a different object and dropped its send. Zed's
pickers stayed on the old model or mode. An equal observation now returns
before taking over the slot, so the projection holding the change sends.

Refs #143547
2026-10-25 11:37:02 -04:00
unsupportedpastels
d23579a1e5 fix(gateway): refuse cancelling steered rows; drop superseded ACP config projections
Addresses independent review findings on #143600.

Refs #143547
2026-10-25 11:37:02 -04:00
unsupportedpastels
8aee8df0ec fix(acp): project config options on outside changes; document prompt.cancel
Addresses maintainer review on #143600.

Refs #143547
2026-10-25 11:37:02 -04:00
unsupportedpastels
b2f9dee01a fix(acp): list gateway editor threads, add config pickers, stop on cancel
session/list now includes editor threads stored as local rows, sessions report
model and reasoning config options, and prompt.cancel on a started turn stops it
in the same call.

Rows ACP-23, ACP-24.

Refs #143547

Co-authored-by: Felipe Cardoso <felipe.cardoso@hotmail.it>
Co-authored-by: omega <omega.ai@keihatsu.de>
2026-10-25 11:37:02 -04:00
Teknium
e1b65c5f0b refactor(browser): callers stop naming agent-browser, Camofox and the built-in browser tools
- hermes acp --setup-browser installs pm's chromium (browser_exec's local
  browser), not agent-browser;
- the codex hermes-tools MCP server stops exposing the deleted browser_*
  tools (browser_exec stays out: it runs model-written Python outside
  codex's sandbox and approval UI); /codex-runtime copy follows;
- telemetry: the removed tool names become RETIRED_TOOL_NAMES so the shipped
  schema enums keep them; camofox stays a legacy browser backend label;
- CLI config defaults drop browser.camofox / record_sessions (the camofox
  plugin reads browser.camofox itself);
- learn prompt names browser_exec; stale comments and help text updated.
2026-10-23 01:41:24 -07:00
Teknium
4b6c7f68d9 feat(delegation): a session routes on the backend its delegate_task was built from
A plain /delegation save (or a config.yaml edit) now changes nothing in a running
chat: routing and schema switch together at /new or on a --now rebuild.

- agent._delegation_backend is captured with the tools (agent_init, ACP rebuild,
  refresh_agent_mcp_tools rebuilds incl. --now and compaction) and pinned with
  them to the session row; a fresh agent restoring the pin restores the backend.
- resolve_task_routes routes on it (config.yaml only for agent-less callers).
- set_global_backend(name, *, session_key, apply_now) is unchanged.
2026-10-23 00:37:14 -07:00
rob-maron
83c5737be2 merge main in 2026-10-20 21:19:31 -04:00
rob-maron
15307dece7 Usage-window plan support 2026-10-20 21:04:30 -04:00
Teknium
85188e61c3 Merge origin/main into fix/pkg13-ink-leftovers
Resolves the hermes_cli/cli_tui_mixin.py conflict from #141501 landing: main moved _Panel to
hermes_cli/cli_panel.py and this branch moved the wrap helpers to hermes_cli/cli_tui_wrap.py.
Keep both moves: import _Panel and the wrap helpers, define neither here.

Refs #134889 (N8)
2026-10-19 12:55:27 -07:00
Teknium
dfb4ecd911 fix: a stop typed as a busy correction ends the voice chat on the shared gateway
In Ink's interrupt and steer busy modes, text typed during a running turn
goes to session.redirect / session.steer, not prompt.submit. The typed
stop-phrase check only ran in prompt.submit, so a bare "stop" in a LOCAL
voice chat reached the running agent and voice chat stayed on.

The owner's correct() now makes the same _typed_voice_stop decision (attached
submitter, LOCAL session, voice on, bare stop phrase) after authorization and
before the generation fence, and answers {voice_stopped: true}. The canonical
CanonicalCorrectionResult becomes Ack | CanonicalVoiceStopped (generated TS
and OpenRPC regenerated); the dispatch test proves it through the real
contract parse.

Every client settles that reply instead of treating it as a refusal that
re-sends the text as a prompt (which would admit "stop" as a turn):
- Ink: settleControlReply renders the stop-phrase event and settles the
  item; the running turn's busy state is untouched.
- Desktop: redirectPrompt drops the optimistic bubble and reports accepted,
  so the composer does not re-queue it.
- ACP: /steer reports the stop-phrase notice and does not send a prompt.

Greptile review on #141508.

Refs #134889 (TUI-26)
2026-10-19 06:54:34 -07:00
kshitijk4poor
310bcf444a refactor(memory): move tool-schema plumbing into agent/memory_manager_tools.py
The stall/registry work pushed agent/memory_manager.py past 1,000 lines.
The memory-provider tool-schema helpers (normalize_tool_schema,
memory_provider_tools_enabled, memory_provider_tools_exposed,
inject_memory_provider_tools) are a self-contained topic with no
dependency on MemoryManager, so they move verbatim to a
memory_manager_tools sibling and every in-tree caller imports from the
new module. agent.memory_manager is a public plugin module
(hermes_cli/plugin_validate_private_imports.py), so it re-exports the
four names, as it already does for the helpers that moved to
agent.memory_context.
2026-10-19 19:15:44 +05:30
Teknium
c9c7948704 fix: ACP, classic CLI and attach clients settle a voice_stopped prompt.submit reply
The canonical prompt.submit result is AdmissionStatus | CanonicalVoiceStopped:
a bare stop phrase typed into a LOCAL session's voice chat ends that chat on
the owner and admits nothing. Only Ink handled the second shape.

- ACP (acp_adapter/gateway_server.py) read receipt["admission_id"] and raised
  KeyError, so the editor's prompt failed. It now ends the prompt with
  end_turn and shows the existing cli.voice.stop_phrase_typed notice.
- The classic CLI's GatewayAgent.run_conversation waited in _pump for a
  message.complete that never comes; only Ctrl-C's bound ended it. It now
  returns at once: no turn, history unchanged, the same notice, and a
  /model --once pick is given back.
- `hermes chat --attach` (GatewayChatView.submit) prints the notice and
  tracks no admission; its one-shot path exits 0 instead of KeyError.
- The legacy sidecar's owner forward (owner_forward._Relay) treated the reply
  as "the gateway did not admit it"; it now returns it and relays nothing,
  and _submit_to_ledger_owner answers {voice_stopped: true}.

Other callers checked: tui_gateway onboarding and hosted rooms call the
sidecar's own handler (it already answers voice_stopped for its own voice
mode, unchanged); web/ has no prompt.submit caller; evals/scripts are probes.

Refs #134889 (TUI-26)
2026-10-19 05:43:16 -07:00
Teknium
90b2022265 Merge pull request #141338 from NousResearch/fix/pkg12-acp-modes
fix(acp): restore Accept Edits / Don't Ask as a gateway-owned per-session edit policy
2026-10-19 01:34:21 -07:00
Teknium
87206822a3 fix(acp): a mode change during a first attach reaches its reply
The attach's session.resume goes through _adopt, so the pump projects the
session's events while _session_fields waits on the model picker and the
provenance lookup. _project_mode dropped a change then (no _modes entry yet),
and the reply rebuilt its mode from the older info: the editor showed Default
while the owner auto-allowed edits.

The first projected policy (the attach's snapshot) now seeds _modes silently,
a later change updates it, and the reply reads the mode from _modes.
2026-10-19 01:19:15 -07:00
Teknium
48ec60eb9a fix(acp): a mode pick refused by a lost turn names that turn
unknown_execution (a lost or ambiguous turn) was refused with "try again after
this turn", though no turn is running and a retry keeps failing until that turn
is resolved or discarded. Each refusal reason now has its own text.
2026-10-18 22:59:03 -07:00
Teknium
098a7b71ba fix(acp): every fresh session snapshot projects the edit mode
A model pick, a confirmed deferred pick, /new, /compress, /model, /undo and
/retry installed a fresh session.resume snapshot and its watermark directly.
A session.info carrying another viewer's mode change still queued behind that
watermark was then skipped, so the editor showed Default while the owner
auto-allowed edits. Every snapshot install (create, load, fork included) now
goes through _adopt, which projects the snapshot's edit policy.
2026-10-18 22:55:20 -07:00
Teknium
64d4862c3d refactor(acp): one edit-mode table for both ACP servers
gateway_session_meta.py copied HermesACPAgent._MODES and both policy maps.
The table now lives in acp_adapter/modes.py; server.py's class attributes
and the gateway path import it. No behavior change.

Refs #134889 (ACP-7)
2026-10-18 20:58:13 -07:00
Teknium
dc995bbd63 fix(acp): name the busy-session refusal of a mode pick in the editor
The owner changes the edit policy on an idle session only, so a mode pick
(set_session_mode or the edit_approval_policy config option) during a turn
was refused with a bare session_busy. Main applied it mid-turn. The editor
now gets "Mode changes apply when the session is idle; try again after
this turn." in the transcript and as the request error, as a deferred model
pick is named; the shown mode stays.

Refs #134889 (ACP-7)
2026-10-18 20:50:51 -07:00
Teknium
ed4cefebb4 fix(acp): refuse a paused prompt before staging its media
Moving the lost-turn refusal after _prepare_submit (so /discard could pass)
meant a refused prompt still staged its attachments (writing image bytes,
possibly fetching a remote image) and retired the editor's retained un-acked
retry identity before saying nothing was submitted. A text-only /discard is
now recognised from the raw prompt content before staging; every other
prompt on a paused session is refused up front, as before.

Review #141357 (ACP media finding).

Refs #134889 (GW-10)
2026-10-18 20:48:57 -07:00
Teknium
e1d69de34d fix(acp): /discard keeps replies the editor has not shown yet
The editor's /discard adopted the owner's whole session.resume snapshot
twice. That advanced last_sequence past message and approval events the
event pump had buffered but not projected, so a follower's reply arriving
during discard was dropped. It now uses the existing pending-only refresh
(_refresh_unknown), which updates the pending rows without consuming the
reply cursor.

Review #141357 (ACP sequence finding).

Refs #134889 (GW-10)
2026-10-18 20:45:06 -07:00
Teknium
0ef1f91d6a fix(acp): project the edit mode from every recovered snapshot
A reconnect (_reattach) or replay gap (_gap_guard) adopted a fresh
session.resume snapshot and skipped the events before its watermark without
projecting the snapshot's edit policy, so the editor could keep showing
Default while the owner enforced Don't Ask. Both paths now go through one
_adopt() that stores the snapshot and projects its mode.

_project_mode also called acp.update_current_mode, which
agent-client-protocol 0.9.0 does not re-export (AttributeError on the first
projected change); build CurrentModeUpdate from acp.schema instead.

Review round 1, #141338 P1.
2026-10-18 20:34:59 -07:00
KoNit-K
0bfd5800f5 fix(acp): recover unknown turns in editor
(cherry picked from commit 1816d92fdc7f966695b830b0e7f53f4ad0420dda)

Salvaged onto main for #134889 (GW-10): resolved against main's ROUTES table
and its pre-prompt unknown refresh; the editor's refusal now names this
in-editor /discard instead of a terminal round-trip.

Refs #134889 (GW-10)
Refs #139532
Refs #141321
2026-10-18 19:52:35 -07:00
Teknium
8729dd9e74 fix(acp): restore Accept Edits / Don't Ask as the session's owner-held edit policy
The gateway ACP projection advertised only Default and refused main's other modes with
acp_edit_policy_mutation_unavailable: the owner had no verb for an editor's edit policy.

The policy is now plain data on the session's frozen LocalSessionPolicy
(edit_approval_policy: ask / workspace_session / session, default ask), written by a
revision-fenced `session.mutate edit_policy` ({policy}), so it lives in the session's stored
receipt and survives an owner restart. Only an ACP session takes it. The owner's edit guard
(gateway/session_local_editor.py) applies it before the editor's consent with main's rule
(should_auto_approve_edit): Accept Edits lets workspace/temp edits run, Don't Ask any edit,
and sensitive paths (.env, .git, .ssh, keys) always ask. session.info reports it to every
attached surface; the ACP projection advertises all three modes, maps set_session_mode and
set_config_option(edit_approval_policy) onto the mutation, shows a new editor the session's
mode, and projects another surface's change as current_mode_update.

A receipt main minted has no field: it restores as ask, and policy_identity skips the field
at its default, so stored credential references still match. The commit keeps the cached
agent (the policy is read per edit, not by the agent).

Refs #134889 (ACP-7)
Refs #141321
2026-10-18 18:58:27 -07:00
Teknium
0952996a37 Merge pull request #140971 from NousResearch/fix/pkg10-desktop-a
fix(gateway): keep session identity and full history across compression, rewind and orphan reap (package 10, lane 4a)
2026-10-18 10:53:58 -07:00
Teknium
3ad36cf9cd fix(cli): keep reading toward an awaited answer and never drop ACP's post-ack recovery
CLI-37 made GatewayClient's reader park on a full event queue instead of
failing the link. Two recovery paths still assumed the old behaviour:

- GatewayChatView and ACP await session.resume / prompt.receipt from the
  queue's only consumer. The owner attaches the re-attached subscription
  before it answers, so more than 4,096 frames ahead of the answer parked
  the reader where it could never read the answer: every RPC on that socket
  froze for EVENT_STALL_TIMEOUT (30 s), then the link died.
- ACP's _after_ack suppressed QueueFull on its recovery tuple ("the reader's
  own overflow ends this link"), which is no longer true: the tuple was
  dropped and that prompt waited forever.

The client queue is now an EventQueue: the bounded asyncio queue plus an
ordered overflow behind it, refilled on every get. While an RPC answer is
awaited the reader reads on into the overflow (bounded by
EVENT_OVERFLOW_FRAMES / EVENT_OVERFLOW_BYTES, sized to the owner fanout's
16,384-frame / 4 MiB backlog); otherwise it waits for the consumer as
before, and a consumer that stops draining is still failed after
EVENT_STALL_TIMEOUT. ACP's post-ack recovery goes behind every frame read
so far through put_behind(), never dropped.

Tests: test_gateway_client_recovery_backlog.py (dokterdok's probes: a
4,097/6,000-frame burst ahead of the resume answer for the chat view and
ACP; a full queue with a post-ack recovery), red on the previous head.
test_gateway_client_backlog's stall test now also pins the overflow cap.

Review finding by @kshitijk4poor on #140968
Review finding by @dokterdok on #140968
Refs #134889 (CLI-35)
Refs #134889 (CLI-37)
Refs #140719
2026-10-18 03:28:00 -07:00
David Dudok de Wit
875577495b fix(gateway): re-attach after session.replay_gap instead of failing the turn
On overflow the owner retires a viewer's subscription and sends one
session.replay_gap while the turn runs on. Every Python subscriber treated
that frame as a failed turn: the classic CLI reported "outcome unknown" and
then hung on every later turn, GatewayChatView (stream-json, -z,
--safe-mode) failed, and ACP stopped its event pump, failing the waiting
prompts of every session. #140292 made gaps much rarer by raising the frame
cap, but kept the overflow path.

A gap now means "this subscription ended; re-attach". The client resumes
that session only, adopts the new subscription, wakes whatever waits on its
pending rows or controls, and answers the controls the snapshot lists. The
snapshot is taken under the event-stream lock: a queued or started
admission it lists publishes its completion on the new subscription; an
unknown one owes none and settles as unknown now, in every client; one it
no longer lists ended in the hole and its receipt settles it, read once and
only against a snapshot that covers it (one whose resume left after the
submit). ACP's pump is the one recovery owner, so a reply is delivered at
most once. After a gap a control blocks only an admission the snapshot
still lists.

Live deltas stop at the gap and the settled reply shows once (the rest of
an exact prefix, else "[output resumed]" and the whole reply), to the
terminal and to the voice stream separately. An interim stays whole, as it
can be the reply's only copy. stream-json emits no further text and flags
its result with replay_gap. After a gap or from a receipt, a reused reply
is suppressed only when all of it was shown; without a gap main's rule
holds. A refused re-attach still ends the wait with today's error; an
unreadable receipt fails only that admission. A CLI turn owns its turn
token and its session from the pre-submit re-attach through _result and
painting, bounded by the interrupt settle deadline, and any received
boundary closes the reply segment.

The real-rig tests share one real owner that pins the fanout frame cap at
256, as #140292's own overflow probe does, so the paused viewer still
overflows.

Refs #134889
Fixes #140388

(cherry picked from commit 0d51f10640c560e0cb0b2205e2dbad18d06c7c5c)
2026-10-18 03:28:00 -07:00
David Dudok de Wit
a9e38dce92 fix(acp): refresh lost-turn state before refusing the next prompt
Refs #134889

Fixes #140521

(cherry picked from commit eeb212211cbf1e27c436baa132a42daf204b7288)
2026-10-18 03:27:59 -07:00
David Dudok de Wit
4af8fdef61 fix(gateway): show the whole history when resuming a compressed conversation
After any compression, session.resume (Ink /resume, Desktop's warm
re-focus and replay-gap re-snapshot, the one-shot chat view's --resume
printout) returned the model's working set: the summary and the last
exchange. Earlier turns looked deleted although they are stored.

The resume snapshot is now the display history. local_history returns
the display lineage (as the REST transcript and the legacy resume do),
marks every row outside the current transcript's active set
`archived: true`, and keeps every live row, so the rows without the
mark are exactly the live transcript. Archived rows fill, newest
first, what the live rows leave of a 3 MiB budget, so the reply stays
under the clients' 8 MiB frame whenever main's live-only reply does;
when older ones are left out the first row says
`archived_truncated: true`. attach and the hosted-room history read
and budget the lineage off the loop; under the event-stream lock only
the live tip is re-read, and a rewind or compaction since the read
triggers a re-read.

Each logical message shows once:
- the store's display dedupe also reads removed rows, and hides a
  message whose newest copy is removed, so a turn undone in a
  compression child does not come back from the parent's copy (copies
  share the display key or message_uid; a merge stands for the prompts
  it absorbed);
- a micro-compaction merge (model_only) stays a live undo target but
  Ink's display_messages, Desktop hydration and the one-shot printer
  skip it: its originals are the archived rows they show.

An archived row is display-only:
- the canonical rewind refuses a target that is not an active row of
  the current transcript (before, it deactivated the whole live
  conversation, also reachable from a Desktop edit of an archived row);
- the classic and Ink /undo and /retry selectors, the classic
  rewind_user_turn, /compress and /rollback history, and ACP's replay
  and token estimate skip it. Desktop's /undo and /retry and the
  owner's /rollback turn rewind follow in the next commit.

Three tests that pinned the tip-only snapshot now assert the old rows
are present and archived, and the live rows unchanged.

Refs #134889
Refs #140449

(cherry picked from commit 81e4666af9d048e1df89c704a921ff55ee9b2ef6)
2026-10-18 03:19:59 -07:00
Teknium
4b3fc4a6fc refactor(acp): run a prompt's slash command through _run_slash
Rebased onto #140188, whose `_prepare_submit` and the command refusal
handling together put `prompt()` one branch over the code-health cap.
The slash half moves to `_run_slash`, returning `(answered, text)`;
behaviour is unchanged. #140190's overlay home now reaches #140188's async
`stage_user_content(content, home)` (folded into the rebased overlay-image
commit).

Refs #134889 (ACP-17, MP-10, ACP-18)
Refs #140138
2026-10-16 21:17:07 -07:00
Teknium
7fb93521a6 refactor(acp): one route table serves editor commands and documents them
The parity generator kept its own ACP_ROUTES list beside the membership
checks in run_command, so an ACP route could change while the documented
cell (and its drift check) stayed the same. acp_adapter/gateway_commands.py
now holds ROUTES (command -> documented cell, handler): run_command
dispatches through it, anything else is the owner's slash.exec, and the
generator reads the same table. The rendered parity doc is unchanged.

Review finding on #140190 (Greptile)
Refs #134889 (ACP-17)
Refs #140138
2026-10-16 21:13:47 -07:00
Teknium
cc9442326c fix(acp): a guarded deferred model pick asks the editor at the turn boundary
A pick made during a turn tells the editor it applies from the next message.
When the target needs consent (cost, data policy, large context), the owner
does not apply it at the boundary: it publishes confirmation_required and keeps
the pick pending. ACP handled only `refused`, so the editor neither asked nor
said why the promised switch never happened.

That ask now goes through the same ACP permission request as an idle guarded
pick. Yes re-sends the same selection once with the owner's token and reports
the switch; no, a lost editor or a failed resend names the model still in use;
a second refusal is reported once and not asked again (as Ink and Desktop).

Review finding on #140190 (Greptile)
Refs #134889 (MP-10)
Refs #140138
2026-10-16 21:13:47 -07:00
Teknium
a042d5a2c9 fix(acp): an overlay HERMES_HOME stages prompt images in the owner's cache
An overlay task home attaches to the profile its symlinked lock names, but
image staging still used the overlay's ambient HERMES_HOME. The overlay does
not share cache/images, and the owner admits attachments only from its own
image cache, so every image prompt failed with invalid_params. Staging now
runs under the resolved owner home (context-local home override); the owner's
path check is unchanged.

Review finding on #140190 (Greptile)
Refs #134889 (ACP-18)
Refs #140138
2026-10-16 21:13:47 -07:00
Teknium
82f58120a9 fix(acp): /retry keeps its rewind through a lost refresh and answers an image turn
A /retry whose session.resume refresh lost its connection forgot the committed
rewind first, so the next /retry derived a new target from the shortened
transcript, removed the turn before it and resent the wrong message. The
prepared rewind now stays retained until the refresh lands, and the repeat
replays it.

The image-turn refusal raised while the rewind payload is derived on the CAS
snapshot is now the command's reply (CommandRefused), not a failed request;
transport and permission errors still fail the request.

Review finding on #140190 (Greptile)
Refs #134889 (ACP-17)
Refs #140138
2026-10-16 21:13:32 -07:00
Teknium
8209e152c5 refactor(acp): table the mutation answers that commit nothing
The deferred-pick branch made _mutate an if/elif ladder on one status
(code health HX011); the answers that change nothing are now a table.
No behaviour change.

Refs #134889 (MP-10)
Refs #140138
2026-10-16 21:13:32 -07:00
Teknium
fc49050f94 fix(acp): an overlay HERMES_HOME attaches with the mirrored profile's identity
On top of the salvaged discovery fix (#138951): discovery now finds the
owner a per-task overlay home's symlinked gateway.lock names, but the
client still minted its session ticket at the overlay's own control socket
(which does not exist: "No such file ... task-home/gateway.sock.path"), and
GatewayACPAgent compared the owner's profile_id with the overlay path, so
it would refuse profile_mismatch next.

gateway_profile_home() names the profile home that serves a home (the home
itself, or the profile an overlay's lock names, under the same private
checks as discovery). connect_gateway ensures, mints the ticket at and
GatewayACPAgent checks profile identity against that home. One owner
stays the writer; nothing local starts for the overlay.

Red on main: tests/acp_adapter/test_gateway_overlay_home.py (real
acp_adapter.entry with HERMES_HOME = a private task dir whose gateway.lock,
state.db and config.yaml link to a real gateway.run daemon's home) failed
session/new with -32603 "Gateway inaccessible: not_ready"; with #138951
alone it failed on the missing overlay control socket. Green: session/new,
a turn and session/load run, and the daemon's own viewer reads the turn.

Refs #138949
Refs #134889 (ACP-18)
Refs #140138
2026-10-16 21:13:32 -07:00
Teknium
0ea563d43d fix(acp): a model pick during a turn says it applies next, or why it did not
On top of the salvaged provider split (#139197): since #139604 the owner
answers a model pick on a running session with status "deferred" and lands
it at the next turn boundary, or drops it there and publishes
session.updated status "refused" with the reason. Desktop shows both; the
ACP adapter showed neither, so an editor's pick looked applied while the
running turn kept the old model, and a dropped pick was silent.

session/set_model (and /model) now tell the editor "<model> applies from
your next message" on a deferred answer, and a refused deferred pick is
shown as "Model switch to X was not applied (reason); still using Y".

Red on main: tests/acp_adapter/test_gateway_model_pick_provider.py (real
acp_adapter.entry + real gateway.run, a second named provider on a loopback
model peer, no monkeypatch): the cross-provider pick left provider
"custom" instead of "custom:second"; the deferred pick showed nothing; the
refused one timed out waiting for any notice.

Refs #139165
Refs #134889 (MP-10)
Refs #140138
2026-10-16 21:13:20 -07:00
funky-xamarin
80fd5d70fb fix(acp): retain provider identity in gateway model picks
(cherry picked from commit 680d60b5037e63481c6a4e68b08d7d3bf1d75d9a)
2026-10-16 21:13:19 -07:00
Teknium
69f80031de fix(acp): registry commands the editor path does not serve get a named reply, not Internal error
On the gateway ACP path every registered Hermes command outside the adapter's
small allowlist (/title /yolo /retry /undo /skills /clear /bg ...) raised
GatewayClientError('unsupported_command'), which the ACP SDK turned into a
JSON-RPC -32603 "Internal error" for the whole prompt, while /help said
unrecognized commands go to the model.

Map them the way the classic transport client (gateway_chat_commands.py) does:
/title <name> is session.mutate rename, /undo [N] and /retry the rewind
mutation, /clear the reset, and every other registry command goes to the
owner's slash.exec, which runs what it serves for a local session (/yolo,
/skills, bare /title, /plan's turn...) and refuses the rest. That refusal
(and /branch's pointer to session/fork) is the command's reply with
stop_reason end_turn, using the shared "not available on the shared gateway
yet" wording. The parity table's ACP column now reads those routes.

Red on main: tests/acp_adapter/test_gateway_registry_commands.py (real
acp_adapter.entry stdio process + real gateway.run daemon) failed with
{'code': -32603, 'message': 'Internal error', 'data': {'details': 'unsupported_command'}}
on /title.

Refs #134889 (ACP-17)
Refs #140138
2026-10-16 21:13:14 -07:00
Teknium
62c7848cfc refactor(acp): split media staging and reply display out of the gateway bridge
gateway_server.py had grown from 942 to 1,095 lines on this branch. Media
staging moves to acp_adapter/gateway_media.py as one async entry point
(stage_user_content, submit_fingerprint): the remote image download is awaited
directly, which removes _has_remote_image and the thread -> asyncio.run() ->
thread round trip. Reply display (messageId grouping, exactly-once final text,
tool and permission bubble closes) moves to GatewayReplyMixin in
acp_adapter/gateway_reply.py. prompt()'s prepare phase (retry reuse, staging, Stop during staging) becomes
_prepare_submit, keeping prompt() under the CC cap. gateway_server.py is now 887
lines. No behavior
change.

Review finding on #140188 (Greptile)
Refs #134889 (ACP-16)
2026-10-16 19:18:55 -07:00
Teknium
11adaf06b9 fix(acp): a reconnect or terminal receipt never leaves a reply id open
The per-session messageId allocator survived _teardown. A reply cut off by a
lost connection never gets its message.complete (re-attach starts at the
owner's current sequence), so the next reply reused the old messageId and an
editor could merge or replace the earlier reply. _teardown now drops every
open id. A retry's terminal receipt (_settled_receipt) also bypassed the id and
tool close logic: both it and message.complete now finish through one
_finish_reply (remainder with messageId, close the id, fail open tool calls).

Review finding on #140188 (Greptile)
Refs #134889 (ACP-15)
2026-10-16 19:18:55 -07:00
Teknium
00ab80983d fix(acp): the editor's Stop during a remote image download cancels the prompt
The remote image fetch ran before the session entered _submitting, so a Stop
during a slow download found neither an admission nor a submitting prompt and
was dropped; the prompt was then submitted and could run tool actions. The
download now runs inside _submitting, so cancel() records the Stop, and the
prompt returns stop_reason=cancelled without submitting anything.

Review finding on #140188 (Greptile)
Refs #134889 (ACP-16)
2026-10-16 19:18:55 -07:00
Teknium
03be2bbdfe fix(acp): an un-acked image prompt's retry reuses its staging, never re-fetches
The editor's retry of a submit whose ack was lost downloaded a remote image
again before choosing the input_id. A failed or changed second download turned
the same ACP prompt into different content, so the fingerprint differed and the
gateway admitted a second turn. The retry identity is now taken from the prompt
as the editor sent it (text, data: bytes, remote URLs) before staging, and the
staged text and attachments are retained with the input_id and resubmitted.

Review finding on #140188 (Greptile)
Refs #134889 (ACP-16)
2026-10-16 19:18:55 -07:00
Teknium
059d01257c fix(acp): stage a remote image URL as an attachment instead of text
Main's in-process ACP server passed an image block's remote URL to the
model as an image part. Admission on the gateway path carries only
staged bytes, so `_stage_user_content` turned it into the text
"[Image attached: URL]" and a vision model never saw the image.

Fetch http(s) image URLs through the gateway's own SSRF-guarded image
downloader (`cache_image_from_url`: pre-flight and per-redirect address
checks, the inbound media size cap), then sniff and stage the bytes like
any data: image. A blocked address, HTTP error or non-image body keeps
the old text note, so the prompt still runs. Only a prompt holding a
remote image stages in a worker thread (`asyncio.to_thread`), since only
it does network I/O; every other prompt stages inline as before, keeping
submit ordering against a concurrent cancel unchanged.

Refs #134889 (ACP-16)
Refs #140138
2026-10-16 19:18:54 -07:00
Teknium
9cb9bb6cad fix(acp): tool-call display on the gateway path matches the in-process agent
Four gaps between `_project` and what main's in-process ACP agent showed:

- `tool.complete` ignored the executor's `is_error`, so a failed tool whose
  plain-text result the heuristic misses showed `completed`. Pass it to
  `build_tool_complete` as `make_tool_progress_cb` did.
- A tool call that never completes (blocked by a guard, approval denied)
  stayed `in_progress` forever. At `message.complete`, close every call that
  admission opened and never completed as `failed` (`build_tool_abandoned`),
  as `flush_open_tool_calls` did at turn end.
- An answered approval/clarify card's `tool_call` stayed a pending bubble.
  Close it (`completed` on allow, `failed` otherwise) as
  `permissions.await_permission` did; best effort, so a failed close never
  costs the answer.
- Assistant and thought chunks carried no `messageId`. Stamp them from a
  per-session `AssistantMessageIdAllocator`, closed at each tool start,
  interim segment and turn end, so separate replies never merge.

Tool handling moves into `_project_tool` to keep `_project` under the
complexity cap.

Refs #134889 (ACP-15)
Refs #140138
2026-10-16 19:18:54 -07:00
Teknium
79aed999c5 fix(acp): project the owner's todo.updated as the native plan update
The in-process ACP agent turned every todo tool result into a `plan`
session update (Zed's task panel). On the gateway path the owner already
publishes the full snapshot as `todo.updated` for a LOCAL session's turn
(an ACP session is one), but `_project` had no case for it, so editors
saw no live plan. Map it through the same `_build_plan_update_from_todo_result`
the in-process agent used. Reasoning and plan share one side-update
helper to keep `_project` under the complexity cap.

Refs #134889 (ACP-5)
Refs #140138
2026-10-16 19:18:54 -07:00
putis
6b9e0a16a9 fix(acp): stream live reasoning to editors on the gateway path
Since the unified gateway runtime (#106742), `hermes acp` is a viewer
of the gateway's session, and editors no longer get live
agent_thought_chunk updates (#134889 ACP-4). The owner publishes
reasoning.delta only for a live session whose show_reasoning flag a
viewer set (gateway/local_viewer_events.py). The ACP viewer never set
it and had no case for the event, while the in-process server it
replaced (acp_adapter/server.py) gave every editor turn a reasoning
sink.

Ask for the flag with config.set, like the CLI does, whenever the
editor attaches: session/new, load and resume, the fork's child, and
the re-attach after a gateway restart, whose sessions come back
without it. Ask before the attach replies, so the first turn already
streams. On a re-attach, ask before offering the session's pending
cards again: their answers need the new connection, which _client()
installs only after the re-attach.

The request is best effort. A refusal, a lost connection or no answer
within 10 s doesn't fail the attach; at worst it goes on without live
reasoning. After a lost connection, the next call that goes through
_client() reconnects and the re-attach asks again.

reasoning.delta becomes agent_thought_chunk for the id the editor
holds, outside the reply's segments.

Tests: an end-to-end test (a real `hermes acp` against an isolated
gateway and a provider that reasons first) covers new, load and fork.
A unit test covers new, load, resume, fork and a reconnect, each with
the request set, refused, losing its reply, hitting a closed socket or
going unanswered. test_gateway_reconnect.py expects the flag on the
replacement owner, three owner fakes answer config.set, and two bridges
to a real owner keep the client's _timeout off the wire.

(cherry picked from commit 8ae47ac1e962fed043df741c311ca56c56d60ccf)
2026-10-16 19:18:54 -07:00
unsupportedpastels
379cf1220f fix(acp): require a provider under bypass flags; best-effort, parallel drift check
Review follow-ups from the maintainer review:
- hermes -m X --safe-mode acp (or --ignore-user-config) without --provider
  is refused at session/new with a message naming --provider, instead of
  creating a session whose first turn cannot build the agent.
- The admission-start editor MCP re-check is best-effort as a whole: any
  failure in the probe or the re-freeze is logged and the turn proceeds;
  it never pauses the FIFO or kills the drain.
- Held servers are re-listed concurrently under one 5 s bound, and the
  re-check runs only after the head passes its admission checks, so a
  refused head spawns no server and commits no change.
- An empty mcpServers list on ACP load/resume keeps the session's editor
  servers, as fork already did; a second client without MCP config no
  longer strips the first editor's tools. Removal is session.mutate
  editor_mcp with [] only.

Refs #134889
2026-10-14 23:08:31 -04:00