Commit Graph

96 Commits

Author SHA1 Message Date
Teknium
f925b01791 fix(relay): stop waiting on Relay after one stalled compaction mark
A wedged Relay pipeline made every compaction block for SCOPE_OP_TIMEOUT
(10s) while it still held the compression lease, with no breaker. The
first stalled mark now trips a process-wide flag and later marks return
immediately; marks are observability and must never tax compaction.

Also: make relay_runtime.SCOPE_OP_TIMEOUT public (relay_compaction reads
it), fold the commit-time telemetry hold into _hold_attempt_telemetry
with one _ATTEMPT_TELEMETRY_FIELDS tuple, and drop the mapping-table
change-detector tests (the ATOF freshness and failure invariants stay).
2026-10-10 04:27:27 -07:00
Maciej Lisiewski
2ff58849f4 ci: ruff UP037 fixes 2026-10-09 17:34:38 +02:00
Maciej Lisiewski
d76cce4f11 ci: apply all automatic linter fixes available 2026-10-08 17:22:54 +02:00
teknium1
7e19f4138b fix(telemetry): record auxiliary model calls with their real outcome
Every failed auxiliary model_route row read error_class=unknown because the
aux logical scope only carried outcome/model/provider and the projection
hard-coded unknown for any non-success. Every exception escaping call_llm,
including Hermes' own aborts (Ctrl+C / /stop mid-compression, interrupted
aux streams, task cancellation), was recorded as failed.

- classify the error that ended an aux call (and the last one a successful
  call recovered from) with agent.error_classifier; HTTP-200 bodies that
  carry a provider error object are classified from that object
- Hermes aborts (non-Exception BaseExceptions, InterruptedError) close the
  call as cancelled/none, matching the contract
- MoA aggregator streams report the same way
- aux calls that finish under the turn's own live scopes (title generation
  runs beside the turn) were never counted: the scope could not be popped
  and the turn-close drain closed it as an orphan without a route. The
  drain now closes it with the stored real result.
2026-10-03 13:38:29 -07:00
emozilla
51aa249efd feat(relay): name the Relay plugin files in doctor and the startup log
Relay 0.9 discovers user and system plugins.toml files outside the Hermes
home, so an exporter or middleware can apply to every Hermes session without
any Hermes setting naming it. Hermes now says which files apply.

The startup line that reports an active plugin host lists the files the
activation loaded. `hermes doctor` gains a NeMo Relay Plugins section: it
resolves the same layers through Relay's validator, which loads no plugin
code and leaves the process-wide host alone, then lists each file, whether
anything is enabled, and any error or warning Relay reports. A configuration
Relay would reject counts as a doctor issue. Validation cannot load dynamic
plugins, so a warning marks the row without counting as an issue.

