Skip to content

Commit c226f54

Browse files
fix(codex): preserve plugin tool auth profiles
1 parent f2c028e commit c226f54

2 files changed

Lines changed: 14 additions & 22 deletions

File tree

src/agents/pi-embedded-runner/run.overflow-compaction.test.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -500,15 +500,9 @@ describe("runEmbeddedPiAgent overflow compaction trigger routing", () => {
500500
toolAuthProfileStore?: unknown;
501501
};
502502
expect(harnessParams?.runtimePlan).toBe(runtimePlan);
503-
expect(harnessParams.authProfileStore).toBe(codexAuthStore);
504503
const forwardedAuthStore = expectRecordFields(harnessParams.authProfileStore, {});
505504
const authProfiles = expectRecordFields(forwardedAuthStore.profiles, {});
506-
expect(Object.keys(authProfiles)).toEqual([
507-
"openai-codex:work",
508-
"openai-codex:other",
509-
"anthropic:work",
510-
"xai:work",
511-
]);
505+
expect(Object.keys(authProfiles)).toEqual(["openai-codex:work"]);
512506
expectRecordFields(authProfiles["openai-codex:work"], {
513507
provider: "openai-codex",
514508
});
@@ -854,11 +848,11 @@ describe("runEmbeddedPiAgent overflow compaction trigger routing", () => {
854848
authProfileStore?: { profiles?: Record<string, unknown> };
855849
toolAuthProfileStore?: unknown;
856850
};
857-
expect(harnessParams.authProfileStore).toBe(codexAuthStore);
858851
const forwardedAuthStore = expectRecordFields(harnessParams.authProfileStore, {});
859852
const authProfiles = expectRecordFields(forwardedAuthStore.profiles, {});
860-
expectRecordFields(authProfiles["xai:work"], {
861-
provider: "xai",
853+
expect(Object.keys(authProfiles)).toEqual(["openai-codex:default"]);
854+
expectRecordFields(authProfiles["openai-codex:default"], {
855+
provider: "openai-codex",
862856
});
863857
expect(harnessParams.toolAuthProfileStore).toBe(codexAuthStore);
864858
});

src/agents/pi-embedded-runner/run.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -973,18 +973,14 @@ export async function runEmbeddedPiAgent(
973973
}
974974
startupStages.mark("auth");
975975
notifyExecutionPhase("auth", { provider, model: modelId });
976-
const codexHarnessOwnsTransport = pluginHarnessOwnsTransport && agentHarness.id === "codex";
977-
// Codex builds OpenClaw tools inside its harness. Keep the full store on
978-
// the existing field so installed Codex packages can resolve tool auth.
979-
const runAttemptAuthProfileStore =
980-
pluginHarnessOwnsTransport && !codexHarnessOwnsTransport
981-
? createScopedAuthProfileStore(
982-
attemptAuthProfileStore,
983-
pluginHarnessForwardedProfileCandidates.length > 0
984-
? pluginHarnessForwardedProfileCandidates
985-
: lastProfileId,
986-
)
987-
: attemptAuthProfileStore;
976+
const runAttemptAuthProfileStore = pluginHarnessOwnsTransport
977+
? createScopedAuthProfileStore(
978+
attemptAuthProfileStore,
979+
pluginHarnessForwardedProfileCandidates.length > 0
980+
? pluginHarnessForwardedProfileCandidates
981+
: lastProfileId,
982+
)
983+
: attemptAuthProfileStore;
988984
const { sessionAgentId } = resolveSessionAgentIds({
989985
sessionKey: params.sessionKey,
990986
config: params.config,
@@ -1448,6 +1444,8 @@ export async function runEmbeddedPiAgent(
14481444
initialReplayState: accumulatedReplayState,
14491445
authStorage,
14501446
authProfileStore: runAttemptAuthProfileStore,
1447+
// Codex builds OpenClaw tools inside its harness. Keep transport
1448+
// auth scoped while letting tool construction see plugin creds.
14511449
toolAuthProfileStore: agentHarness.id === "codex" ? attemptAuthProfileStore : undefined,
14521450
modelRegistry,
14531451
agentId: workspaceResolution.agentId,

0 commit comments

Comments
 (0)