Skip to content

fix(inference): propagate anthropic wire mode to Hermes sandbox config sync - #4747

Closed
jahubba wants to merge 1 commit into
NVIDIA:mainfrom
jahubba:fix/hermes-anthropic-inference-sync
Closed

fix(inference): propagate anthropic wire mode to Hermes sandbox config sync#4747
jahubba wants to merge 1 commit into
NVIDIA:mainfrom
jahubba:fix/hermes-anthropic-inference-sync

Conversation

@jahubba

@jahubba jahubba commented Jun 4, 2026

Copy link
Copy Markdown

Summary

nemoclaw inference set --provider anthropic-prod (or compatible-anthropic-endpoint) leaves Hermes-type sandboxes unable to run any inference: the Hermes config sync writes model.provider: custom without an api_mode, so the agent speaks OpenAI chat-completions at an anthropic-type provider and the gateway L7 policy denies every call (DENIED inference.local:443 POST /chat/completions). This PR propagates the anthropic wire mode through the Hermes sync, matching what patchOpenClawInferenceConfig already does for OpenClaw sandboxes.

Related Issue

Fixes #4746

Changes

  • src/lib/actions/inference-set.tspatchHermesInferenceConfig writes model.api_mode: anthropic_messages when route.inferenceApi === "anthropic-messages" (Hermes honors this key for custom providers), and clears the key on non-anthropic routes so a stale wire mode never survives a provider switch.
  • src/lib/inference/config.tsgetSandboxInferenceConfig keeps compatible-anthropic-endpoint on the OpenAI wire only for an explicit preferredInferenceApi === "openai-completions"; the null-default no longer silently selects the OpenAI branch for an anthropic-type provider (the Hermes sync never passes a preference).
  • 6 new unit tests across inference-set.test.ts and config.test.ts: anthropic wire propagation for both providers, stale api_mode cleanup on switch-away, anthropic-prod route mapping, default-vs-explicit preference for compatible-anthropic-endpoint.

Note on local verification: this was developed on an aarch64 Jetson host where a fixed set of environment-dependent suites (NIM/GPU preflight/install checks) fail identically on a clean main checkout; the affected test files pass 51/51 and npm run typecheck:cli + Biome are clean. Relying on CI for the full matrix.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with doc updates
  • Doc only (prose changes, no code sample modifications)
  • Doc only (includes code sample changes)

Verification

  • npx prek run --all-files passes
  • npm test passes
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • npm run docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Jason Hubbard jasonahubbard@gmail.com

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Fixed Anthropic endpoint routing to correctly respect explicit API preference selections and prevent unintended protocol switches when using compatible endpoints.
  • Tests

    • Expanded test coverage for Anthropic endpoint configuration and provider switching scenarios.

…g sync

nemoclaw inference set left Hermes-type sandboxes unable to run inference
after switching to anthropic-prod or compatible-anthropic-endpoint: the
Hermes config sync wrote model.provider: custom without an api_mode, so
Hermes spoke OpenAI chat-completions at an anthropic-type provider and the
gateway L7 policy denied every call (POST /chat/completions not allowed).

Two fixes:
- patchHermesInferenceConfig now writes model.api_mode: anthropic_messages
  when the route is anthropic-wire (and clears the key otherwise, so a
  stale wire mode never survives a provider switch).
- getSandboxInferenceConfig keeps compatible-anthropic-endpoint on the
  OpenAI wire only for an explicit preferredInferenceApi, not the null
  default - callers without a baked preference (the Hermes sync) now get
  the anthropic branch an anthropic-type provider requires.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@copy-pr-bot

copy-pr-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

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: afe2f4c0-2160-44ac-a026-8a372b81fbb0

📥 Commits

Reviewing files that changed from the base of the PR and between 17734b1 and 37760bc.

📒 Files selected for processing (4)
  • src/lib/actions/inference-set.test.ts
  • src/lib/actions/inference-set.ts
  • src/lib/inference/config.test.ts
  • src/lib/inference/config.ts

📝 Walkthrough

Walkthrough

This PR fixes Hermes sandbox inference for Anthropic providers by adding the missing anthropic-messages wire-mode declaration to the Hermes config and tightening the conditional for compatible-anthropic-endpoint to avoid silent OpenAI-wire fallback when no API preference is passed.

Changes

Hermes Anthropic Provider Wire-Mode Fix

Layer / File(s) Summary
Hermes config api_mode propagation
src/lib/actions/inference-set.ts, src/lib/actions/inference-set.test.ts
patchHermesInferenceConfig now sets modelConfig.api_mode: "anthropic_messages" when the resolved inference API is anthropic-messages, and removes stale api_mode for all other APIs. Tests verify propagation for both anthropic-prod and compatible-anthropic-endpoint, and verify cleanup when switching from Anthropic to OpenAI routes.
Sandbox inference config conditional tightening
src/lib/inference/config.ts, src/lib/inference/config.test.ts
getSandboxInferenceConfig now requires explicit preferredInferenceApi === "openai-completions" to route compatible-anthropic-endpoint to the OpenAI wire, preventing silent fallback when no preference is passed. Tests verify anthropic-prod routes to Anthropic wire, compatible-anthropic-endpoint defaults to Anthropic wire, and switches to OpenAI wire only on explicit openai-completions request.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

fix, enhancement: inference, area: inference, integration: hermes, bug-fix, area: providers

Suggested reviewers

  • cv

Poem

🐰 A Hermes hop through Anthropic fields,
Where api_mode now reveals its yields,
No silent falls to OpenAI's way,
Just anthropic-messages on display,
Configuration aligned, the agents play! 🎯

🚥 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 clearly and specifically describes the main change: propagating anthropic wire mode to Hermes sandbox config sync, which is the core fix for the broken Hermes-Anthropic inference.
Linked Issues check ✅ Passed The PR fully implements both required coding fixes from issue #4746: (1) patchHermesInferenceConfig now writes model.api_mode for anthropic-messages and clears it for non-anthropic routes; (2) getSandboxInferenceConfig restricts compatible-anthropic-endpoint to OpenAI wire only on explicit openai-completions preference.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the two root causes identified in issue #4746 across inference-set.ts, config.ts, and their corresponding test files with no extraneous modifications.

✏️ 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 and usage tips.

@sandl99

sandl99 commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

#4402 did fix the issue on v0.0.59

@sandl99 sandl99 closed this Jun 5, 2026
@wscurran wscurran added area: inference Inference routing, serving, model selection, or outputs area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery bug-fix PR fixes a bug or regression integration: hermes Hermes integration behavior provider: anthropic Anthropic or Claude provider behavior labels Jun 5, 2026
@jahubba

jahubba commented Jun 8, 2026

Copy link
Copy Markdown
Author

Thanks @sandl99. I think #4847 is needed to fully resolve this one. The path this issue reports — nemoclaw inference set --provider anthropic-prod — is handled by patchHermesInferenceConfig, which on v0.0.59 still writes provider: custom with no api_mode, so the gateway keeps denying /chat/completions. #4847 adds the missing api_mode to that patch and lands in v0.0.60 (verified: its patchHermesInferenceConfig → Anthropic-routes test asserts api_mode: anthropic_messages). So this is resolved as of v0.0.60. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: inference Inference routing, serving, model selection, or outputs area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery bug-fix PR fixes a bug or regression integration: hermes Hermes integration behavior provider: anthropic Anthropic or Claude provider behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nemoclaw inference set breaks Hermes sandboxes for Anthropic providers (Hermes sync drops the anthropic-messages wire mode)

3 participants