Commit Graph

33 Commits

Author SHA1 Message Date
alt-glitch
192cdaf266 refactor(delegation): delete unreached ledger ack, finalizing filters, reserved events and dead params
Removed:
- tools/async_delegation.py::mark_completion_delivered (no production caller; delivery acks go through claim/complete_completion_delivery)
- tools/async_delegation.py: 'finalizing' in seven state SQL filters (the ledger state column is only ever written 'running' or a terminal status; 'finalizing' is in-memory record status only, in every commit)
- tools/delegate_tool_child_run.py::_ChildRun.wait_liveness_aware child_future parameter (unread in the body)
- tools/delegate_tool_child_run.py::_start_heartbeat (a constructor alias; delegate_tool builds _Heartbeat directly)
- tools/delegate_tool.py: facade imports DelegateEvent and _batch_prefix (unused in the body, reached by nobody through the facade)
- tools/delegate_tool_progress.py::DelegateEvent.TASK_SPAWNED / TASK_COMPLETED / TASK_FAILED (reserved, never emitted)
- tools/delegate_tool_auto_resume.py: _lineage's lineage-id set and superseded_reason's unused record argument

Tests: the completion-wait helper in test_delegate_auto_resume.py filters
state != "running", matching the production SQL.
2026-11-16 15:23:23 +05:30
Teknium
69677b5829 fix(delegation): pin the child's brief through compaction; context first as a cacheable prefix
Review findings from unsupportedpastels and kshitijk4poor:

- A steered child lost its brief at its second compaction. The compactor stops
  protecting early turns after the first pass and restates the newest real user
  turn, which after a steer is the steer. A delegated child's first user turn
  is its whole brief (goal, context, output contract), so it is now always
  protected (ContextCompressor.pin_task_turn, set on every child). The head
  window methods move to context_compressor_window.py with it.
- Siblings given one context stopped reading it from cache: the goal came
  first, so the shared bytes started after the first difference. The first user
  turn is now "CONTEXT: ... TASK: <goal>", and the context is registered as the
  message's stable prefix, which gives it its own cache breakpoint on marker
  routes. Every brief is registered: a parent often sends one brief in separate
  calls, which a per-call "shared" test cannot see.
- Stale docs and comments that still placed the context in the system prompt.

Co-authored-by: unsupportedpastels <unsupportedpastels@users.noreply.github.com>
Co-authored-by: kshitijk4poor <kshitijk4poor@users.noreply.github.com>
2026-11-11 18:29:48 -08:00
Teknium
e7ff451652 perf(delegation): sibling subagents share one prompt prefix and cache scope
Providers that cache automatically match only inside the scope the client
sends, and only up to the first byte that differs. A child's task context sat
in its system prompt, which OpenAI-family models render ahead of the tools, and
on the Codex backend each child sent its own session_id header, the scope that
backend caches under. So every subagent paid full price for the prefix all of
one parent's children share.

- The goal and its context are the child's first user turn; the child system
  prompt carries nothing per-task, so siblings send identical system prompts.
- One parent's children share a cache scope of their own (sub_<hash of the
  parent's scope>), which keys prompt_cache_key and, on the Codex backend, the
  session_id header. Skipped on slot-keyed routes (xAI), where two streams
  under one key evict each other.

Claude children gain too: the cache breakpoint at the end of the system prompt
now covers bytes every sibling sends.
2026-11-11 18:29:48 -08:00
kshitijk4poor
acea369414 fix(delegate): read the SSH session cwd raw, not the host-resolved tracker copy
The subdirectory tracker resolves its working_dir on the machine running
Hermes (the host process cwd when unset), so on SSH a terminal.cwd of
project reached the workspace hint as <host cwd>/project: absolute, past
the relative-path guard, and hinted whenever that local directory existed.
On SSH read agent.session_cwd, the value the tracker was built from, and
let the same guards judge it. Compute the backend check once.
2026-11-10 13:36:37 +05:30
Kevin Rajan
773bb452b2 fix(ssh): never expand remote-relative subagent workspace on host
A terminal.cwd of ~/project or project can match a host directory under
Docker HOME. _resolve_workspace_hint used host expanduser/abspath and
injected that host path into the SSH child's WORKSPACE PATH even though
the remote terminal resolves it on the SSH target.

Skip non-absolute POSIX candidate paths for SSH before local expansion.
Add a parameterized regression for tilde and relative workspaces.

Follow-up to kshitijk4poor's #152470 and xxxigm's #143142.
Tests unrun; source-reviewed only.
2026-11-10 13:36:37 +05:30
kshitijk4poor
caa88a0efb fix(ssh): rewrite the image's Hermes home in a container, not by real-home equality
The official image runs as hermes with HOME=/opt/data, so get_real_home()
equals the Hermes home and the real-home exemption kept /opt/data on the
SSH cwd: cd exited 126 on the target exactly as before. Key the rewrite on
running in a container instead (a host may share the layout over an NFS
home), and cover every directory Hermes starts in there: the Hermes home,
the root it belongs to (/opt/data under a named profile too), each one's
home/, and the install root. Matching is lexical, so a symlink on this
machine cannot redirect a remote path; the set is cached per home.

