diff --git a/src/lib/actions/telemetry/snapshot.test.ts b/src/lib/actions/telemetry/snapshot.test.ts index 52bf06f2f0d..f62e642c644 100644 --- a/src/lib/actions/telemetry/snapshot.test.ts +++ b/src/lib/actions/telemetry/snapshot.test.ts @@ -378,6 +378,128 @@ it.each(nativeModelCases)( }, ); +const hermesConfig = (baseUrl: string) => + `model:\n default: nvidia/nemotron-3-ultra-550b-a55b\n provider: custom\n base_url: ${baseUrl}\n`; +const nvidiaAttachment = { + schemaVersion: 1, + profileId: "nemoclaw-nvidia-inference-v1", + providerName: "nemoclaw-nvidia-prod-v1", + providerId: "11111111-2222-4333-8444-555555555555", +} as const; +const openaiAttachment = { + schemaVersion: 1, + profileId: "nemoclaw-openai-inference-v1", + providerName: "nemoclaw-openai-api-v1", + providerId: "66666666-7777-4888-9999-000000000000", +} as const; + +const nvidiaRoute = { provider: "nvidia-prod", model: "nvidia/nemotron-3-ultra-550b-a55b" }; +const forged = (value: unknown) => value as T; + +it.each<{ + name: string; + entry: Partial; + baseUrl?: string; + providerProfile: string; + providerStatus?: string; +}>([ + { + name: "an attached native NVIDIA route", + entry: { ...nvidiaRoute, nativeNvidiaProviderAttachment: nvidiaAttachment }, + providerProfile: "nvidia", + }, + { + name: "an attached native OpenAI route", + entry: { + ...nvidiaRoute, + provider: "openai-api", + nativeHostedProviderAttachment: openaiAttachment, + }, + baseUrl: "https://api.openai.com/v1", + providerProfile: "openai", + }, + { + name: "a valid NVIDIA receipt with another Hermes endpoint", + entry: { ...nvidiaRoute, nativeNvidiaProviderAttachment: nvidiaAttachment }, + baseUrl: "https://api.openai.com/v1", + providerProfile: "custom", + }, + { + name: "a native config for another recorded model", + entry: { + ...nvidiaRoute, + model: "other/model", + nativeNvidiaProviderAttachment: nvidiaAttachment, + }, + providerProfile: "custom", + }, + { + name: "a native config without an attachment", + entry: nvidiaRoute, + providerProfile: "custom", + }, + { + name: "an NVIDIA receipt recorded for another provider", + entry: { + ...nvidiaRoute, + provider: "openai-api", + nativeNvidiaProviderAttachment: nvidiaAttachment, + }, + providerProfile: "unknown", + providerStatus: "collection_error", + }, + { + name: "an empty NVIDIA receipt", + entry: { ...nvidiaRoute, nativeNvidiaProviderAttachment: forged({}) }, + providerProfile: "unknown", + providerStatus: "collection_error", + }, + { + name: "an NVIDIA receipt stored as a hosted attachment", + entry: { ...nvidiaRoute, nativeHostedProviderAttachment: forged(nvidiaAttachment) }, + providerProfile: "unknown", + providerStatus: "collection_error", + }, + { + name: "an unrelated local attachment", + entry: { ...nvidiaRoute, nativeLocalProviderAttachment: forged({ profileId: "unrelated" }) }, + providerProfile: "custom", + }, + { + name: "a shared-route config with an invalid NVIDIA receipt", + entry: { ...nvidiaRoute, nativeNvidiaProviderAttachment: forged({}) }, + baseUrl: "https://inference.local/v1", + providerProfile: "nvidia", + }, + { + name: "a registry entry that carries its own attached route", + entry: forged({ + ...nvidiaRoute, + nativeAttachedRoute: { + provider: "nvidia-prod", + endpoint: "https://integrate.api.nvidia.com/v1", + }, + }), + providerProfile: "custom", + }, +])( + "reports the Hermes custom adapter for $name as $providerProfile (#13577)", + async ({ entry, baseUrl, providerProfile, providerStatus }) => { + const event = await collectNativeConfiguration( + "hermes", + "/sandbox/.hermes/config.yaml", + hermesConfig(baseUrl ?? "https://integrate.api.nvidia.com/v1"), + entry, + ); + expect(event.parameters.configurations[0].agents[0].models[0]).toMatchObject({ + modelId: "nvidia/nemotron-3-ultra-550b-a55b", + providerProfile, + providerStatus: providerStatus ?? "reported", + }); + expect(isOperationEvent(event)).toBe(true); + }, +); + it.each(nativeModelCases)( "marks a malformed $agent native model as a collection error (#12859)", async ({ agent, configPath, invalidConfig }) => { diff --git a/src/lib/actions/telemetry/snapshot.ts b/src/lib/actions/telemetry/snapshot.ts index 38fd99ffaea..d5a4b5c1c15 100644 --- a/src/lib/actions/telemetry/snapshot.ts +++ b/src/lib/actions/telemetry/snapshot.ts @@ -15,6 +15,7 @@ import { parseRuntimeRoster, projectRuntimeAgents, projectCurrentInferenceRoute, + type RuntimeRouteAuthority, unknownModel, } from "../../domain/telemetry/dimensions"; import type { @@ -27,6 +28,7 @@ import type { ValueStatus, } from "../../domain/telemetry/event"; import { resolveRegisteredAgentDefinition } from "../../agent/runtime"; +import { recordedNativeProviderEndpoint } from "../../inference/native-provider/recorded-selection"; import { readAppliedPolicySelection } from "../../domain/telemetry/provenance"; import { DCODE_OBSERVABILITY_FEATURE } from "../../onboard/observability-policy-presets"; import { readManagedWorkloadAuthority } from "../../onboard/workload/authority"; @@ -49,6 +51,26 @@ import { getMcpProviderInspectionRuntimeSelection } from "../sandbox/mcp-bridge- const MAX_CONCURRENT_RUNTIME_OBSERVATIONS = 4; +/** + * Route proved by a valid native NVIDIA or hosted attachment, or an invalid-receipt marker. + * Both keys are always set so registry fields with the same names cannot reach telemetry. + */ +function nativeAttachmentEvidence(entry: SandboxEntry): { + nativeAttachedRoute: RuntimeRouteAuthority["nativeAttachedRoute"]; + nativeAttachmentInvalid: boolean; +} { + try { + const endpoint = recordedNativeProviderEndpoint(entry); + return { + nativeAttachedRoute: + endpoint && entry.provider ? { provider: entry.provider, endpoint } : undefined, + nativeAttachmentInvalid: false, + }; + } catch { + return { nativeAttachedRoute: undefined, nativeAttachmentInvalid: true }; + } +} + function booleanSetting(value: unknown): { value: "true" | "false" | "unknown"; status: ValueStatus; @@ -325,7 +347,11 @@ async function collectRuntime( runtime, raw.status === "fulfilled" ? raw.value : null, roster.status === "fulfilled" ? roster.value : undefined, - { ...entry, metadataErrors: options.metadataErrors }, + { + ...entry, + ...nativeAttachmentEvidence(entry), + metadataErrors: options.metadataErrors, + }, ), ); if (raw.status === "rejected" || roster.status === "rejected") row.status = "collection_error"; diff --git a/src/lib/domain/telemetry/dimensions.ts b/src/lib/domain/telemetry/dimensions.ts index c89b604329e..58a9c4c64a0 100644 --- a/src/lib/domain/telemetry/dimensions.ts +++ b/src/lib/domain/telemetry/dimensions.ts @@ -95,6 +95,10 @@ export interface RuntimeRouteAuthority { modelSelectionProvenance?: unknown; nativeModelSelectionProvenance?: unknown; modelAssignmentSelections?: unknown; + /** Provider and endpoint proved by a validated native attachment receipt. */ + nativeAttachedRoute?: { provider: string; endpoint: string } | undefined; + /** A recorded native attachment receipt failed validation. */ + nativeAttachmentInvalid?: boolean; metadataErrors?: readonly TelemetryMetadataError[]; } @@ -103,6 +107,10 @@ type ModelReference = { providerKey: string; api?: unknown; managed: boolean; + /** A native reference that NemoClaw attached for the recorded provider and model. */ + attached?: boolean; + /** The provider cannot be classified because the recorded attachment is invalid. */ + attachmentInvalid?: boolean; nativeConfiguration?: unknown; }; @@ -241,11 +249,13 @@ function projectModel( gatewayReceipt.provider === authority.provider ? gatewayReceipt.providerProfile : undefined; - const provider = reference.managed - ? (bound?.providerProfile ?? gatewayProvider ?? classifyTelemetryProvider(authority.provider)) - : reference.providerKey - ? (NATIVE_PROVIDERS[reference.providerKey] ?? "custom") - : "unknown"; + const provider = reference.attachmentInvalid + ? "unknown" + : reference.managed || reference.attached + ? (bound?.providerProfile ?? gatewayProvider ?? classifyTelemetryProvider(authority.provider)) + : reference.providerKey + ? (NATIVE_PROVIDERS[reference.providerKey] ?? "custom") + : "unknown"; const api = classifyTelemetryApi(reference.api); return { assignment, @@ -538,6 +548,12 @@ export function projectRuntimeAgents( anthropic_messages: "anthropic-messages", codex_responses: "openai-responses", }; + const managed = + typeof model.base_url === "string" && + /^https:\/\/inference\.local(?:\/v1)?\/?$/.test(model.base_url); + // NemoClaw writes every Hermes route with the `custom` adapter, so the + // adapter name does not identify the selected provider. + const nativeCustom = !managed && model.provider === "custom"; reference = { model: model.default, providerKey: typeof model.provider === "string" ? model.provider : "", @@ -548,9 +564,16 @@ export function projectRuntimeAgents( : typeof model.api_mode === "string" ? (modes[model.api_mode] ?? model.api_mode) : model.api_mode, - managed: + managed, + attached: + nativeCustom && + model.default === authority.model && typeof model.base_url === "string" && - /^https:\/\/inference\.local(?:\/v1)?\/?$/.test(model.base_url), + typeof authority.provider === "string" && + authority.nativeAttachedRoute?.provider === authority.provider && + model.base_url.replace(/\/+$/, "") === + authority.nativeAttachedRoute.endpoint.replace(/\/+$/, ""), + attachmentInvalid: nativeCustom && authority.nativeAttachmentInvalid === true, }; } else if (runtime.agentHarnessId === "langchain-deepagents-code") { const models = dataRecord(root.models); diff --git a/src/lib/inference/native-provider/recorded-selection.ts b/src/lib/inference/native-provider/recorded-selection.ts index d5c48e9d5d9..0262b299ddd 100644 --- a/src/lib/inference/native-provider/recorded-selection.ts +++ b/src/lib/inference/native-provider/recorded-selection.ts @@ -3,9 +3,13 @@ import { NVIDIA_HOSTED_LOGICAL_PROVIDER, + NVIDIA_HOSTED_NATIVE_ENDPOINT, normalizeNativeNvidiaProviderAttachment, } from "../native-nvidia/contract"; -import { requireHostedProviderAttachment } from "./hosted-attachment"; +import { + hostedNativeProviderForAttachment, + requireHostedProviderAttachment, +} from "./hosted-attachment"; import { normalizeProviderBaseUrl } from "../../core/provider-endpoint"; import type { NativeProviderAttachment } from "./contract"; @@ -52,3 +56,13 @@ export function recordedNativeProviderAttachment(selection: { } return hosted; } + +/** Endpoint of the recorded native NVIDIA or hosted attachment; throws like the attachment check. */ +export function recordedNativeProviderEndpoint( + selection: Parameters[0], +): string | undefined { + if (!recordedNativeProviderAttachment(selection)) return undefined; + return selection.nativeNvidiaProviderAttachment !== undefined + ? NVIDIA_HOSTED_NATIVE_ENDPOINT + : hostedNativeProviderForAttachment(selection.nativeHostedProviderAttachment)?.endpoint; +}