The docs give the user and system file locations for each platform and point
to `hermes doctor`.
2026-09-29 12:16:43 -04:00
Alex Fournier
55e102a763 Merge main into chore/relay-0.9
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-09-28 12:18:42 -07:00
Teknium
a5bd246865 Old pre-decomposition import paths are gone: plugin compat layer removed on schedule (#126164)
* refactor(plugins): remove the Sep 2026 decomposition compat layer on schedule

The PLUGIN-COMPAT layer (2776813df3 + d63e380324 + 0a5164cebe) kept pre-#102117 import paths
alive for external plugins until 2026-09-14. That window closed two weeks ago; since then the loader
has already been skipping plugins that use the old paths. This removes the layer itself:

- 328 appended `PLUGIN-COMPAT` blocks (lazy `__getattr__` pointer tables, re-exported third-party
  names, restored dead definitions) and the three re-export stub modules
  (gateway/startup_watchdog, hermes_cli/observability/relay_runtime, tools/environments/modal_utils)
- COMPAT_MANIFEST.md, compat_manifest.json, scripts/check_compat_pointers.py and its lint step
- the reporting surfaces: CLI banner notice, `hermes plugins compat`, the `hermes doctor` section,
  the post-update notice, the Desktop one-time dialog, the loader's pre-import skip and the
  `plugins.allow_deprecated_imports` escape hatch

An external plugin that still imports an old path now fails to load with its ImportError as the
reason in `hermes plugins list`, the same path as any broken plugin.

hermes_cli/plugin_compat.py stays as three inert stubs (compat_report, removal_in_effect,
summary_lines): an already-running pre-removal `hermes update` lazy-imports them after the checkout
swap (tests/compat/old_updater_surface.json).

In-tree fallout, both already dead: hermes_cli/setup.py::_check_espeak_ng (no callers; its
`shutil` came from a compat block) and gateway/config.py::SessionResetPolicy ("retained solely for
the scheduled plugin-compat window"). Two test_run_agent patches targeted the removed
`run_agent.handle_function_call` pointer; they now patch `model_tools.handle_function_call`, the
seam production reads, like every sibling test in that file.

* chore: retrigger CI (zero-job startup_failure phantom)

* test: drop resolution allowlist rows for the two deleted which() sites

hermes_cli/setup.py::_check_espeak_ng (dead) and tools/skillevaluator_scan.py::scanner_available
(a restored definition inside a PLUGIN-COMPAT block) no longer exist; the stale-row gate requires
their allowlist entries go with them.
2026-09-28 10:21:41 -07:00
Alex Fournier
f5448560e9 Merge origin/main into chore/relay-0.9
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-09-27 11:52:04 -04:00
Jeffrey Quesnelle
7de8728cba Merge pull request #108345 from afourniernv/fix/relay-atof-cwd
fix(relay): include cwd in session and turn scopes
2026-09-24 01:06:16 -04:00
Alex Fournier
f1cddf129a Merge origin/main into chore/relay-0.9
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-09-23 10:59:09 -04:00
teknium1
d9ec0bcf56 fix(relay): read segments config through the gateway's own reader, keep -z in its launch dir (#95577)
Follow-up to the salvaged #88281 commits: read gateway.telemetry.session_segments
through hermes_cli.config_effective.load_user_config_effective(), the exact
primitive gateway.run._load_gateway_config() now delegates to, instead of
read_raw_config() + managed overlay. The raw read dropped ${VAR} expansion
(max_turns: ${SEG_TURNS} parsed as 0) and model-key canonicalization.

The same import also rebound TERMINAL_CWD to the home dir in `hermes -z`
(which does not pre-set it like cli.py): the launch dir's AGENTS.md was
never loaded and terminal commands ran in $HOME (#95577). The subprocess
guard now asserts TERMINAL_CWD / HERMES_QUIET / _HERMES_GATEWAY stay unset
too, and the fixtures patch the effective reader, which both the old and
new call paths go through.

Found by the core entrypoint parity E2E matrix (oneshot row, context_file).
2026-09-23 05:39:26 -07:00
Mr.XYS
853312c1fc fix(relay): stop importing gateway.run from non-gateway hosts (#87183)
gateway.run executes os.environ["_HERMES_GATEWAY"] / HERMES_QUIET /
HERMES_EXEC_ASK at module top level. _segments_config() late-imported it,
so any CLI/TUI/desktop/cron process hitting the relay turn lifecycle had
HERMES_EXEC_ASK=1 written into its own environ, routing dangerous-command
approvals onto the gateway path (tools/approval.py:3344) where the CLI has
no notify_cb — the approval panel never renders and commands hang forever
in pending_approval.

Read the gateway telemetry config via read_raw_config() + managed overlay
instead (no import side effects), and point the test fixture at the new
read path.
2026-09-23 05:39:26 -07:00
Alex Fournier
d7c657bf3c fix(relay): clear stale cwd scope data
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-09-23 07:46:43 -04:00
Alex Fournier
00c45c084d Merge origin/main into fix/relay-atof-cwd
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-09-23 07:43:29 -04:00
Alex Fournier
68fb2e9160 fix(relay): skip managed execution for empty activation
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-09-22 14:43:45 -04:00
Alex Fournier
ab8a99c730 fix(relay): honor ambient plugin configuration
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-09-21 14:02:05 -07:00
Alex Fournier
c70630732f chore(relay): scope 0.9 upgrade to compatibility changes
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-09-21 14:01:33 -07:00
Alex Fournier
1a60a49680 fix(relay): close concurrent logical scopes in stack order
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-09-21 14:01:33 -07:00
Alex Fournier
7d2d106d27 fix(relay): narrow foreign host conflict detection
Signed-off-by: Alex Fournier <afournier@nvidia.com>
Signed-off-by: mschwab <mschwab@nvidia.com>
2026-09-21 14:01:33 -07:00
mschwab
c7b2198a38 fix(relay): keep error diagnostics fatal and validate the exact payload
Relay 0.8's initialize() raised on error-level diagnostics; 0.9's validate()
reports them instead, so the migration had started writing configurations
Relay would refuse at runtime and commenting out the legacy variables that
would otherwise have warned about it. Error-level diagnostics now raise
again, and only warnings come back as the diagnostics list.

The probe also uses validate_exact(): plain validate() layers the payload
over whatever ambient user plugins.toml exists, which is not the document
the runtime loads. The migrate test checks the written file through the
same explicit-file layer the runtime uses.

Tool execution intercepts take a ToolExecutionContext in Relay 0.9; the one
in-repo registration, in tests, is updated to that shape.

Documents the two 0.9 behaviours a reader would not guess: the system
plugins.toml still layers beneath Hermes's explicit file, and a foreign
plugin host is only detectable when Hermes has a configuration selected.

Relocked with uv 0.9.28, the version CI pins. The remaining lock delta is
what that version itself emits for a relative exclude-newer.

Signed-off-by: mschwab <mschwab@nvidia.com>
2026-09-21 14:01:33 -07:00
mschwab
1477d8e659 feat(relay): move to the NeMo Relay 0.9 plugin-host API
Relay 0.9 (NVIDIA/NeMo-Relay#943) removed the process-global plugin
lifecycle Hermes was built on: plugin.report(), clear()/clear_async(),
load_dynamic_plugin_activation_specs() and initialize_with_dynamic_plugins()
are gone, initialize() now returns an owned PluginHostActivation, and the
validation report nests config diagnostics under "config".

The runtime now hands the selected plugins.toml to initialize() as
additional_plugins_toml, so Relay reads static components and
[[plugins.dynamic]] records from one file in place of user-file discovery,
and keeps the returned activation for teardown via close(). Hermes still
parses the file locally only to reject its own legacy [[dynamic_plugins]]
records before Relay sees them.

The foreign-activation preflight had no query to lean on any more; it is
now inferred from initialize() refusing the host lease, matched on the two
PluginError::Conflict messages Relay raises for that. Any other failure
stays fail-open as before.

validate_relay_plugin_payload uses plugin.validate() and no longer
activates the host to check a document.

Bumps nemo-relay to >=0.9,<0.10 and relocks (0.8.3 -> 0.9.0). Verified
against the real 0.9.0 binding: the four Relay suites pass 80/80 and the
other suites importing relay_runtime pass 199/199.

Signed-off-by: mschwab <mschwab@nvidia.com>
2026-09-21 14:01:33 -07:00
teknium1
148d1f6da5 fix(relay): shared-metrics task close skips a scope buried under a concurrent turn
Two concurrent Hermes turns in one session push two task scopes onto the same
physical stack. _finish_task popped its handle unconditionally, so the first turn
to finish hit the native "scope handle is not at the top of the stack" and logged a
full traceback on every overlap (#115471). pop_relay_scope_if_top compares the
handle to the current top inside the task context and skips the pop when a
sibling scope sits above it; the orphan is reclaimed by the existing session-close
drain in _close_scope_handle. Draining the sibling from the task close (as the
candidate PR did) would pop a LIVE turn scope, and guarding pop_relay_scope
itself would break _pop_with_drain, which relies on that raise.

Co-authored-by: Mohamad Kanso <91088196+MohamadKanso@users.noreply.github.com>
2026-09-19 23:42:20 -07:00
beardthelion
768d08c8d0 fix(relay): propagate push RuntimeError instead of retrying via exit fallback
_open_session_scope wrapped both executor.submit() and future.result()
in one try/except RuntimeError. The except branch exists for executor
refusal during interpreter shutdown, but result() re-raises whatever the
worker raised, so a RuntimeError from relay.scope.push itself was
misclassified as refusal and the exit_fallback lane ran the same push a
second time.

Keep submit() alone in the try and move result() to the else branch:
executor refusal still pushes synchronously once via exit_fallback,
while a push-side RuntimeError propagates after a single attempt. This
mirrors the split run_in_session already uses, where result() only
catches FuturesTimeoutError.

Tests pin all three arms: push RuntimeError propagates after one call
with no half-populated session state, submit() refusal still uses the
sync fallback once, and the coordinator end-to-end degrades to an
uninstrumented lease then recovers on the next acquire.
2026-09-19 23:42:20 -07:00
Alex Fournier
4ff64a1d06 Merge origin/main into fix/relay-atof-cwd
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-09-17 19:44:34 +02:00
teknium1
87ce653d1d feat(relay): migrate legacy HERMES_NEMO_RELAY_ATIF_*/ATOF_* vars into a validated relay-plugins.toml
3fad83df31 (Aug 11) moved Relay exporter config to a plugins.toml
selected by HERMES_NEMO_RELAY_PLUGINS_TOML. A .env still carrying the legacy
exporter vars and no TOML logs ONE warning and initialises no exporters, so
users who followed the earlier docs lost every trace silently (the
maintainer's stopped Aug 20, noticed Sep 14; five multiplexed profiles on
the same box carry the same eight vars today).

- `hermes_cli/relay_plugin_migrate.py`: build the document from the
  `nemo_relay.observability` dataclasses (`ComponentSpec(...).to_dict()`,
  so the `type = "file"` sink discriminator is emitted), validate it by
  activating it through `nemo_relay.plugin.initialize` + `clear_async`,
  write `<home>/relay-plugins.toml` (tomli_w when installed, minimal emitter
  otherwise), set HERMES_NEMO_RELAY_PLUGINS_TOML in that .env, and comment
  the legacy lines out (never delete). Defaults mirror the removed plugin so
  files land where they used to.
- `hermes update` runs it for the default home AND every live named profile
  (each writes its own TOML) as a best-effort post-update step, with a loud
  notice; `hermes migrate relay [--all-profiles] [--no-validate]` runs it on
  demand.
- The runtime WARNING and the `hermes doctor` finding now say "NO traces
  are being exported" and name the exact command and file path.
- Docs: environment-variables.md + built-in-plugins.md carry the migration
  note and a complete plugins.toml example including `type = "file"`.
2026-09-15 03:44:36 -07:00
Alex Fournier
6bfd5bce48 fix(relay): harden cwd resolution
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-09-11 09:31:13 -07:00
Alex Fournier
6cc7d54e1a fix(relay): include cwd in session and turn scopes
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-09-11 08:38:33 -07:00
David Gardner
6ee218602d feat(relay): pass API request metadata to Relay tracking
Signed-off-by: David Gardner <dagardner@nvidia.com>
2026-09-10 13:23:24 -07:00
Teknium
2776813df3 compat(plugins): temporary import-path shims for external plugins — ONE commit, revert on schedule
The Sep 2026 decomposition (PR #102117) makes internal import paths a non-API: names now live in
the focused modules that define them. This commit is the ONLY thing keeping the old paths alive,
so external plugins have time to update. It is deliberately a single, unsquashed commit:

    git revert <this sha>

removes every shim, stub and manifest at once on the announced date. Nothing in-tree may depend on
these pointers: scripts/check_compat_pointers.py (wired into lint.yml) fails CI if it does.

What it adds (see COMPAT_MANIFEST.md, compat_manifest.json):
- 332 facade modules get one delimited `PLUGIN-COMPAT` block appended at the end of the file
- 1,172 moved names resolved lazily via a module `__getattr__` (PEP 562) — never a top-level import,
  so no import cycles; facades that already had `__getattr__` get a chained one
- 592 third-party/stdlib names the old modules used to expose, with their original import statements
- 266 public definitions that had been deleted as unused, restored byte-for-byte from the pre-decomposition
  tree (+40 private helpers and 16 imports pulled in only because a restored definition needs them)
- 3 deleted modules recreated as re-export stubs (gateway/startup_watchdog, hermes_cli/observability/
  relay_runtime, tools/environments/modal_utils)
- private names (`_x`) get no pointer: they were never API (3,792 skipped)

Verified: all 335 touched modules import under a fresh HERMES_HOME and every manifest name resolves;
the lint reports zero in-tree uses; ruff clean; targeted suites unchanged.
2026-09-03 17:13:22 -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
fe03731efd review-fix(suppress-audit): codex_runtime/relay_runtime/shutdown_watchdog — restore BASE exception semantics 2026-09-03 09:41:59 -07:00
Teknium
0071ba9965 Merge origin/main (561b053f79) into simp/forwardport: forward-port 220 main commits into the simplified tree 2026-09-03 03:31:03 -07:00
Teknium
feed17bd75 refactor(agent/relay): unmanaged __next__ sentinel exit; codec baseline/_codec flattened; register_subagent turn check relies on active_turn invariant; small ctor/lookup collapses 2026-09-02 22:46:46 -07:00
Teknium
9b669ca507 refactor(agent/relay): _ManagedAttempt error-recording ctx manager; managed_callback_guard as contextmanager; plugin cleanup steps table; close_session via _operation; anthropic normalize predicates collapsed 2026-09-02 22:35:41 -07:00
Teknium
763cee5c20 refactor(agent/relay_runtime): _Lazy singleton for executor/segments config; _fail_open decorator replaces *_unguarded pairs; dead context reset dropped 2026-09-02 22:22:18 -07:00
Teknium
874843146b refactor(agent/relay_runtime): conversation initializer context built once 2026-09-02 21:22:33 -07:00
Teknium
aca6425ee9 refactor(agent/relay): Noop host via staticmethod lambdas; grouped default-flag declarations 2026-09-02 21:17:48 -07:00
Teknium
5ecba78cd8 refactor(agent/relay_runtime): merge active_turn guards; small guard inversions 2026-09-02 21:07:53 -07:00
Teknium
11dab00851 refactor(agent/relay_runtime): plugin config tracks ownership via _relay alone; fold intercept/subagent guards 2026-09-02 21:05:57 -07:00
Teknium
fa06ccf236 refactor(agent/relay_runtime): _operation() context manager for tracked Relay calls 2026-09-02 20:51:04 -07:00
Teknium
720a4d46ef refactor(agent/relay_runtime): end_turn accounting via suppress+lock; logical-call unwind pops from the tail 2026-09-02 20:37:43 -07:00
Teknium
b121ac4a83 refactor(agent/relay_llm): execute/execute_async default to the inherited turn's session; execute_current(_async) become aliases 2026-09-02 20:29:43 -07:00
Teknium
5adb74fd24 refactor(agent/relay_runtime,transports): inline single-use _push_session_scope; get_transport rediscovery predicate 2026-09-02 20:23:21 -07:00
Teknium
38534b92a1 refactor(agent/relay_runtime): plugin configuration acquire = preflight-or-activate; drop _remember; reflow boolean spans 2026-09-02 20:07:59 -07:00
Teknium
9d0586c275 refactor(agent/relay_runtime): resolve_execution_context reuses relay_instrumentation_enabled; tighter turn unwind/profile key 2026-09-02 19:59:48 -07:00
Teknium
c83de74cb7 refactor(agent/relay): pack call/signature spans to 120 cols 2026-09-02 19:55:45 -07:00
Teknium
bc224e648d refactor(agent/relay): RelayRuntime._lookup for locked registry reads; first-close-error helper; subagent parent predicate leans on active_turn 2026-09-02 19:52:58 -07:00
Teknium
ff4d896e50 refactor(agent/relay,transports): fold docstring whitespace (text unchanged) 2026-09-02 19:49:06 -07:00
Teknium
b162ef97b1 refactor(agent/relay_runtime): contextlib.suppress for swallow-only excepts; shared timeout message; daemon-thread outcome box 2026-09-02 19:46:01 -07:00
Teknium
46f696c48b refactor(agent/relay,transports): anthropic build_kwargs default table + thinking-type set; compact accumulator/logical-scope plumbing 2026-09-02 19:43:35 -07:00