Conversation
…mounts When a multi-instance provider config has one entry without instance_id (the 'default' instance, e.g. original anthropic entry) and a second entry with an explicit instance_id (e.g. 'anthropic-sonnet'), the second mount was silently overwriting the first under the default name. Root cause: provider modules always self-mount under their default name (e.g. 'anthropic'). When the second entry loaded, it replaced the first at that key. The remap then moved the second to 'anthropic-sonnet' and unmounted 'anthropic' — the first instance was gone. Fix: snapshot the current occupant of the default mount name before each provider mount. After the remap, if the snapshot was overwritten, restore it to the default name. Also relaxes the multi-instance validation: instead of requiring ALL entries to have instance_id, now allows exactly ONE entry per module to omit it (the 'default' instance). Additional entries still require it. This enables the real-world migration pattern where an existing provider entry (no 'id') coexists with a newly-added named instance (with 'id').
3 tasks
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.
Problem
When a user has an existing provider entry (no id) and adds a second instance via the CLI (with id), both entries for the same module cause the first instance to be silently lost.
Root cause: Provider modules always self-mount under their default name (e.g. 'anthropic'). When the second entry loaded:
Symptom: Partial provider failure: 4/5 loaded. Missing: {'anthropic': 1}
Fix
Snapshot approach: Before each provider mount, snapshot any existing occupant of the default mount name. After the remap, if the snapshot was overwritten, restore it.
This correctly handles the mixed scenario:
Validation relaxed: Previously ALL entries in a multi-instance scenario required instance_id. Now at most ONE entry per module may omit it (the 'default' instance). Additional entries still require it.
Both _session_init.py (Rust bridge path) and session.py (Python path) are updated.
Tests
Companion PR
amplifier-app-cli: revert auto-assign Pass 2 in _map_id_to_instance_id() (removes the workaround that caused this bug)