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).
This commit is contained in:
stainlu
2026-04-27 10:59:11 +08:00
committed by Ayaan Zaidi
parent 0bfcdcf044
commit 4369c20bfe

View File

@@ -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({