Skip to content

Add agentReplanOnError flag to restart planning loop on tool errors - #1

Draft
esolithe with Copilot wants to merge 3 commits into
mainfrom
copilot/add-agent-replan-on-error-flag
Draft

Add agentReplanOnError flag to restart planning loop on tool errors#1
esolithe with Copilot wants to merge 3 commits into
mainfrom
copilot/add-agent-replan-on-error-flag

Conversation

Copilot AI commented Apr 24, 2026

Copy link
Copy Markdown

Adds a configurable agent_replan_on_error flag that changes the agent's recovery behavior when a tool call fails — instead of continuing with the default "explain or call another tool" prompt, it injects a replan-specific system message instructing the AI to try a different strategy.

Changes

  • core/config.py — Added agent_replan_on_error: false to model defaults; picked up automatically by the config sync logic on existing installs
  • core/toolcalls.py — Tracks had_tool_error across the tool execution loop; conditionally switches the follow-up system prompt when the flag is enabled:
    if had_tool_error and replan_on_error:
        system_content = (
            "One or more tool calls returned an error. "
            "Please replan your approach and try a different strategy to achieve the goal."
        )
  • channels/webui/static/js/new_menu_options.js (new) — Defines AGENT_MENU_OPTIONS registry and extends FIELD_DESCRIPTIONS so the flag renders with a description in the settings UI
  • channels/webui.py — Registers new_menu_options in JS_FILES after modal_settings
Original prompt

Start implementation

[Chronological Review: The conversation began with the user requesting an examination of files in the specified directory to identify error cases handled by the "addThought" function. The user then requested the addition of a new flag in the `newMenuOptions.js` file to restart the thinking loop upon encountering errors. The user later pointed out that certain files were missing from the examination, specifically mentioning the utilities, world state, and search web files.]

[Intent Mapping:

  • "Examine the files in #file:agent": The user wants to identify error cases in the "addThought" function.
  • "Look through each of them": The user expects a thorough review of the specified files.
  • "I would like a new flag added to #file:newMenuOptions.js called agentReplanOnError": The user requests a specific modification to the codebase to enhance error handling.
  • "You seem to be missing the utilities, world state and search web": The user indicates that the previous examination did not include all relevant files.]

[Technical Inventory:

  • Files in the agent directory: agent_filesystem.js, agent_groups_loader.js, agent_macros.js, agent_media.js, agent_messaging.js, agent_openlumara.js, agent_openlumarapolling.js, agent_planning_input.js, agent_search_web.js, agent_utilities.js, agent_world_state.js.
  • The user is currently focused on agent_search_web.js and has requested modifications to newMenuOptions.js.]

[Code Archaeology:

  • The user is interested in the "addThought" function, which is likely defined in one of the files in the agent directory.
  • The user has requested the addition of a flag in newMenuOptions.js to control behavior based on error handling.]

[Progress Assessment:

  • The user has not yet received a complete examination of all relevant files.
  • The request for the new flag in newMenuOptions.js is pending implementation.]

[Context Validation: The user’s requests for examining files and adding a new flag are clearly articulated, and the context for continuing work is established.]

[Recent Commands Analysis:

  • Last Agent Commands: The user requested an examination of files in the agent directory and pointed out missing files.
  • Tool Results Summary: No specific tool results were returned as the conversation focused on user requests rather than tool executions.
  • Pre-Summary State: The agent was actively discussing the examination of files and the addition of a new flag when the token budget was exceeded.
  • Operation Context: The commands were executed to align with the user’s goal of improving error handling in the codebase.]
1. Conversation Overview: - Primary Objectives: - "Examine the files in #file:agent" to identify error cases in "addThought". - "I would like a new flag added to #file:newMenuOptions.js called agentReplanOnError" to enhance error handling. - Session Context: The user is focused on improving the error handling mechanism in their codebase, specifically within the agent files. - User Intent Evolution: The user initially sought a review of files but later clarified that certain files were missing from the examination.
  1. Technical Foundation:
  • JavaScript: Used for the implementation of the agent files and the requested modifications.
  • Error Handling Logic: The user is looking to integrate a new flag for better error management.
  1. Codebase Status:
  • File Name: agent_search_web.js
    • Purpose: Part of the agent's functionality related to web searching.
    • Current State: Under examination for error handling.
  • File Name: newMenuOptions.js
    • Purpose: To manage menu options, including the new error handling flag.
    • Current State: Pending modification to include agentReplanOnError.
  1. Problem Resolution:
  • Issues Encountered: The user noted missing files in the previous examination.
  • Solutions Implemented: None yet; the user is still in the process of gathering information.
  • Debugging Context: The user is focused on identifying error cases in the "addThought" function.
  1. Progress Tracking:
  • Completed Tasks: None completed yet; the user is still in the information-gathering phase.
  • Partially Complete Work: Examination of files is ongoing, with specific requests for modifications pending.
  • Validated Outcomes: No features confirmed working yet.
  1. Active Work State:
  • Current Focus: The user is examining agent_search_web.js and preparing to modify newMenuOptions.js.
  • Recent Context: The user has requested a review of files and pointed out missing files.
  • Working Code: The user is focused on the "addThought" function and its error handling.
  • Immediate Context: The user is looking to enhance error handling in the agent's logic.
  1. Recent Operations:
  • Last Agent Commands: User requested examination of files and pointed out missing files.
  • Tool Results Summary: No specific tool results were generated; the focus was on user requests.
  • Pre-Summary State: The agent...

Created from VS Code.

Copilot AI changed the title [WIP] Add agentReplanOnError flag to newMenuOptions.js Add agentReplanOnError flag to restart planning loop on tool errors Apr 24, 2026
Copilot AI requested a review from esolithe April 24, 2026 00:17
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