Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .github/actions/resolve-hermes-base-image/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ runs:

image="ghcr.io/nvidia/nemoclaw/hermes-sandbox-base"
min_glibc="2.39"
expected_hermes_version="$(sed -nE 's/^ARG HERMES_SEMVER=([0-9]+\.[0-9]+\.[0-9]+)$/\1/p' agents/hermes/Dockerfile.base)"
if [[ ! "$expected_hermes_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Could not read one valid HERMES_SEMVER from agents/hermes/Dockerfile.base"
exit 1
fi

glibc_version() {
docker run --rm --entrypoint /usr/bin/ldd "$1" --version 2>/dev/null \
Expand All @@ -26,6 +31,13 @@ runs:
[[ -n "$have" ]] && [[ "$(printf '%s\n%s\n' "$min_glibc" "$have" | sort -V | head -n 1)" == "$min_glibc" ]]
}

hermes_version() {
local ref="$1"
docker run --rm --entrypoint /usr/local/bin/hermes "$ref" --version 2>/dev/null \
| sed -nE 's/.*v([0-9]+\.[0-9]+\.[0-9]+).*/\1/p; s/^([0-9]+\.[0-9]+\.[0-9]+)$/\1/p' \
| head -n 1
}

# Build-time package/import guard only. Authenticated HTTPS execution is
# validated by test/e2e/live/mcp-bridge.test.ts against a
# final Hermes sandbox image and OpenShell policy.
Expand All @@ -50,7 +62,7 @@ runs:
}

try_image() {
local ref="$1" version digest_ref
local ref="$1" version hermes_semver digest_ref
if ! docker pull "$ref" >/dev/null 2>&1; then
return 1
fi
Expand All @@ -64,6 +76,11 @@ runs:
echo "::warning::Hermes sandbox base image ${ref} has glibc ${version:-unknown}; need >= ${min_glibc}"
return 1
fi
hermes_semver="$(hermes_version "$digest_ref" || true)"
if [[ "$hermes_semver" != "$expected_hermes_version" ]]; then
echo "::warning::Hermes sandbox base image ${ref} has Hermes ${hermes_semver:-unknown}; need ${expected_hermes_version}"
return 1
fi
if ! layout_ok "$digest_ref"; then
echo "::warning::Hermes sandbox base image ${ref} contains retired sandbox state; trying another candidate"
return 1
Expand Down Expand Up @@ -109,6 +126,11 @@ runs:
echo "::error::Local Hermes sandbox base image has glibc ${version:-unknown}; need >= ${min_glibc}"
exit 1
fi
local_hermes_version="$(hermes_version nemoclaw-hermes-base-local || true)"
if [[ "$local_hermes_version" != "$expected_hermes_version" ]]; then
echo "::error::Local Hermes sandbox base image has Hermes ${local_hermes_version:-unknown}; need ${expected_hermes_version}"
exit 1
fi
if ! layout_ok nemoclaw-hermes-base-local; then
echo "::error::Local Hermes sandbox base image contains retired sandbox state"
exit 1
Expand Down
8 changes: 4 additions & 4 deletions agents/hermes/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ RUN chmod 755 /usr/local/bin/nemoclaw-start /usr/local/lib/nemoclaw/sandbox-init
RUN test -x /usr/local/lib/nemoclaw/validate-hermes-env-secret-boundary.py \
|| { echo "ERROR: validate-hermes-env-secret-boundary.py missing or not executable" >&2; exit 1; }

# Hermes v0.17.0 computes `sessions list` preview from the first user message,
# Hermes v0.18.0 computes `sessions list` preview from the first user message,
# while #5254's user-facing expectation is that the existing row reflects the
# latest resumed/continued one-shot turn. Patch only the pinned query shape and
# prove the SessionDB list contract at build time so a Hermes update cannot
Expand Down Expand Up @@ -203,7 +203,7 @@ PY
# chain tampering of the build context (an attacker rewriting the file has to
# also rewrite the Dockerfile-committed hash, which reviewers gate). Regenerate
# with `sha256sum agents/hermes/{hermes-wrapper.py,validate-env-secret-boundary.py}`.
ARG NEMOCLAW_HERMES_WRAPPER_SHA256=34ef50ea993c776f28312bcf659e908eeae3c07e4094a49e513cb320eee6538f
ARG NEMOCLAW_HERMES_WRAPPER_SHA256=ec8b0e4d6254175929d5a02240acd6af25e94774a30b36ba5c6f5a69c32fb9d7
ARG NEMOCLAW_HERMES_VALIDATOR_SHA256=970d7ff03bc409ff1d5ca46bfdbd2a42ac28a32a810ccc147a508301bff38496
# hadolint ignore=DL4006
RUN printf '%s %s\n' \
Expand Down Expand Up @@ -232,10 +232,10 @@ RUN hermes_version_output="$(/usr/local/bin/hermes --version)" \
echo "ERROR: could not parse Hermes semver from: $hermes_version_output" >&2; \
exit 1; \
fi \
&& if [ "$hermes_semver" != "0.17.0" ] \
&& if [ "$hermes_semver" != "0.18.0" ] \
&& { grep -q '_translate_resumed_oneshot' /usr/local/lib/nemoclaw/hermes-wrapper.py \
|| grep -q 'EXPECTED_OCCURRENCES' /usr/local/lib/nemoclaw/patch-hermes-session-list-preview.py; }; then \
echo "ERROR: installed Hermes ${hermes_semver} but Hermes v0.17.0 compatibility workarounds are still installed; re-review #5254 workaround removal before upgrading Hermes" >&2; \
echo "ERROR: installed Hermes ${hermes_semver} but Hermes v0.18.0 compatibility workarounds are still installed; re-review #5254 workaround removal before upgrading Hermes" >&2; \
exit 1; \
fi
# This runs before `/usr/local/bin/hermes` is moved to `hermes.real`, so the
Expand Down
10 changes: 5 additions & 5 deletions agents/hermes/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ ENV DEBIAN_FRONTEND=noninteractive
# pyproject.toml, HERMES_TARBALL_SHA256 the GitHub tarball checksum, and
# HERMES_NPM_INTEGRITY the `npm view hermes-agent@<semver> dist.integrity`
# sha512 used as a registry cross-check at build time.
# Calver tag v2026.6.19 = Hermes Agent v0.17.0.
ARG HERMES_VERSION=v2026.6.19
ARG HERMES_SEMVER=0.17.0
ARG HERMES_TARBALL_SHA256=69b805ec0a7a7be880068ba8a3b17479d7ba29f0cac0a2e9c6692c02f346ba91
ARG HERMES_NPM_INTEGRITY=sha512-PzSJiYqmwpTudmakYs2oCJ57OW3VwEJYf8buTuKvuRvcYEUf/KOTu2dD6pLf2XYgDKErpvcDaoSAJ1nGCyvzAA==
# Calver tag v2026.7.1 = Hermes Agent v0.18.0.
ARG HERMES_VERSION=v2026.7.1
ARG HERMES_SEMVER=0.18.0
ARG HERMES_TARBALL_SHA256=ec8a380629cc2f3f2102dd92cad50c4ded706fe59c0e359a05681166a0ae2991
ARG HERMES_NPM_INTEGRITY=sha512-fS+8MsE69shNPmFnKDrE1a+KUDEEXgbyN/QM7J+2nh294gTjh2wCknk2tfMsD03GhSxl7YwyDmp6e5HLYzw8yA==
ARG HERMES_UV_EXTRAS="anthropic messaging web pty mcp"
ARG UV_VERSION=0.11.8

Expand Down
6 changes: 5 additions & 1 deletion agents/hermes/config/hermes-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function buildHermesConfig(
};

const config: Record<string, unknown> = {
_config_version: 30,
_config_version: 32,
_nemoclaw_upstream: upstream,
model: modelConfig,
providers: {
Expand All @@ -104,6 +104,10 @@ export function buildHermesConfig(
agent: {
max_turns: 60,
reasoning_effort: "medium",
// Config v30→32 migrations switch the old implicit/auto behavior off.
// Generated configs start at v32, so persist the same migrated value
// instead of skipping directly to Hermes' legacy "auto" default.
verify_on_stop: false,
},
tools: {
tool_search: {
Expand Down
6 changes: 3 additions & 3 deletions agents/hermes/hermes-wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ def _run_gateway_guard(guard_path: str) -> int:
"--resume": "--resume",
}
# Keep this allowlist aligned with the top-level flags accepted by the pinned
# Hermes Agent CLI in agents/hermes/Dockerfile.base (HERMES_VERSION=v2026.6.19,
# HERMES_SEMVER=0.17.0) and agents/hermes/manifest.yaml (expected_version
# "0.17.0"). Unknown flags deliberately fail closed by passing the original argv
# Hermes Agent CLI in agents/hermes/Dockerfile.base (HERMES_VERSION=v2026.7.1,
# HERMES_SEMVER=0.18.0) and agents/hermes/manifest.yaml (expected_version
# "0.18.0"). Unknown flags deliberately fail closed by passing the original argv
# through to upstream Hermes.
_BOOLEAN_FLAGS = {
"--worktree",
Expand Down
6 changes: 3 additions & 3 deletions agents/hermes/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ homepage: "https://github.com/NousResearch/hermes-agent"
install_method: curl # curl install.sh | bash
binary_path: /usr/local/bin/hermes
version_command: "hermes --version"
expected_version: "0.17.0"
# Hermes reports semver from `hermes --version` (e.g. `0.17.0`) even though its
# GitHub release cadence is calendar-based (`v2026.6.19`). Declaring the
expected_version: "0.18.0"
# Hermes reports semver from `hermes --version` (e.g. `0.18.0`) even though its
# GitHub release cadence is calendar-based (`v2026.7.1`). Declaring the
# scheme keeps the staleness check off the shape heuristic when a manifest
# could otherwise straddle both schemes (#6049).
version_scheme: semver
Expand Down
4 changes: 2 additions & 2 deletions agents/hermes/patch-session-list-preview.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env python3
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""Patch pinned Hermes v0.17.0 session-list previews to show the latest user turn.
"""Patch pinned Hermes v0.18.0 session-list previews to show the latest user turn.

Source-of-truth note for this localized Hermes runtime patch:
- Invalid state: Hermes v0.17.0 computes `sessions list` preview text from
- Invalid state: Hermes v0.18.0 computes `sessions list` preview text from
the first user message, but #5254's resumed/continued one-shot UX expects
the original row to reflect the latest appended turn.
- Value being patched: pinned/prebuilt `/opt/hermes/hermes_state.py`
Expand Down
4 changes: 4 additions & 0 deletions docs/manage-sandboxes/messaging-channels.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ When both Slack allowlists are set, NemoClaw requires the mention to come from o
Channel messages still require an explicit bot mention.
When a Slack channel `@mention` is denied by these allowlists, NemoClaw sends a denial notice back to the sender instead of dropping the message silently.
During sandbox startup, NemoClaw normalizes OpenShell credential placeholders into the environment shape expected by the Slack runtime, so post-rebuild Slack starts use the gateway-managed tokens instead of literal placeholder strings.
<AgentOnly variant="hermes">
NemoClaw enables Hermes rich Slack rendering. Final responses can use Slack Block Kit, including native table blocks for Markdown table output.
This rendering change uses the existing Slack credentials and does not require additional scopes or a new app installation.
</AgentOnly>
Slack Socket Mode allows one active connection per app-level token.
If another sandbox on the same gateway already uses the same Slack app token, onboarding and `channels add slack` warn before continuing in interactive mode and abort in non-interactive mode.
Use `--force` only when you intentionally want to move the Slack Socket Mode session to the new sandbox.
Expand Down
20 changes: 20 additions & 0 deletions src/lib/agent/base-image-hermes-resolution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ describe("Hermes base-image resolver integration", () => {
]);
const captureByEntrypoint = new Map([
["/opt/hermes/.venv/bin/python", "nemoclaw-hermes-mcp-runtime-ok"],
["/usr/local/bin/hermes", "Hermes Agent v0.18.0 (2026.7.1)"],
["/usr/bin/ldd", "ldd (GNU libc) 2.41"],
]);

Expand Down Expand Up @@ -136,4 +137,23 @@ describe("Hermes base-image resolver integration", () => {
`Hermes final image does not accept base image ref '${platformRef}'`,
);
});

it("reuses a validated pinned platform-digest resolution hint", () => {
const initial = createAgentSandbox(makeAgent());
createdBuildContexts.push(initial.buildCtx);
const hint = initial.baseImageResolutionMetadata;
expect(hint).not.toBeNull();

dockerMocks.imageInspect.mockImplementation((ref: string) => {
expect(ref).not.toBe(trackedRef);
return { status: ref === platformRef ? 0 : 1 };
});

const reused = createAgentSandbox(makeAgent(), {
resolutionHint: hint ?? undefined,
});
createdBuildContexts.push(reused.buildCtx);

expect(reused.baseImageResolutionMetadata).toEqual(hint);
});
});
58 changes: 43 additions & 15 deletions src/lib/agent/base-image-hermes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,65 @@ describe("agent base image provisioning", () => {
vi.restoreAllMocks();
});

it("probes resolved Hermes bases for the native MCP Streamable HTTP runtime", () => {
it("probes resolved Hermes bases for the pinned version and native MCP runtime", () => {
withMockedDocker(({ ensureAgentBaseImage, dockerCaptureMock, resolveSandboxBaseImageMock }) => {
const compatibleOutputByEntrypoint = new Map([
["/usr/local/bin/hermes", "Hermes Agent v0.18.0 (2026.7.1)"],
["/opt/hermes/.venv/bin/python", "nemoclaw-hermes-mcp-runtime-ok"],
]);
dockerCaptureMock.mockImplementation(
(args: string[]) => compatibleOutputByEntrypoint.get(args[3]) ?? "",
);
ensureAgentBaseImage(makeAgent());
const options = resolveSandboxBaseImageMock.mock.calls[0]?.[0] as {
validateImage?: (imageRef: string) => boolean;
};

expect(options.validateImage?.("hermes-base:test")).toBe(true);
const compatibleLocalRef = "nemoclaw-hermes-sandbox-base-local:test";
expect(options.validateImage?.(compatibleLocalRef)).toBe(true);
expect(dockerCaptureMock).toHaveBeenCalledWith(
["run", "--rm", "--entrypoint", "/usr/local/bin/hermes", compatibleLocalRef, "--version"],
{ ignoreError: true, timeout: 20_000 },
);
expect(dockerCaptureMock).toHaveBeenCalledWith(
[
"run",
"--rm",
"--entrypoint",
"/opt/hermes/.venv/bin/python",
"hermes-base:test",
compatibleLocalRef,
"-c",
expect.stringContaining("_MCP_HTTP_AVAILABLE"),
],
{ ignoreError: true, timeout: 20_000 },
);

dockerCaptureMock.mockReturnValue("");
expect(options.validateImage?.("hermes-base:stale")).toBe(false);
dockerCaptureMock.mockImplementation((args: string[]) =>
args[3] === "/usr/local/bin/hermes" ? "Hermes Agent v0.17.0 (2026.6.19)" : "",
);
const staleLocalRef = "nemoclaw-hermes-sandbox-base-local:stale";
expect(options.validateImage?.(staleLocalRef)).toBe(false);
expect(dockerCaptureMock).not.toHaveBeenCalledWith(
expect.arrayContaining([staleLocalRef, "/opt/hermes/.venv/bin/python"]),
expect.anything(),
);

dockerCaptureMock.mockClear();
dockerCaptureMock.mockImplementation(
(args: string[]) => compatibleOutputByEntrypoint.get(args[3]) ?? "",
);
expect(
options.validateImage?.(
`ghcr.io/nvidia/nemoclaw/hermes-sandbox-base@sha256:${"a".repeat(64)}`,
),
).toBe(true);
expect(dockerCaptureMock).toHaveBeenCalled();

dockerCaptureMock.mockClear();
expect(options.validateImage?.("ghcr.io/nvidia/nemoclaw/hermes-sandbox-base:latest")).toBe(
false,
);
expect(dockerCaptureMock).not.toHaveBeenCalled();
});
});

Expand Down Expand Up @@ -162,22 +198,14 @@ describe("agent base image provisioning", () => {
expect(() => ensureAgentBaseImage(makeAgent())).toThrow(
"Hermes final image does not accept base image ref",
);
expect(resolveSandboxBaseImageMock).toHaveBeenCalledWith(
expect.objectContaining({
localTag: "localhost:5000/custom/hermes:latest",
env: expect.objectContaining({
[envVar]: "localhost:5000/custom/hermes:latest",
NEMOCLAW_SANDBOX_BASE_LOCAL_BUILD: "0",
}),
}),
);
expect(resolveSandboxBaseImageMock).not.toHaveBeenCalled();
});
} finally {
prior === undefined ? delete process.env[envVar] : (process.env[envVar] = prior);
}
});

it("fails closed when no MCP-capable Hermes base image can be resolved", () => {
it("fails closed when no version-matched, MCP-capable Hermes base image can be resolved", () => {
withMockedDocker(
({
ensureAgentBaseImage,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/agent/base-image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe("agent base image provisioning", () => {
forceRefresh: true,
rootDir: root,
validateImage: expect.any(Function),
validationDescription: "the required MCP Streamable HTTP runtime",
validationDescription: "Hermes 0.18.0 with the required MCP Streamable HTTP runtime",
}),
);
expect(dockerImageInspectMock).not.toHaveBeenCalled();
Expand Down Expand Up @@ -123,7 +123,7 @@ describe("agent base image provisioning", () => {
NEMOCLAW_SANDBOX_BASE_LOCAL_BUILD: "0",
}),
validateImage: expect.any(Function),
validationDescription: "the required MCP Streamable HTTP runtime",
validationDescription: "Hermes 0.18.0 with the required MCP Streamable HTTP runtime",
}),
);
expect(dockerImageInspectMock).not.toHaveBeenCalled();
Expand Down
34 changes: 32 additions & 2 deletions src/lib/agent/base-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
dockerRmi,
dockerTag,
} from "../adapters/docker";
import { parseVersionFromText } from "../adapters/openshell/client";
import { ROOT } from "../runner";
import { SANDBOX_BUILD_CONTEXT_PREFIX } from "../sandbox/build-context";
import {
Expand Down Expand Up @@ -157,13 +158,35 @@ export function hermesBaseImageSupportsMcp(imageRef: string): boolean {
return output.trim() === HERMES_MCP_RUNTIME_PROBE_OK;
}

/**
* Require a resolved Hermes base to match the manifest pin as well as the
* optional-runtime contract. A reviewed remote digest can remain valid as an
* image artifact after Dockerfile.base advances, so capability probes alone
* are not enough to keep a stale Hermes runtime out of a new final image.
*/
function hermesBaseImageIsCompatible(imageRef: string, expectedVersion: string | null): boolean {
if (!expectedVersion) return false;
const versionOutput = dockerCapture(
["run", "--rm", "--entrypoint", "/usr/local/bin/hermes", imageRef, "--version"],
{ ignoreError: true, timeout: 20_000 },
);
if (parseVersionFromText(versionOutput, "hermes --version") !== expectedVersion) return false;
return hermesBaseImageSupportsMcp(imageRef);
}

function createAgentBaseImageResolutionOptions(
agent: AgentDefinition,
dockerfilePath: string,
options: EnsureAgentBaseImageOptions,
): ResolveBaseImageOptions {
const imageName = `ghcr.io/nvidia/nemoclaw/${agent.name}-sandbox-base`;
const validateImage = agent.name === "hermes" ? hermesBaseImageSupportsMcp : undefined;
const validateImage =
agent.name === "hermes"
? (imageRef: string) =>
(HERMES_OFFICIAL_BASE_DIGEST_REF.test(imageRef) ||
hermesFinalDockerfileAcceptsBase(agent, imageRef)) &&
hermesBaseImageIsCompatible(imageRef, agent.expectedVersion)
: undefined;
const pinnedRemoteRef = getHermesPinnedRemoteBaseRef(agent) ?? undefined;
return {
imageName,
Expand All @@ -179,7 +202,9 @@ function createAgentBaseImageResolutionOptions(
preferPinnedRemoteRef: agent.name === "hermes" && pinnedRemoteRef !== undefined,
validateImage,
validationDescription:
agent.name === "hermes" ? "the required MCP Streamable HTTP runtime" : undefined,
agent.name === "hermes"
? `Hermes ${agent.expectedVersion ?? "<missing>"} with the required MCP Streamable HTTP runtime`
: undefined,
};
}

Expand Down Expand Up @@ -278,6 +303,11 @@ export function ensureAgentBaseImage(
}

const explicitOverride = process.env[overrideEnvVar]?.trim();
if (explicitOverride && !hermesFinalDockerfileAcceptsBase(agent, explicitOverride)) {
throw new Error(
`Hermes final image does not accept base image ref '${explicitOverride}'; use the tracked official digest or a repository-built local base`,
);
}
const resolved = explicitOverride
? resolveExactImage(explicitOverride)
: resolveSandboxBaseImage(resolutionOptions);
Expand Down
Loading
Loading