Skip to content

feat: Add relay support for hermes_cli adapter - #15

Merged
dagardner-nv merged 14 commits into
NVIDIA:mainfrom
dagardner-nv:david-hermes-cli-relay
Jun 24, 2026
Merged

feat: Add relay support for hermes_cli adapter#15
dagardner-nv merged 14 commits into
NVIDIA:mainfrom
dagardner-nv:david-hermes-cli-relay

Conversation

@dagardner-nv

@dagardner-nv dagardner-nv commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator
  • Move code common to both hermes_cli and hermes_sdk to adapters/common/src/nemo_fabric_adapters/common/hermes.py
  • Add a small pre-flight check for the API key being defined in the hermes_cli, mimicking behavior of hermes_sdk

Summary by CodeRabbit

  • New Features
    • Added shared Hermes configuration helpers (including MCP/server mapping, plugin/relay support, and config writing with YAML output).
    • Improved Hermes CLI/SDK config generation with consistent model selection, base URL resolution, and relay artifact collection.
    • Enabled Hermes relay-capable profile with enhanced observability artifact outputs.
  • Bug Fixes
    • Added Hermes CLI API-key preflight that fails fast when the required environment variable is missing.
    • Removed reliance on optional agent_profile fields in Hermes-related configs/fixtures.
  • Tests
    • Expanded Hermes common unit tests, updated fixtures, and added a Hermes CLI API-key preflight end-to-end test.
  • Chores
    • Added a relay install extra and included PyYAML for tests.

Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
…copy/pasted code

Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: e94a63d8-6fde-4590-9e1f-77a7740cc393

📥 Commits

Reviewing files that changed from the base of the PR and between 8524285 and c819489.

📒 Files selected for processing (2)
  • examples/code-review-agent/profiles/hermes-cli-relay.yaml
  • tests/test_adapaters_hermes_common.py
✅ Files skipped from review due to trivial changes (1)
  • examples/code-review-agent/profiles/hermes-cli-relay.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_adapaters_hermes_common.py

📝 Walkthrough

Walkthrough

Shared Hermes helpers are extracted into a common module and consumed by both Hermes adapters. The CLI and SDK flows now delegate configuration, relay handling, and summaries to shared code, with updated tests, fixtures, and a new relay profile.

Changes

Shared Hermes helper extraction

