Skip to content

feat: add error recovery with configurable retries in execute_task - #431

Open
NOLANeight wants to merge 1 commit into
bytedance:mainfrom
NOLANeight:feat/error-recovery
Open

feat: add error recovery with configurable retries in execute_task#431
NOLANeight wants to merge 1 commit into
bytedance:mainfrom
NOLANeight:feat/error-recovery

Conversation

@NOLANeight

Copy link
Copy Markdown

When an unexpected exception occurs during a step, instead of breaking immediately, the agent now formats the error as a user message with recovery hints and gives the LLM up to max_error_retries attempts to try a different approach.

Changes:

  • AgentConfig: add max_error_retries field (default 2)
  • BaseAgent: store _max_error_retries and expose via property
  • execute_task: on exception, inject recovery message and retry instead of breaking; reset counter on successful step
  • _finalize_step: preserve ERROR state instead of overwriting it
  • Add 10 unit tests covering recovery success, exhaustion, counter reset, zero-retries, and message formatting
  • Update trae_config.yaml.example with max_error_retries

Description

More Information

Validation

Linked Issues

When an unexpected exception occurs during a step, instead of breaking
immediately, the agent now formats the error as a user message with
recovery hints and gives the LLM up to max_error_retries attempts to
try a different approach.

Changes:
- AgentConfig: add max_error_retries field (default 2)
- BaseAgent: store _max_error_retries and expose via property
- execute_task: on exception, inject recovery message and retry
  instead of breaking; reset counter on successful step
- _finalize_step: preserve ERROR state instead of overwriting it
- Add 10 unit tests covering recovery success, exhaustion, counter
  reset, zero-retries, and message formatting
- Update trae_config.yaml.example with max_error_retries
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.

1 participant