From 620499306ed4194a48ba4a514de71b7ee580d00b Mon Sep 17 00:00:00 2001 From: Christian Rocha Date: Tue, 14 Apr 2026 08:34:47 -0400 Subject: [PATCH] docs: add comment explaining non-atomic SaveWithModels behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 💘 Generated with Crush Assisted-by: GLM-5.1 via Crush --- internal/session/session.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/session/session.go b/internal/session/session.go index 0271bf9a293095c259f114bce2de5e0d901e5ec1..8c13d2f146993909ff6f31417ed3fda4206def74 100644 --- a/internal/session/session.go +++ b/internal/session/session.go @@ -322,6 +322,11 @@ func (s *service) UpdateSessionModels(ctx context.Context, id string, models map return err } +// SaveWithModels saves the session and then persists the models column as a +// second operation. This is intentionally non-atomic: if the models update +// fails, the session fields are still saved (which is equivalent to the +// pre-feature behavior where models were never persisted). The next agent turn +// will retry the models write, so transient failures are self-healing. func (s *service) SaveWithModels(ctx context.Context, session Session, models map[config.SelectedModelType]config.SelectedModel) (Session, error) { saved, err := s.Save(ctx, session) if err != nil {