From 4369c20bfe092cb02076b8590651b15ff62087bb Mon Sep 17 00:00:00 2001 From: stainlu Date: Mon, 27 Apr 2026 10:59:11 +0800 Subject: [PATCH] fix(agents): make originalProvider optional in runAgentAttempt params The required-typed param introduced in 9987e7797f broke attempt-execution.cli.test.ts and auth-profile-runtime-contract.test.ts which construct runAgentAttempt params without an originalProvider field. Make it optional and explicitly require the typeof check before passing to isClaudeCliProvider so a missing field correctly skips the seed (defensive default for fallback paths that didn't plumb the original provider through, no-op for non-fallback paths). --- src/agents/command/attempt-execution.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/agents/command/attempt-execution.ts b/src/agents/command/attempt-execution.ts index 95606895cb5..46e2c5eb9a5 100644 --- a/src/agents/command/attempt-execution.ts +++ b/src/agents/command/attempt-execution.ts @@ -240,9 +240,13 @@ export function runAgentAttempt(params: { * fallback context seeding to chains that actually started on claude-cli; * a stale `cliSessionBindings["claude-cli"]` from an unrelated past run * must not contaminate fallbacks that started on another provider - * (Codex review #72069 P1). + * (Codex review #72069 P1). Optional for callers that don't drive + * a fallback chain (tests, ad-hoc invocations); when omitted, the + * claude-cli fallback seed is skipped — that's a no-op for non-fallback + * paths and a defensive default for fallback paths that didn't plumb + * the original provider through. */ - originalProvider: string; + originalProvider?: string; cfg: OpenClawConfig; sessionEntry: SessionEntry | undefined; sessionId: string; @@ -283,6 +287,7 @@ export function runAgentAttempt(params: { // must not bleed into this fallback chain. const claudeCliFallbackPrelude = params.isFallbackRetry && + typeof params.originalProvider === "string" && isClaudeCliProvider(params.originalProvider) && !isClaudeCliProvider(params.providerOverride) ? buildClaudeCliFallbackContextPrelude({