fix(agents): fallback retry image safety and partial execution detection#1699
Open
BingqingLyu wants to merge 6 commits intomainfrom
Open
fix(agents): fallback retry image safety and partial execution detection#1699BingqingLyu wants to merge 6 commits intomainfrom
BingqingLyu wants to merge 6 commits intomainfrom
Conversation
…n through model fallback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
resolveRetryImages— only strip onformaterrors (model can't handle images) or cross-provider retries (privacy boundary)suppressPromptImageDetectionto the embedded runner sodetectAndLoadPromptImagesis skipped on cross-provider retries — closes the gap where prompt-referenced local images bypassed the image strippreviousFailureReasonandpreviousPartialExecutionthroughModelFallbackRunOptionsso the retry callback knows what the prior attempt did; warn fallback models about already-executed tools to prevent replaying non-idempotent operationsBuilds on openclaw#55632 (prompt preservation for new sessions). Supersedes openclaw#44188. Closes openclaw#43481, openclaw#43492.
Design boundary
All changes stay at the
runAgentAttempt/runWithModelFallbackboundary. The pi-runner internals are not modified beyond accepting thesuppressPromptImageDetectionflag. This is intentional — the runner's internal loops (profile rotation, cooldown skips) are treated as opaque. See openclaw#44188 for the full design discussion.Changes
failover-error.tsPartialExecutiontype withtoolNamesanddidSendViaMessagingToolFailoverErrorcarries optionalpartialExecutionfieldsanitizeToolNamesstatic method (caps at 20 entries, strips non-alphanumeric, truncates to 100 chars)describeFailoverErrorreturnspartialExecutionwhen presentmodel-fallback.tsModelFallbackRunOptionsextended withpreviousFailureReasonandpreviousPartialExecutionrunOptionsfor next candidateattempt-execution.tsresolveRetryImages: failure-mode-aware image handling (format → strip, cross-provider → strip, same-provider non-format → preserve)buildPartialExecutionSystemContext: system prompt warning about already-executed tools (same-provider only, CWE-200)runAgentAttemptextended withprimaryProvider,previousFailureReason,previousPartialExecutionresolveRetryImagesandeffectiveExtraSystemPromptEmbedded runner (
params.ts,run.ts,attempt.ts)suppressPromptImageDetectionparam gatesdetectAndLoadPromptImagesagent-command.tsprimaryProvider,previousFailureReason,previousPartialExecutionfrom fallbackrunOptionsintorunAgentAttemptTest plan
resolveRetryImages— 6 tests: first attempt, format error, rate_limit, cross-provider, undefined provider, undefined imagesbuildPartialExecutionSystemContext— 3 tests: tool listing, messaging warning, empty toolsFailoverError.sanitizeToolNames— 3 tests: cap at 20, truncate to 100, filter emptyFailoverError.partialExecution— 2 tests: carries when provided, undefined when absentdescribeFailoverError— 2 tests: includes/omits partialExecutionrunWithModelFallback— 4 tests: threads previousFailureReason, threads previousPartialExecution, merges across attempts, omits when absentpnpm check— clean (0 warnings, 0 errors)pnpm build— clean (no type errors, no INEFFECTIVE_DYNAMIC_IMPORT)🤖 Generated with Claude Code