Commit Graph

80 Commits

Author SHA1 Message Date
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
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
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
Teknium
552c5b62ca refactor(agent/relay_runtime): remove dead emit_mark (module fn + RelayRuntime method; only a test asserted its False path) 2026-09-02 19:31:18 -07:00
Teknium
e58175139d refactor(agent/relay): drop _safe in favour of _warn_on_error/suppress; pack spans to 110 cols; strip intra-function separator blanks 2026-09-02 19:24:48 -07:00
Teknium
2ed4135398 refactor(agent/relay_runtime): _warn_on_error fail-open helper for telemetry paths; conversation/compaction bodies lifted out of try blocks 2026-09-02 19:12:37 -07:00
Teknium
be3a659b14 refactor(agent/relay): compact relay/transport docstrings and comments (keep every invariant); reflow boolean spans; drop no-op helpers 2026-09-02 18:53:45 -07:00
Teknium
a560fd840c refactor(agent/relay): fold execute/execute_async invoke into _ManagedAttempt; stream() = ManagedLlmStream; codec tool normalizer table; plugin acquire preflight/activate split; pack call/signature spans 2026-09-02 18:35:48 -07:00
Teknium
00cd12f7e4 refactor(agent/relay): fold relay_llm attempt scaffolding into _ManagedAttempt; dedupe runtime session/scope paths; drop dead relay_runtime module-level shims 2026-09-02 13:29:48 -07:00
Alex Fournier
31e7237adb fix(relay): upgrade to 0.8.1
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-08-28 08:28:21 -04:00
Alex Fournier
31402f630b fix(relay): complete native plugin cutover
Signed-off-by: Alex Fournier <afournier@nvidia.com>
2026-08-19 08:52:03 -07:00
Bryan Bednarski
93bec27f66 fix(relay): preserve shutdown scope cleanup
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
2026-08-19 08:52:03 -07:00
Bryan Bednarski
6ec2c0ba8b fix(relay): define process-wide profile policy
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
2026-08-19 08:52:03 -07:00
Bryan Bednarski
3fad83df31 fix(relay): guard native plugin ownership cutover
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
2026-08-19 08:52:03 -07:00
Bryan Bednarski
ad9fb060c5 fix(relay): clarify opt-in plugin layering
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
2026-08-19 08:52:02 -07:00
Bryan Bednarski
c86fd74e28 refactor(relay): require 0.7 plugin APIs
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
2026-08-19 08:52:02 -07:00
Bryan Bednarski
4e34dfc932 refactor(relay): use canonical dynamic plugin config
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
2026-08-19 08:52:02 -07:00
Bryan Bednarski
0b7288ebcb fix(relay): require explicit plugin configuration
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
2026-08-19 08:52:01 -07:00
Bryan Bednarski
e7da915f67 fix(relay): defer subscriber flush to shutdown
Signed-off-by: Bryan Bednarski <bbednarski@nvidia.com>
2026-08-19 08:52:01 -07:00