diff --git a/packages/paperclip-runner/src/issue-thread/issue-thread.test.ts b/packages/paperclip-runner/src/issue-thread/issue-thread.test.ts index 85cea2d767b..401ea3c0d0d 100644 --- a/packages/paperclip-runner/src/issue-thread/issue-thread.test.ts +++ b/packages/paperclip-runner/src/issue-thread/issue-thread.test.ts @@ -500,6 +500,11 @@ describe("Capability live projection", () => { .map((item) => item.body); expect(bodies.some((body) => body.includes("semantic-interaction-result"))).toBe(false); }); + it.each([["cursor", "Cursor"], ["copilot", "GitHub Copilot"], ["pi", "Pi"]] as const)("labels the %s provider truthfully", async (agent, label) => { + const snapshot = await liveSnapshot(); + snapshot.config = { ...snapshot.config, provider: "acpx", driver: "acpx_runtime", acpxAgent: agent }; + expect(projectCapabilityIssueThread({ snapshot }).identity.agentLabel).toBe(`Real ${label} via ACPX`); + }); it("separates exposed agent tools from withheld control-plane operations", async () => { const view = projectCapabilityIssueThread({ snapshot: await liveSnapshot() }); diff --git a/packages/paperclip-runner/src/issue-thread/live-projection.ts b/packages/paperclip-runner/src/issue-thread/live-projection.ts index 06f5ceab78e..bcf606d18c4 100644 --- a/packages/paperclip-runner/src/issue-thread/live-projection.ts +++ b/packages/paperclip-runner/src/issue-thread/live-projection.ts @@ -8,6 +8,7 @@ * change already exists in the input. */ +import { ACPX_CAPABILITY_PROFILES } from "../drivers/acpx/capability-profiles.js"; import type { CapabilityFixtureInteraction, CapabilityFixtureState, @@ -761,7 +762,7 @@ export function projectCapabilityIssueThread( : snapshot.config.provider === "opencode" || snapshot.config.driver === "opencode_server" ? "Real OpenCode" : snapshot.config.provider === "acpx" || snapshot.config.driver === "acpx_runtime" - ? `Real ${snapshot.config.acpxAgent === "claude" ? "Claude" : snapshot.config.acpxAgent === "codex" ? "Codex" : "Pi"} via ACPX` + ? `Real ${ACPX_CAPABILITY_PROFILES[snapshot.config.acpxAgent ?? "pi"].displayName} via ACPX` : "Real Codex" : mode === "replay" ? "Replay" : "Fake agent"; const connection = input.connection ?? { state: "connected", attempt: 0 }; diff --git a/server/src/services/native-runtime/native-session-executor.test.ts b/server/src/services/native-runtime/native-session-executor.test.ts index 9ca2b570efd..8d2988eabb3 100644 --- a/server/src/services/native-runtime/native-session-executor.test.ts +++ b/server/src/services/native-runtime/native-session-executor.test.ts @@ -285,6 +285,7 @@ import { buildRemoteCodexLauncherCommand, mayUsePreinstalledRunnerArtifact, nativeUsageCostUsd, + nativeUsageBiller, normalizeNativeUsage, parseRemoteRunnerProcessIdentity, REMOTE_RUNNER_CHILD_LAUNCH_SCRIPT, @@ -959,6 +960,13 @@ describe("native incomplete-bootstrap evidence", () => { }); describe("native provider usage normalization", () => { + it.each([["cursor", "cursor"], ["copilot", "github"], ["pi", "openrouter"]] as const)("keeps %s cost unknown and attributes its actual biller", (agent, biller) => { + const provider = { kind: "acpx", agent, model: "exact-model" } as NativeExecutionInput["provider"]; + expect(nativeUsageBiller(provider)).toBe(biller); + const usage = { runDelta: { inputTokens: 100, outputTokens: 12, providerCostUsd: 0 }, cumulative: { providerCostUsd: 0.44 } }; + expect(nativeUsageCostUsd(usage, provider)).toBeUndefined(); + expect(normalizeNativeUsage(usage)).toMatchObject({ inputTokens: 100, outputTokens: 12 }); + }); it("reads remote runner run-delta tokens and provider cost", () => { const usage = { total: { diff --git a/server/src/services/native-runtime/native-session-executor.ts b/server/src/services/native-runtime/native-session-executor.ts index 4e512e6be42..5be5dffb351 100644 --- a/server/src/services/native-runtime/native-session-executor.ts +++ b/server/src/services/native-runtime/native-session-executor.ts @@ -9028,10 +9028,10 @@ async function executePaperclipNativeSessionWithinScope( summary: native.result.summary, sessionId: native.normalizedSessionId, sessionDisplayId: native.providerSessionId ?? native.normalizedSessionId, - provider: "openai", + provider: nativeUsageBiller(input.execution.provider), model: input.execution.provider.model, usage: normalizeNativeUsage(native.usage), - costUsd: nativeUsageCostUsd(native.usage), + costUsd: nativeUsageCostUsd(native.usage, input.execution.provider), usageBasis: "per_run", nativeFinalization: finalization, }; @@ -9087,7 +9087,23 @@ function nativeUsageMeasurement(usage: Record) { ); } -export function nativeUsageCostUsd(usage: Record | null) { +export function nativeUsageBiller(provider: NativeExecutionInput["provider"]): string { + if (provider.kind === "acpx") { + if (provider.agent === "cursor") return "cursor"; + if (provider.agent === "copilot") return "github"; + if (provider.agent === "pi") return "openrouter"; + } + return "openai"; +} + +export function nativeUsageCostUsd( + usage: Record | null, + provider?: NativeExecutionInput["provider"], +) { + // The ACP normalization contract fills absent per-turn cost with zero and + // reports actual cost cumulatively. Until it carries an authoritative run + // delta with provenance, neither value is a candidate's billed USD receipt. + if (provider?.kind === "acpx" && ["cursor", "copilot", "pi"].includes(provider.agent)) return undefined; if (!usage) return undefined; const measurement = nativeUsageMeasurement(usage); const direct =