Skip to content

Conversation

@yuyutaotao
Copy link
Collaborator

Summary

Added error handling for planning response parse errors to allow the task executor to retry planning instead of terminating the entire execution loop. This improves robustness when the AI model returns malformed responses.

Key Changes

  • Wrapped the session.appendAndRun() call in a try-catch block to handle planning-phase errors
  • Added specific handling for AIResponseParseError exceptions that occur during planning response parsing
  • When a parse error occurs, the executor now:
    • Records the error in conversation history as pending feedback
    • Increments the error counter for the current planning loop
    • Triggers a replan attempt instead of failing the entire task
    • Respects maxErrorCountAllowedInOnePlanningLoop to prevent infinite retry loops
    • Respects replanningCycleLimit to prevent excessive replanning cycles
  • Non-parse errors are re-thrown to maintain existing error handling behavior

Implementation Details

  • Parse errors are distinguished from other errors by checking if the error is an instance of AIResponseParseError
  • The error counter and replan count are used to enforce limits and prevent infinite loops
  • Error messages are logged for debugging purposes
  • When limits are exceeded, an appendErrorPlan() is called with a descriptive error message
  • The retry logic uses continue to restart the planning loop, allowing the executor to attempt planning again with the same context

https://claude.ai/code/session_01PPMv2PKGKTzkbW9HscXN51

@yuyutaotao yuyutaotao force-pushed the claude/fix-planning-error-handling-84Lyx branch from b0e1049 to 3cf5633 Compare February 11, 2026 10:42
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 11, 2026

Deploying midscene with  Cloudflare Pages  Cloudflare Pages

Latest commit: e7c1c84
Status: ✅  Deploy successful!
Preview URL: https://331998e1.midscene.pages.dev
Branch Preview URL: https://claude-fix-planning-error-ha.midscene.pages.dev

View logs

@yuyutaotao yuyutaotao force-pushed the claude/fix-planning-error-handling-84Lyx branch from 3cf5633 to 3702a9c Compare February 11, 2026 10:46
…hrowing

When the planning AI response fails to parse (AIResponseParseError),
the error is now caught at the planning loop level and treated like
action execution errors - incrementing the error counter, setting a
feedback message, and continuing to the next planning round. This
prevents a single malformed AI response from terminating the entire
planning loop.

https://claude.ai/code/session_01PPMv2PKGKTzkbW9HscXN51
@yuyutaotao yuyutaotao force-pushed the claude/fix-planning-error-handling-84Lyx branch from 3702a9c to 4074593 Compare February 11, 2026 10:52
When the page is still loading (spinner, skeleton screen, progress bar,
etc.), the planner now must use a Sleep action (1000ms) to wait for the
page to finish loading before continuing with subsequent actions or
assertions. If loading persists after 5 consecutive waits, the task is
considered failed.

https://claude.ai/code/session_013R6UiSRRXHpMaLUccdvxF7

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants