Skip to content

Add a Reflexion loop: learn from failures that repeat - #486

Closed
HugoXK wants to merge 1 commit into
ThinkFlowLab:mainfrom
HugoXK:feat/reflexion
Closed

HugoXK wants to merge 1 commit into
ThinkFlowLab:mainfrom
HugoXK:feat/reflexion

Conversation

@HugoXK

@HugoXK HugoXK commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Add a Reflexion loop: learn from failures that repeat

Fixes #485

When a tool call keeps erroring, or a model call fails several times in a row, the Bot now writes itself one short actionable note into its own memory, so its next conversations avoid the loop. The note goes through the ordinary memory path (size-capped, secret-scanned, visible in the memory panel, removable with forget), at most once per failure per day, and never throws into the turn. config.reflexion: false turns it off.

Ran at the tip: npm run verify (green, TZ=UTC), node scripts/ds-bot-patches.mjs check. Not run: smoke, Desktop, real-model steward.

A tool call that keeps erroring, or a model call that fails several
times in a row, now leaves a short actionable note in the failing Bot's
own memory, so its next conversations avoid the loop. The note goes
through the ordinary memory path (size-capped, secret-scanned, visible
in the panel, removable with forget) at most once per failure per day.
config.reflexion: false turns it off.
@Birfy Birfy added enhancement New feature or request area:automation Scheduled tasks and automation labels Oct 20, 2026
@Birfy

Birfy commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

Review (Birfy, 2026-10-20 12:00 Asia/Shanghai) at 7a44734, risk tier T2, CI green on its old base (fork run approved today), but CONFLICTING with main a7adfe0 (patches/ds-bot/0001-core-fixes.patch).

Problems:

  1. Merge conflict. Merge main and regenerate the ds-bot patch series.
  2. On by default, and it writes to Bot memory without anyone asking. MEMORY.md rides in every request, so an automatic, permanent line changes how the Bot behaves from then on. This should be opt-in (reflexion: true) unless the owner decides otherwise on Reflexion: learn from failures that repeat #485.
  3. The trigger is too broad. Any tool/result with isError counts. Three failing bash / read calls in 10 minutes is normal work (non-zero exit, file not found), and the note then tells the Bot to "stop retrying" that tool, so most working Bots would get a misleading lesson about their core tools. Limit it to identical failures (same tool and same error code/text) and exclude tools whose errors are ordinary results.
  4. Model failures are not the Bot's lesson. model:RATE_LIMIT or a provider outage writes "a model call has failed repeatedly… wait" into every affected Bot's memory, and it stays there after the provider recovers. Turn failures already reach the owner through noteTurnFailure and the finish/fail notifications (Notify when my own Bots finish or fail a turn, with one Notifications switch #470). Drop the model signature, or keep it out of lasting memory.
  5. Notes never expire. Nothing removes the note once the tool works again; only a manual forget does. Give it an expiry or clear it on the next success.
  6. Replace the #TBD placeholders with Reflexion: learn from failures that repeat #485.

No self-review PASS. This is also a new feature that still needs the owner's yes on #485.

@Birfy

Birfy commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

Owner decision (2026-10-20): declining this PR (option b on #485). Please close when convenient.

@Birfy

Birfy commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

Closing per the owner decision on #485 (2026-10-20, option b: decline). Thanks for the work, @HugoXK.

@Birfy Birfy closed this Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:automation Scheduled tasks and automation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reflexion: learn from failures that repeat

2 participants