feat: resume-time provider-mismatch guard + session repair/diagnose commands#233
Open
michaeljabbour wants to merge 1 commit into
Open
feat: resume-time provider-mismatch guard + session repair/diagnose commands#233michaeljabbour wants to merge 1 commit into
michaeljabbour wants to merge 1 commit into
Conversation
…ommands Implements microsoft-amplifier/amplifier-support#208 (Option A + recovery path). FEATURE 1: Resume-time provider-mismatch warning - New stdlib-only provider_guard.py module wired at _prepare_resume_context, the single choke point all four resume paths funnel through. - Derives last-writing provider/model from session's events.jsonl via memory-safe line-by-line tail-read (gets last llm:response event). - Compares against active resolved provider; on mismatch, interactive TTY warns + confirms (abort exits cleanly BEFORE any LLM call). - Non-TTY proceeds with logging (automation-safe); model-only mismatch stays silent. - Tested on real incident sessions (openai-written sessions with anthropic config). FEATURE 2: Session repair and diagnostic commands - New 'amplifier session repair <session>' and 'amplifier session diagnose <session>' subcommands wrapping amplifier_foundation.session. - Repair: backup → diagnose → fix structural tool-call damage → write → re-verify. - Honest no-op when healthy; repairs missing tool_results, ordering violations, incomplete assistant turns. - Used by pre-turn repair (main.py:2762) and available as CLI for user recovery. FOUNDATION LOCK BUMP: 91dc9dc0 → 37a257ad (REQUIRED) - Old pin predated session-library restructure; installed wheel lacked diagnosis.py, store.py, finder.py. - Tests masked this via conftest path shadowing; production runs were silent ImportError no-ops. - Bump revives pre-turn auto-repair independently valuable. - Wheel-level API probe passes post-bump. Testing: 1137 → 1162 passing, zero net-new failures. Ruff clean on all touched files. End-to-end proven via real CLI on incident sessions. Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Part of microsoft-amplifier/amplifier-support#208 (Option A + recovery path).
Cross-provider resume can brick sessions due to provider/model mismatches (#206, #207, #208). Wave 1 landed provider-edge fixes; this PR is the resume-layer guard and recovery path.
Features
Feature 1: Resume-time provider-mismatch warning
Feature 2: Session repair and diagnostic commands
amplifier session repair <session>andamplifier session diagnose <session>subcommands.Technical Details
New Files
Modified Files
Foundation Lock Bump: A Critical Discovery
Shipped auto-repair was silently dead.
The old pin (91dc9dc0 → v1.0.0) predates the foundation's session-library restructure. The installed wheel lacked diagnosis.py, store.py, and finder.py entirely. Consequently:
The lock bump (37a257ad) revives both the new Feature 2 and the pre-existing-but-broken pre-turn repair independently. Wheel-level API probe passes post-bump — all repair functions are present.
Testing
End-to-End Proof
(a) Provider mismatch warning + abort
PTY-driven resume with openai-written session + anthropic config:
✓ User can abort before any LLM call. events.jsonl untouched.
(b) Session diagnosis and repair
Scope & Deferred Work
What's included:
What's out of scope (per design):
Remaining for this Issue
Per the maintainer-triaged A+B direction, Wave 2 Phase 2:
The subtraction check (documented in the issue thread) proved no core kernel changes are needed for Wave 1 or Wave 2/Phase 1.