Skip to content

delegate_gemini: error clearly on checkpoint-miss-on-resume + guarantee an answer at the step cap - #19

Merged
allocsys merged 5 commits into
mainfrom
fix/delegate-gemini-checkpoint-miss
Jul 26, 2026
Merged

delegate_gemini: error clearly on checkpoint-miss-on-resume + guarantee an answer at the step cap#19
allocsys merged 5 commits into
mainfrom
fix/delegate-gemini-checkpoint-miss

Conversation

@allocsys

Copy link
Copy Markdown
Owner

Fixes the regression found while live-testing the 2026-07-26 delegate_gemini resume fix (PR #17). Full writeup: madmcp-delegate-gemini-resume-checkpoint-miss-2026-07-26 / BUG page (Notion).

1. Checkpoint-miss-on-resume no longer silent

runInvestigation couldn't previously distinguish "no resume requested" from "resume requested but loadCheckpoint returned null" (expired TTL, Redis unavailable, bad id) -- both fell through to the same fresh-run branch, which on a resume call could build a prompt from a literal Task: undefined. Confirmed live: the model burned 5 steps hunting Mem0/Notion for context before stumbling onto its own prior partial-run log.

Now: resume_run_id given + no checkpoint loaded + no task provided -> throws a clear, distinct error ("has no live checkpoint ... no saved task to resume from"), caught by tools.js's existing try/catch and returned as an explicit failure. If a task was also provided, the existing graceful fresh-start fallback is preserved (defensive-caller pattern).

2. Step-budget cap now guarantees an answer attempt

Previously only a text reminder asked the model to wrap up near the step cap -- in testing, the model used its literal last step on another tool call anyway, and the run hit the cap with zero synthesized answer. Fixed structurally: the final allowed step now calls Gemini with no function-calling tools in the request at all, so a function call is impossible on that turn by construction, not by instruction-following. Kept an escalating text nudge on top (2 steps remaining: wrap up; 1 remaining: this turn has no tools, answer now) for quality.

Testing status

Both fixes are unit-reasoned through the code paths but not yet re-verified end-to-end against live Gemini + Redis (the original bug was only caught via a live test). Recommend a live re-test before merge:

  • Resume with a bogus/expired resume_run_id and no task -> should now return a clear error, not a confused run.
  • A task deliberately too broad for a tight max_steps -> should now return some answer (even if explicitly marked incomplete) at the cap, never a bare "(stopped after reaching cap)" with nothing.

allocsys added 5 commits July 26, 2026 13:01
… with an undefined task; throw a clear, distinct error instead
…e: withhold function-calling tools entirely on the final allowed step instead of relying on a text reminder
… now has no tools available at all, not just a soft suggestion to wrap up
…d-error when there is truly nothing to fall back on (no task provided either); if a task WAS provided alongside a resume_run_id that fails to load, keep the graceful fresh-start fallback for defensive callers
…ition to the hard final-step guarantee), per the documented fix plan's escalating-notice design
@vercel

vercel Bot commented Jul 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
madmcp Ready Ready Preview, Comment Jul 26, 2026 9:33am

@allocsys
allocsys merged commit 3f849b1 into main Jul 26, 2026
4 checks passed
@allocsys
allocsys deleted the fix/delegate-gemini-checkpoint-miss branch July 26, 2026 09:37
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