SSHEnvironment coerces its starting cwd, so environments built outside the
terminal tool (execute_code, image tools, the backend prompt probe, the
dashboard files pane) no longer start in a host directory. The files pane
dials after leaving the requested profile's scope, so it coerces the cwd
inside that scope. The subagent workspace hint skips a candidate the
rewrite changes, through the same function.
2026-11-10 13:36:37 +05:30
xxxigm
213a0c33eb fix(delegate): skip the Hermes home when hinting a subagent workspace
On SSH, TERMINAL_CWD=. resolves to the Docker data directory because that directory exists on the machine running Hermes. The child prompt then told the subagent to use it as its workdir.
2026-11-10 13:36:37 +05:30
yoniebans
c6ac2564ba fix(gateway): publish subagent events to local viewers and retain fallback-evicted rosters 2026-10-16 22:10:26 +02:00
Teknium
24dfa8a19e fix(delegation): keep structured summaries valid; honour opt-out for parent copy
JSON summaries: a text-level redaction pass over a structured (output_schema)
answer could eat JSON delimiters -- the ENV-assignment rule turns
{"env": "OPENAI_API_KEY=sk-proj-...", "n": 2} into
{"env": "OPENAI_API_KEY=*** "n": 2}, so a valid answer came back unparsable
with schema_valid flipped to False. When a summary is structured (schema set or
schema_valid present) and parses as JSON, redact the parsed values (with the
field name as context for credential-named keys) and re-serialize; text
redaction only for summaries that do not parse. Re-validation still runs when
redaction changed the summary.

Opt-out policy (maintainer ruling): forced redaction must not override
security.redact_secrets: false for the parent model's own copy. The entry the
parent reads (attach_worktree/emit_complete/_finalize_child_results), live
subagent.complete progress, the in-process completion queue and batch failure
notices now honour the setting (force=False). Everything that leaves the
process or persists stays forced: the spill file under cache/delegation,
async_delegations rows (_persist_completion, record_unit_child, recovery) and
their replay/reads, worker IPC, memory.on_delegation, and subagent_stop hooks.
Registered vault values are scrubbed in both modes.

Replaces the PR test that asserted forced redaction of the parent copy with
two invariants: structured summary stays valid JSON, and the opt-out keeps
the parent copy while spill/memory/hook/SQLite stay masked.
2026-10-16 05:44:47 -07:00
helix4u
9ed387ce23 fix(delegation): redact child output before parent consumers 2026-10-16 05:44:47 -07:00
Maciej Lisiewski
4278b6aa24 ci: RUF013, RUF015 2026-10-08 21:29:48 +02:00
Maciej Lisiewski
d76cce4f11 ci: apply all automatic linter fixes available 2026-10-08 17:22:54 +02:00
funky-xamarin
8ae0a21a4c fix(delegation): make remaining-depth guidance unambiguous 2026-09-19 23:57:59 -07:00
funky-xamarin
a915be8bd7 fix(delegation): align child prompts with depth-derived roles 2026-09-19 23:57:59 -07:00
KoNit-K
0aa178736a fix(delegation): avoid duplicating child goals in system prompts 2026-09-18 09:52:36 -07:00
Victor Kyriazakos
cd3de040ab feat(notifications): opt-in suppression of user-channel warning notifications
Squash of the 54 commits on victor-kyriazakos:feat/user-channel-warning-suppression
(PR #112302, head f45c640e55) so the contributor's authorship survives a rebase-merge;
the commits interleave with a cron delivery-ledger rework that the salvage removes in
follow-up commits, so per-commit cherry-picks were not practical.

Adds display.suppress_warning_notifications (global + per-platform, default false):
one resolver (gateway/warning_notifications.py), BasePlatformAdapter.emit_warning /
emit_media_warning / warning_text, a notification_category classification carried
through wakes, queues and persistence, and render/present boundaries for CLI/TUI.
2026-09-18 01:43:35 +05:30
teknium1
23036e20a6 fix(ux): plain-language, actionable user-facing messages (core)
Squashed integration of the user-facing message audit for this surface set.
Full per-finding receipts: /tmp/ux-audit/lanes/*-receipt.md (campaign artifacts).
2026-09-15 04:12:13 -07:00
Teknium
9c9e7ab6e5 fix(multiplex): a served profile's turn sees its own cwd, approvals, redaction and tool policy
Under gateway.multiplex_profiles a secondary profile's turn ran with the LAUNCH
profile's working directory, command allowlist, redact_secrets switch, credential
file mounts, browser engine/headed flags, LSP service, auxiliary-provider health
marks and MCP stderr log, and several TERMINAL_ENV consumers read the process env
instead of the routed profile's terminal scope. A standalone `hermes -p X gateway
run` never behaved that way.

- tools/terminal_scope.py: resolve the terminal.cwd placeholder inside the
  profile scope with the same rule gateway/run.py applies at import (local ->
  $HOME, sandbox default otherwise) so the system prompt, context files and the
  terminal of a routed turn start where the profile's standalone gateway would.
- tools/image_source.py, credential_files.py, image_generation_tool.py,
  skills_tool.py, delegate_tool_progress.py, agent/tool_executor.py: read
  TERMINAL_ENV / TERMINAL_CWD through the terminal scope.
- tools/approval.py (+ approval_floors.py): one permanent allowlist per routed
  profile home; the unscoped module set stays for single-profile processes.
- agent/redact.py: `_redact_enabled()` resolves security.redact_secrets for the
  routed profile (scope .env, then config); launch snapshot kept when unscoped.
- tools/credential_files.py, agent/auxiliary_health.py, agent/lsp/__init__.py,
  tools/browser_tool_cloud.py, tools/mcp_tool_config.py,
  tools/tool_result_storage.py: key process caches by profile home (or bypass
  the slot under an override).

Tests: tests/tools/test_multiplex_turn_parity.py (4, red on base).
Docs: multi-profile-gateways.md isolation table.
2026-09-11 19:39:12 -07:00
Teknium
0cb996d977 fix(delegation): number delegation batches per conversation, not per process
`format_batch_tag` handed out `set N` ordinals from one process-wide table,
so every conversation on a shared backend and every child's nested fan-out
advanced the same counter. A user's second wave of 15 lanes rendered as
`[set 20 · 13/15]`, which reads like 20 batches were spawned.

Scope the ordinal table by the parent conversation (`parent_agent.session_id`)
and thread the parent through the three render sites (batch header,
completion lines, child tree-line prefix via the shared session_ref). The
first fan-out in a conversation is `set 1`, the next `set 2`; sibling
conversations and nested child batches no longer inflate it.

Invariant test proven red on origin/main, green with the fix.
2026-09-06 05:03:20 -07:00
Teknium
e83816a4d1 review-fix(comments): restore lost #NNNN rationale comments across non-test source (mechanical sweep, condensed, code unchanged)
For each issue anchor present in BASE 63279301bc non-test .py and absent on HEAD, the BASE comment/docstring block was re-attached at the HEAD location of the code it explained (matched by the distinctive code line / enclosing def). Sentences already covered by an existing HEAD comment were deduped; the issue number always survives. Insert-only: no code lines changed.
2026-09-03 09:44:26 -07:00
Teknium
54bd822d93 refactor(delegate): child prompt text blocks as module constants (byte-identical prompts) 2026-09-02 19:47:36 -07:00
Teknium
9cf7c74030 refactor(delegate): module headers condensed (one-line docstrings, logger comment inline) 2026-09-02 19:43:56 -07:00
Teknium
defca3639a refactor(delegate): reflow comments/docstrings to 118 cols (word-identical, AST-identical) 2026-09-02 19:25:04 -07:00
Teknium
1283ccd855 refactor(delegate): docstring compaction by hand (every rule/why kept) 2026-09-02 19:16:07 -07:00
Teknium
eabec2ff50 refactor(delegate): AST-identical re-layout pass 2 2026-09-02 19:04:50 -07:00
Teknium
940681711e refactor(delegate): progress relay — tighter identity/relay/normalize paths 2026-09-02 18:41:25 -07:00
Teknium
b18228f377 refactor(delegate): AST-identical re-layout (pack signatures/call args, join split literals) 2026-09-02 17:59:28 -07:00
Teknium
64957b7e02 refactor(delegate): _Batch dataclass owns batch execution/dispatch; _quiet best-effort contextmanager 2026-09-02 17:50:16 -07:00
Teknium
3da2ff88e3 refactor(delegate): pack re-import block; single blank line between top-level defs (AST-identical) 2026-09-02 17:03:55 -07:00
Teknium
016f31375d refactor(delegate): join wrapped logical lines that fit in 120 cols (AST-identical) 2026-09-02 16:59:26 -07:00
Teknium
884c697291 refactor(delegate): split _finalize_child_results (memory/hooks/cost rollup), lift _create_isolated_worktree and _report_child_done, collapse dead worktree-attach import fallback 2026-09-02 16:54:15 -07:00
Teknium
8e9628e9cf refactor(delegate): progress relay -> _ChildProgressRelay class + event table; split _dispatch_background into collaborators 2026-09-02 15:40:23 -07:00
Teknium
05526b028a refactor(tools/delegate): split delegate_tool into child_run/config/dispatch/progress/registry/results; compact delegation helpers 2026-09-02 14:45:15 -07:00