From b0bd00a9efe661c6869b61496ea181c71ac09031 Mon Sep 17 00:00:00 2001 From: Rui Luo Date: Wed, 21 Oct 2026 17:15:32 +0800 Subject: [PATCH 1/4] fix(telemetry): report the attached provider family for native Hermes models Signed-off-by: Rui Luo --- src/lib/actions/telemetry/snapshot.test.ts | 50 ++++++++++++++++++++++ src/lib/domain/telemetry/dimensions.ts | 30 ++++++++++--- 2 files changed, 75 insertions(+), 5 deletions(-) diff --git a/src/lib/actions/telemetry/snapshot.test.ts b/src/lib/actions/telemetry/snapshot.test.ts index 52bf06f2f0d..266e9b67a8c 100644 --- a/src/lib/actions/telemetry/snapshot.test.ts +++ b/src/lib/actions/telemetry/snapshot.test.ts @@ -378,6 +378,56 @@ it.each(nativeModelCases)( }, ); +const hermesNvidiaConfig = + "model:\n default: nvidia/nemotron-3-ultra-550b-a55b\n provider: custom\n base_url: https://integrate.api.nvidia.com/v1\n"; +const nvidiaAttachment = { + schemaVersion: 1, + profileId: "nemoclaw-nvidia-inference-v1", + providerName: "nemoclaw-nvidia-prod-v1", + providerId: "11111111-2222-4333-8444-555555555555", +} as const; + +it.each([ + { + name: "an attached native NVIDIA route", + model: "nvidia/nemotron-3-ultra-550b-a55b", + attachment: nvidiaAttachment, + providerProfile: "nvidia", + }, + { + name: "a native config for another recorded model", + model: "other/model", + attachment: nvidiaAttachment, + providerProfile: "custom", + }, + { + name: "a native config without an attachment", + model: "nvidia/nemotron-3-ultra-550b-a55b", + attachment: undefined, + providerProfile: "custom", + }, +])( + "reports the Hermes custom adapter for $name as $providerProfile (#13577)", + async ({ model, attachment, providerProfile }) => { + const event = await collectNativeConfiguration( + "hermes", + "/sandbox/.hermes/config.yaml", + hermesNvidiaConfig, + { + provider: "nvidia-prod", + model, + ...(attachment ? { nativeNvidiaProviderAttachment: attachment } : {}), + }, + ); + expect(event.parameters.configurations[0].agents[0].models[0]).toMatchObject({ + modelId: "nvidia/nemotron-3-ultra-550b-a55b", + providerProfile, + 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/domain/telemetry/dimensions.ts b/src/lib/domain/telemetry/dimensions.ts index c89b604329e..84fb3ad1fed 100644 --- a/src/lib/domain/telemetry/dimensions.ts +++ b/src/lib/domain/telemetry/dimensions.ts @@ -95,6 +95,9 @@ export interface RuntimeRouteAuthority { modelSelectionProvenance?: unknown; nativeModelSelectionProvenance?: unknown; modelAssignmentSelections?: unknown; + nativeNvidiaProviderAttachment?: unknown; + nativeHostedProviderAttachment?: unknown; + nativeLocalProviderAttachment?: unknown; metadataErrors?: readonly TelemetryMetadataError[]; } @@ -103,9 +106,19 @@ type ModelReference = { providerKey: string; api?: unknown; managed: boolean; + /** A native reference that NemoClaw attached for the recorded provider and model. */ + attached?: boolean; nativeConfiguration?: unknown; }; +function hasNativeProviderAttachment(authority: RuntimeRouteAuthority): boolean { + return [ + authority.nativeNvidiaProviderAttachment, + authority.nativeHostedProviderAttachment, + authority.nativeLocalProviderAttachment, + ].some((receipt) => dataRecord(receipt) !== null); +} + type AssignmentSources = { selections: Map; conflicts: Set; @@ -241,11 +254,12 @@ 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.managed || reference.attached + ? (bound?.providerProfile ?? gatewayProvider ?? classifyTelemetryProvider(authority.provider)) + : reference.providerKey + ? (NATIVE_PROVIDERS[reference.providerKey] ?? "custom") + : "unknown"; const api = classifyTelemetryApi(reference.api); return { assignment, @@ -551,6 +565,12 @@ export function projectRuntimeAgents( 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. + attached: + model.provider === "custom" && + model.default === authority.model && + hasNativeProviderAttachment(authority), }; } else if (runtime.agentHarnessId === "langchain-deepagents-code") { const models = dataRecord(root.models); From f5a8bcab3a5fe57f6bba8d769b90d4e1b50668fa Mon Sep 17 00:00:00 2001 From: Rui Luo Date: Wed, 21 Oct 2026 19:33:44 +0800 Subject: [PATCH 2/4] fix(telemetry): require a valid attachment receipt for the provider Signed-off-by: Rui Luo --- src/lib/actions/telemetry/snapshot.test.ts | 50 ++++++++++++++++------ src/lib/actions/telemetry/snapshot.ts | 16 ++++++- src/lib/domain/telemetry/dimensions.ts | 16 ++----- 3 files changed, 56 insertions(+), 26 deletions(-) diff --git a/src/lib/actions/telemetry/snapshot.test.ts b/src/lib/actions/telemetry/snapshot.test.ts index 266e9b67a8c..f9a94333802 100644 --- a/src/lib/actions/telemetry/snapshot.test.ts +++ b/src/lib/actions/telemetry/snapshot.test.ts @@ -387,37 +387,61 @@ const nvidiaAttachment = { providerId: "11111111-2222-4333-8444-555555555555", } as const; -it.each([ +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; providerProfile: string }>([ { name: "an attached native NVIDIA route", - model: "nvidia/nemotron-3-ultra-550b-a55b", - attachment: nvidiaAttachment, + entry: { ...nvidiaRoute, nativeNvidiaProviderAttachment: nvidiaAttachment }, providerProfile: "nvidia", }, { name: "a native config for another recorded model", - model: "other/model", - attachment: nvidiaAttachment, + entry: { + ...nvidiaRoute, + model: "other/model", + nativeNvidiaProviderAttachment: nvidiaAttachment, + }, providerProfile: "custom", }, { name: "a native config without an attachment", - model: "nvidia/nemotron-3-ultra-550b-a55b", - attachment: undefined, + entry: nvidiaRoute, + providerProfile: "custom", + }, + { + name: "an NVIDIA receipt recorded for another provider", + entry: { + ...nvidiaRoute, + provider: "openai-api", + nativeNvidiaProviderAttachment: nvidiaAttachment, + }, + providerProfile: "custom", + }, + { + name: "an empty NVIDIA receipt", + entry: { ...nvidiaRoute, nativeNvidiaProviderAttachment: forged({}) }, + providerProfile: "custom", + }, + { + name: "an NVIDIA receipt stored as a hosted attachment", + entry: { ...nvidiaRoute, nativeHostedProviderAttachment: forged(nvidiaAttachment) }, + providerProfile: "custom", + }, + { + name: "an unrelated local attachment", + entry: { ...nvidiaRoute, nativeLocalProviderAttachment: forged({ profileId: "unrelated" }) }, providerProfile: "custom", }, ])( "reports the Hermes custom adapter for $name as $providerProfile (#13577)", - async ({ model, attachment, providerProfile }) => { + async ({ entry, providerProfile }) => { const event = await collectNativeConfiguration( "hermes", "/sandbox/.hermes/config.yaml", hermesNvidiaConfig, - { - provider: "nvidia-prod", - model, - ...(attachment ? { nativeNvidiaProviderAttachment: attachment } : {}), - }, + entry, ); expect(event.parameters.configurations[0].agents[0].models[0]).toMatchObject({ modelId: "nvidia/nemotron-3-ultra-550b-a55b", diff --git a/src/lib/actions/telemetry/snapshot.ts b/src/lib/actions/telemetry/snapshot.ts index 38fd99ffaea..21295e099ff 100644 --- a/src/lib/actions/telemetry/snapshot.ts +++ b/src/lib/actions/telemetry/snapshot.ts @@ -27,6 +27,7 @@ import type { ValueStatus, } from "../../domain/telemetry/event"; import { resolveRegisteredAgentDefinition } from "../../agent/runtime"; +import { recordedNativeProviderAttachment } 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 +50,15 @@ import { getMcpProviderInspectionRuntimeSelection } from "../sandbox/mcp-bridge- const MAX_CONCURRENT_RUNTIME_OBSERVATIONS = 4; +/** Recorded provider whose native NVIDIA or hosted attachment receipt is valid for it. */ +function nativeAttachedProvider(entry: SandboxEntry): string | undefined { + try { + return recordedNativeProviderAttachment(entry) && entry.provider ? entry.provider : undefined; + } catch { + return undefined; + } +} + function booleanSetting(value: unknown): { value: "true" | "false" | "unknown"; status: ValueStatus; @@ -325,7 +335,11 @@ async function collectRuntime( runtime, raw.status === "fulfilled" ? raw.value : null, roster.status === "fulfilled" ? roster.value : undefined, - { ...entry, metadataErrors: options.metadataErrors }, + { + ...entry, + nativeAttachedProvider: nativeAttachedProvider(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 84fb3ad1fed..11e00a82ba9 100644 --- a/src/lib/domain/telemetry/dimensions.ts +++ b/src/lib/domain/telemetry/dimensions.ts @@ -95,9 +95,8 @@ export interface RuntimeRouteAuthority { modelSelectionProvenance?: unknown; nativeModelSelectionProvenance?: unknown; modelAssignmentSelections?: unknown; - nativeNvidiaProviderAttachment?: unknown; - nativeHostedProviderAttachment?: unknown; - nativeLocalProviderAttachment?: unknown; + /** Logical provider of the validated native attachment receipt, if one is recorded. */ + nativeAttachedProvider?: string; metadataErrors?: readonly TelemetryMetadataError[]; } @@ -111,14 +110,6 @@ type ModelReference = { nativeConfiguration?: unknown; }; -function hasNativeProviderAttachment(authority: RuntimeRouteAuthority): boolean { - return [ - authority.nativeNvidiaProviderAttachment, - authority.nativeHostedProviderAttachment, - authority.nativeLocalProviderAttachment, - ].some((receipt) => dataRecord(receipt) !== null); -} - type AssignmentSources = { selections: Map; conflicts: Set; @@ -570,7 +561,8 @@ export function projectRuntimeAgents( attached: model.provider === "custom" && model.default === authority.model && - hasNativeProviderAttachment(authority), + typeof authority.provider === "string" && + authority.nativeAttachedProvider === authority.provider, }; } else if (runtime.agentHarnessId === "langchain-deepagents-code") { const models = dataRecord(root.models); From 84dcf93d97e94516e118bb2e0bfdecfd670ef2f9 Mon Sep 17 00:00:00 2001 From: Rui Luo Date: Wed, 21 Oct 2026 20:11:07 +0800 Subject: [PATCH 3/4] fix(telemetry): match the Hermes endpoint to the attached route Signed-off-by: Rui Luo --- src/lib/actions/telemetry/snapshot.test.ts | 37 ++++++++++++++++--- src/lib/actions/telemetry/snapshot.ts | 13 ++++--- src/lib/domain/telemetry/dimensions.ts | 9 +++-- .../native-provider/recorded-selection.ts | 16 +++++++- 4 files changed, 61 insertions(+), 14 deletions(-) diff --git a/src/lib/actions/telemetry/snapshot.test.ts b/src/lib/actions/telemetry/snapshot.test.ts index f9a94333802..ba04bc03942 100644 --- a/src/lib/actions/telemetry/snapshot.test.ts +++ b/src/lib/actions/telemetry/snapshot.test.ts @@ -378,24 +378,51 @@ it.each(nativeModelCases)( }, ); -const hermesNvidiaConfig = - "model:\n default: nvidia/nemotron-3-ultra-550b-a55b\n provider: custom\n base_url: https://integrate.api.nvidia.com/v1\n"; +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; providerProfile: string }>([ +it.each<{ + name: string; + entry: Partial; + baseUrl?: string; + providerProfile: 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: { @@ -436,11 +463,11 @@ it.each<{ name: string; entry: Partial; providerProfile: string }> }, ])( "reports the Hermes custom adapter for $name as $providerProfile (#13577)", - async ({ entry, providerProfile }) => { + async ({ entry, baseUrl, providerProfile }) => { const event = await collectNativeConfiguration( "hermes", "/sandbox/.hermes/config.yaml", - hermesNvidiaConfig, + hermesConfig(baseUrl ?? "https://integrate.api.nvidia.com/v1"), entry, ); expect(event.parameters.configurations[0].agents[0].models[0]).toMatchObject({ diff --git a/src/lib/actions/telemetry/snapshot.ts b/src/lib/actions/telemetry/snapshot.ts index 21295e099ff..4df1bc28577 100644 --- a/src/lib/actions/telemetry/snapshot.ts +++ b/src/lib/actions/telemetry/snapshot.ts @@ -27,7 +27,7 @@ import type { ValueStatus, } from "../../domain/telemetry/event"; import { resolveRegisteredAgentDefinition } from "../../agent/runtime"; -import { recordedNativeProviderAttachment } from "../../inference/native-provider/recorded-selection"; +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"; @@ -50,10 +50,13 @@ import { getMcpProviderInspectionRuntimeSelection } from "../sandbox/mcp-bridge- const MAX_CONCURRENT_RUNTIME_OBSERVATIONS = 4; -/** Recorded provider whose native NVIDIA or hosted attachment receipt is valid for it. */ -function nativeAttachedProvider(entry: SandboxEntry): string | undefined { +/** Recorded provider and endpoint proved by a valid native NVIDIA or hosted attachment. */ +function nativeAttachedRoute( + entry: SandboxEntry, +): { provider: string; endpoint: string } | undefined { try { - return recordedNativeProviderAttachment(entry) && entry.provider ? entry.provider : undefined; + const endpoint = recordedNativeProviderEndpoint(entry); + return endpoint && entry.provider ? { provider: entry.provider, endpoint } : undefined; } catch { return undefined; } @@ -337,7 +340,7 @@ async function collectRuntime( roster.status === "fulfilled" ? roster.value : undefined, { ...entry, - nativeAttachedProvider: nativeAttachedProvider(entry), + nativeAttachedRoute: nativeAttachedRoute(entry), metadataErrors: options.metadataErrors, }, ), diff --git a/src/lib/domain/telemetry/dimensions.ts b/src/lib/domain/telemetry/dimensions.ts index 11e00a82ba9..e5b234091f7 100644 --- a/src/lib/domain/telemetry/dimensions.ts +++ b/src/lib/domain/telemetry/dimensions.ts @@ -95,8 +95,8 @@ export interface RuntimeRouteAuthority { modelSelectionProvenance?: unknown; nativeModelSelectionProvenance?: unknown; modelAssignmentSelections?: unknown; - /** Logical provider of the validated native attachment receipt, if one is recorded. */ - nativeAttachedProvider?: string; + /** Provider and endpoint proved by a validated native attachment receipt. */ + nativeAttachedRoute?: { provider: string; endpoint: string }; metadataErrors?: readonly TelemetryMetadataError[]; } @@ -561,8 +561,11 @@ export function projectRuntimeAgents( attached: model.provider === "custom" && model.default === authority.model && + typeof model.base_url === "string" && typeof authority.provider === "string" && - authority.nativeAttachedProvider === authority.provider, + authority.nativeAttachedRoute?.provider === authority.provider && + model.base_url.replace(/\/+$/, "") === + authority.nativeAttachedRoute.endpoint.replace(/\/+$/, ""), }; } 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; +} From ea26f2f536e9f98888584ebff0d6f6d0ae913ba4 Mon Sep 17 00:00:00 2001 From: Rui Luo Date: Wed, 21 Oct 2026 21:05:35 +0800 Subject: [PATCH 4/4] fix(telemetry): report invalid native attachment receipts as collection errors Signed-off-by: Rui Luo --- src/lib/actions/telemetry/snapshot.test.ts | 31 ++++++++++++++++++---- src/lib/actions/telemetry/snapshot.ts | 23 +++++++++++----- src/lib/domain/telemetry/dimensions.ts | 26 +++++++++++------- 3 files changed, 59 insertions(+), 21 deletions(-) diff --git a/src/lib/actions/telemetry/snapshot.test.ts b/src/lib/actions/telemetry/snapshot.test.ts index ba04bc03942..f62e642c644 100644 --- a/src/lib/actions/telemetry/snapshot.test.ts +++ b/src/lib/actions/telemetry/snapshot.test.ts @@ -401,6 +401,7 @@ it.each<{ entry: Partial; baseUrl?: string; providerProfile: string; + providerStatus?: string; }>([ { name: "an attached native NVIDIA route", @@ -444,26 +445,46 @@ it.each<{ provider: "openai-api", nativeNvidiaProviderAttachment: nvidiaAttachment, }, - providerProfile: "custom", + providerProfile: "unknown", + providerStatus: "collection_error", }, { name: "an empty NVIDIA receipt", entry: { ...nvidiaRoute, nativeNvidiaProviderAttachment: forged({}) }, - providerProfile: "custom", + providerProfile: "unknown", + providerStatus: "collection_error", }, { name: "an NVIDIA receipt stored as a hosted attachment", entry: { ...nvidiaRoute, nativeHostedProviderAttachment: forged(nvidiaAttachment) }, - providerProfile: "custom", + 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 }) => { + async ({ entry, baseUrl, providerProfile, providerStatus }) => { const event = await collectNativeConfiguration( "hermes", "/sandbox/.hermes/config.yaml", @@ -473,7 +494,7 @@ it.each<{ expect(event.parameters.configurations[0].agents[0].models[0]).toMatchObject({ modelId: "nvidia/nemotron-3-ultra-550b-a55b", providerProfile, - providerStatus: "reported", + providerStatus: providerStatus ?? "reported", }); expect(isOperationEvent(event)).toBe(true); }, diff --git a/src/lib/actions/telemetry/snapshot.ts b/src/lib/actions/telemetry/snapshot.ts index 4df1bc28577..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 { @@ -50,15 +51,23 @@ import { getMcpProviderInspectionRuntimeSelection } from "../sandbox/mcp-bridge- const MAX_CONCURRENT_RUNTIME_OBSERVATIONS = 4; -/** Recorded provider and endpoint proved by a valid native NVIDIA or hosted attachment. */ -function nativeAttachedRoute( - entry: SandboxEntry, -): { provider: string; endpoint: string } | undefined { +/** + * 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 endpoint && entry.provider ? { provider: entry.provider, endpoint } : undefined; + return { + nativeAttachedRoute: + endpoint && entry.provider ? { provider: entry.provider, endpoint } : undefined, + nativeAttachmentInvalid: false, + }; } catch { - return undefined; + return { nativeAttachedRoute: undefined, nativeAttachmentInvalid: true }; } } @@ -340,7 +349,7 @@ async function collectRuntime( roster.status === "fulfilled" ? roster.value : undefined, { ...entry, - nativeAttachedRoute: nativeAttachedRoute(entry), + ...nativeAttachmentEvidence(entry), metadataErrors: options.metadataErrors, }, ), diff --git a/src/lib/domain/telemetry/dimensions.ts b/src/lib/domain/telemetry/dimensions.ts index e5b234091f7..58a9c4c64a0 100644 --- a/src/lib/domain/telemetry/dimensions.ts +++ b/src/lib/domain/telemetry/dimensions.ts @@ -96,7 +96,9 @@ export interface RuntimeRouteAuthority { nativeModelSelectionProvenance?: unknown; modelAssignmentSelections?: unknown; /** Provider and endpoint proved by a validated native attachment receipt. */ - nativeAttachedRoute?: { provider: string; endpoint: string }; + nativeAttachedRoute?: { provider: string; endpoint: string } | undefined; + /** A recorded native attachment receipt failed validation. */ + nativeAttachmentInvalid?: boolean; metadataErrors?: readonly TelemetryMetadataError[]; } @@ -107,6 +109,8 @@ type ModelReference = { 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; }; @@ -245,8 +249,9 @@ function projectModel( gatewayReceipt.provider === authority.provider ? gatewayReceipt.providerProfile : undefined; - const provider = - reference.managed || reference.attached + const provider = reference.attachmentInvalid + ? "unknown" + : reference.managed || reference.attached ? (bound?.providerProfile ?? gatewayProvider ?? classifyTelemetryProvider(authority.provider)) : reference.providerKey ? (NATIVE_PROVIDERS[reference.providerKey] ?? "custom") @@ -543,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 : "", @@ -553,19 +564,16 @@ export function projectRuntimeAgents( : typeof model.api_mode === "string" ? (modes[model.api_mode] ?? model.api_mode) : model.api_mode, - 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. + managed, attached: - model.provider === "custom" && + nativeCustom && model.default === authority.model && typeof model.base_url === "string" && 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);