From 70139a921078cd9c4e0871d7e1ff3425fab0c246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Sibiril?= <81782+aureliensibiril@users.noreply.github.com> Date: Fri, 24 Apr 2026 19:59:37 +0200 Subject: [PATCH] Drop unused AgentRun.SaveCheckpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The transactional variant is no longer reachable: supervisor paths persist checkpoints through PGCheckpointer (WithConn, not WithTx), and Update deliberately excludes the checkpoint column to avoid racing a concurrent checkpoint save. Nothing else calls it. Signed-off-by: Aurélien Sibiril <81782+aureliensibiril@users.noreply.github.com> --- pkg/coredata/agent_run.go | 61 --------------------------------------- 1 file changed, 61 deletions(-) diff --git a/pkg/coredata/agent_run.go b/pkg/coredata/agent_run.go index 2009640c5..0c5e1a89f 100644 --- a/pkg/coredata/agent_run.go +++ b/pkg/coredata/agent_run.go @@ -442,67 +442,6 @@ WHERE return nil } -// SaveCheckpoint writes checkpoint inside the caller's transaction. Use -// this from service methods that must update checkpoint and status -// atomically, such as Approve. -func (e *AgentRun) SaveCheckpoint( - ctx context.Context, - tx pg.Tx, - scope Scoper, - cp *agent.Checkpoint, -) error { - data, err := marshalAgentCheckpoint(cp) - if err != nil { - return err - } - - q := ` -UPDATE agent_runs -SET - checkpoint = @checkpoint, - updated_at = now() -WHERE - %s - AND id = @id -RETURNING - id, - organization_id, - start_agent_name, - status, - checkpoint, - input_messages, - result, - error_message, - started_at, - lease_owner, - lease_expires_at, - created_at, - updated_at; -` - - q = fmt.Sprintf(q, scope.SQLFragment()) - - args := pgx.StrictNamedArgs{ - "id": e.ID.String(), - "checkpoint": json.RawMessage(data), - } - maps.Copy(args, scope.SQLArguments()) - - rows, err := tx.Query(ctx, q, args) - if err != nil { - return fmt.Errorf("cannot save agent run checkpoint: %w", err) - } - - entity, err := pgx.CollectExactlyOneRow(rows, pgx.RowToStructByName[AgentRun]) - if err != nil { - return fmt.Errorf("cannot save agent run checkpoint: %w", err) - } - - *e = entity - - return nil -} - func (e *AgentRun) LoadNextPendingForUpdateSkipLocked( ctx context.Context, tx pg.Tx,