mirror of
https://github.com/docker/docker-agent.git
synced 2026-11-04 10:02:15 +00:00
The previous save/restore around a fork-skill sub-session was racy against the TUI model picker: a user switching model mid-skill had their choice silently reverted by the deferred restore. Replace the naive ModelOverrides() snapshot + SetModelOverride(prev...) restore with a pointer-identity compare-and-swap: - Add an opaque ModelOverrideSnapshot type plus SnapshotModelOverride and RestoreModelOverride methods on Agent. RestoreModelOverride CAS-swaps on the underlying atomic.Pointer, so the restore is a no-op if any other caller mutated the override since it was captured. - handleRunSkill now snapshots before and after applying the skill's override and defers a CAS-restore. If the user switches model via the TUI (or any other caller wins the race), their choice is kept and the skill's override scope ends cleanly. - Document that ModelOverrides() is for read-only inspection only and that the snapshot/restore primitive must be used for scoped overrides. - Clarify the docs: fallback is to the agent's currently-active model (configured default OR a previously-set override), and concurrent TUI model switches during a fork skill are preserved. Validated with race-detector tests covering the happy path, restore to a pre-existing override, and both concurrent-change and concurrent-clear scenarios. Assisted-By: docker-agent