Files
openclaw/extensions/codex/src/app-server/local-runtime-attribution.ts
Peter Steinberger 9b560b8a41 fix: limit Codex attribution to local transcripts
Summary:
- Limit canonical OpenAI Codex app-server attribution rewrites to local transcript and trajectory records.
- Keep runtime/tool routing on the selected OpenAI model metadata, including OpenAI API-key backup profiles.
- Fix the current gateway-readiness lint blocker that was red on main.

Verification:
- codex-review branch helper clean with focused Codex app-server tests.
- pnpm lint --threads=8
- pnpm test src/commands/gateway-readiness.test.ts
- GitHub CI run 25960997256 green.

Co-authored-by: Eva (agent) <eva+agent-78055@100yen.org>
2026-05-16 12:45:11 +01:00

40 lines
1.2 KiB
TypeScript

import type { EmbeddedRunAttemptParams } from "openclaw/plugin-sdk/agent-harness-runtime";
const OPENAI_PROVIDER_ID = "openai";
const OPENAI_RESPONSES_API = "openai-responses";
const OPENAI_CODEX_PROVIDER_ID = "openai-codex";
const OPENAI_CODEX_RESPONSES_API = "openai-codex-responses";
export type CodexLocalRuntimeAttribution = {
provider: string;
api?: string;
};
function normalizeRuntimeId(value: string | undefined): string {
return value?.trim().toLowerCase() ?? "";
}
export function resolveCodexLocalRuntimeAttribution(
params: EmbeddedRunAttemptParams,
): CodexLocalRuntimeAttribution {
const authProfileProvider = normalizeRuntimeId(
params.runtimePlan?.auth?.authProfileProviderForAuth,
);
if (
normalizeRuntimeId(params.runtimePlan?.observability.harnessId) === "codex" &&
authProfileProvider !== OPENAI_PROVIDER_ID &&
normalizeRuntimeId(params.model.provider) === OPENAI_PROVIDER_ID &&
normalizeRuntimeId(params.model.api) === OPENAI_RESPONSES_API
) {
return {
provider: OPENAI_CODEX_PROVIDER_ID,
api: OPENAI_CODEX_RESPONSES_API,
};
}
return {
provider: params.provider,
api: params.model.api,
};
}