Layer / File(s) Summary
Shared Hermes config helpers and core tests
adapters/common/src/nemo_fabric_adapters/common/*, tests/conftest.py, tests/test_adapaters_hermes_common.py, pyproject.toml
Defines shared Hermes payload, config, YAML, and normalization helpers, plus fixtures and unit tests for them.
Relay plugin helpers and relay-facing artifacts
adapters/common/src/nemo_fabric_adapters/common/hermes.py, tests/test_adapaters_hermes_common.py, examples/code-review-agent/profiles/hermes-cli-relay.yaml, pyproject.toml
Adds relay plugin loading, environment setup, artifact collection, relay tests, a relay profile, and the relay dependency.
Hermes CLI adapter integration and preflight coverage
adapters/hermes-cli/src/nemo_fabric_adapters/hermes_cli/adapter.py, tests/test_hermes_cli_preflight.py, tests/test_hermes_cli_fields.py, tests/fixtures/hermes-cli-agent/agent.yaml, tests/smoke_hermes_config_mapping.py, tests/fixtures/hermes-shim-agent/*
Wires the CLI adapter to the shared helpers, adds API-key preflight validation, and updates related tests and fixtures.
Hermes SDK adapter integration
adapters/hermes-sdk/src/nemo_fabric_adapters/hermes_sdk/adapter.py
Routes SDK config, relay, history, and summary handling through the shared Hermes helpers and removes local duplicates.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • NVIDIA/NeMo-Fabric#12: Shares Hermes SDK history-selection behavior that this PR routes through hermes_common.

Suggested reviewers

  • AjayThorve
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main change: adding relay support to the hermes_cli adapter.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

…s-cli-relay

Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>
@dagardner-nv
dagardner-nv marked this pull request as ready for review June 24, 2026 16:31

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@adapters/common/src/nemo_fabric_adapters/common/hermes.py`:
- Around line 211-245: In configure_hermes_relay, clear any previously set
HERMES_NEMO_RELAY_* environment variables before applying the new relay config
so stale ATOF/ATIF values do not leak between requests. Add the cleanup at the
start of the function, then reapply only the keys for enabled observability
sections from load_relay_plugin_config, keeping the existing behavior in
configure_hermes_relay, agent_name, and relay_model_name intact.
- Around line 302-306: relay_model_name currently reads the selected model
directly from models_payload and calls .get() on whatever is stored there, which
can crash on malformed non-dict entries. Update relay_model_name to use
selected_model_config() for resolving the chosen model config instead of
accessing the raw models map, and keep the existing fallback chain to
settings.get("model_name") and "unknown". This should be done in hermes.py
within relay_model_name, reusing selected_model_config() to safely handle bad
models.<selected> shapes.
- Around line 315-326: The artifact collection loop in hermes.py is too broad
because it uses wildcard globs for the atof/atif sections, which can attach
unrelated files from a shared directory. Update the section handling in the
artifact-collection logic so each relay section only adds the files explicitly
configured for that run, using the section’s own configuration rather than
scanning all matching *.jsonl or *.json files in the output directory. Keep the
change localized to the existing loop that builds artifacts so the filtering
remains tied to the section_name and its config.

In `@adapters/hermes-cli/src/nemo_fabric_adapters/hermes_cli/adapter.py`:
- Around line 46-55: The preflight API key check currently only inspects the
parent process environment, so it can reject valid configs that provide the key
through the merged subprocess environment. Update _api_key_preflight_check to
validate against the same effective environment built by build_env() (including
settings["env"] merged with os.environ) before raising the missing api_key_env
RuntimeError. Keep the check scoped to the resolved api_key_env from
settings/model_config and use the merged env as the source of truth.

In `@adapters/hermes-sdk/src/nemo_fabric_adapters/hermes_sdk/adapter.py`:
- Around line 22-28: The Hermes SDK adapter currently relies on a source-tree
sys.path hack to import nemo_fabric_adapters.common.hermes, but the package
metadata does not declare that shared adapter as a runtime dependency. Update
the Hermes SDK packaging/dependency definition so nemo_fabric_adapters.common is
included when the hermes SDK is installed, and adjust the hermes extra/runtime
requirements to pull in the shared adapter alongside hermes-agent. Use the
adapter.py import of hermes_common and the package metadata that currently has
dependencies = [] and the hermes extra as the places to update.

In `@tests/conftest.py`:
- Around line 63-65: The test setup in conftest.py is adding the local
adapters_common path to sys.path in a way that can lose import precedence to an
installed nemo_fabric_adapters package. Update the sys.path handling in the
adapters_common block to insert the local path at the front instead of appending
it, so the test suite resolves the repository’s local adapter modules first.

In `@tests/test_hermes_cli_preflight.py`:
- Around line 24-27: The test is mutating process-global os.environ directly and
leaving FAB_CI_FAKE_KEY behind between parametrized runs, so update the
preflight test to use monkeypatch in the same test scope. In the test that
checks CLI preflight behavior, replace the direct os.environ assignment and
assertion around FAB_CI_FAKE_KEY with monkeypatch.setenv and monkeypatch.delenv
so each case is isolated and later tests do not inherit leaked environment
state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ae9a5ec6-eb96-4d1f-bfbb-0432b51ad339

📥 Commits

Reviewing files that changed from the base of the PR and between e7892f5 and f799872.

📒 Files selected for processing (15)
  • adapters/common/src/nemo_fabric_adapters/common/__init__.py
  • adapters/common/src/nemo_fabric_adapters/common/hermes.py
  • adapters/hermes-cli/src/nemo_fabric_adapters/hermes_cli/adapter.py
  • adapters/hermes-sdk/src/nemo_fabric_adapters/hermes_sdk/adapter.py
  • examples/code-review-agent/profiles/hermes-cli-relay.yaml
  • pyproject.toml
  • tests/conftest.py
  • tests/fixtures/hermes-cli-agent/agent.yaml
  • tests/fixtures/hermes-shim-agent/adapters/hermes-shim/src/nemo_fabric_test_adapters/hermes_shim/adapter.py
  • tests/fixtures/hermes-shim-agent/agent.yaml
  • tests/fixtures/hermes-shim-agent/profiles/harbor-swebench-django-13741.yaml
  • tests/fixtures/hermes-shim-agent/profiles/swebench-shim.yaml
  • tests/test_adapaters_hermes_common.py
  • tests/test_hermes_cli_fields.py
  • tests/test_hermes_cli_preflight.py
💤 Files with no reviewable changes (5)
  • tests/fixtures/hermes-shim-agent/adapters/hermes-shim/src/nemo_fabric_test_adapters/hermes_shim/adapter.py
  • tests/fixtures/hermes-shim-agent/agent.yaml
  • tests/fixtures/hermes-shim-agent/profiles/harbor-swebench-django-13741.yaml
  • tests/fixtures/hermes-shim-agent/profiles/swebench-shim.yaml
  • tests/fixtures/hermes-cli-agent/agent.yaml

Comment thread adapters/common/src/nemo_fabric_adapters/common/hermes.py
Comment thread adapters/common/src/nemo_fabric_adapters/common/hermes.py
Comment thread adapters/common/src/nemo_fabric_adapters/common/hermes.py
Comment thread adapters/hermes-cli/src/nemo_fabric_adapters/hermes_cli/adapter.py
Comment thread adapters/hermes-sdk/src/nemo_fabric_adapters/hermes_sdk/adapter.py
Comment thread tests/conftest.py
Comment thread tests/test_hermes_cli_preflight.py
Signed-off-by: David Gardner <dagardner@nvidia.com>
@dagardner-nv dagardner-nv added the enhancement New feature or request label Jun 24, 2026
Signed-off-by: David Gardner <dagardner@nvidia.com>
Signed-off-by: David Gardner <dagardner@nvidia.com>

@AjayThorve AjayThorve left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@dagardner-nv
dagardner-nv merged commit ae37986 into NVIDIA:main Jun 24, 2026
4 checks passed
@dagardner-nv
dagardner-nv deleted the david-hermes-cli-relay branch July 9, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants