fix: keep migrated agents running and harden migration paths#1
fix: keep migrated agents running and harden migration paths#1simonovic86 wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 89e30cb9b1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if err := s.startManagedAgentLoop(pkg.AgentID, instance); err != nil { | ||
| s.logger.Error("Failed to start migrated agent", "error", err) | ||
| _ = instance.Close(ctx) | ||
| s.sendStartConfirmation(stream, pkg.AgentID, false, err.Error()) | ||
| return |
There was a problem hiding this comment.
Clean up checkpoint when managed agent registration fails
If startManagedAgentLoop fails here (for example because registerManagedAgent rejects a duplicate agentID), the handler returns an error but leaves the just-written checkpoint file in place. In this path, the existing local agent keeps running while its persisted checkpoint has been overwritten by the incoming transfer, so a later restart/load can resume from the wrong state even though migration was rejected.
Useful? React with 👍 / 👎.
Summary
agent_idbefore building filesystem pathsWhy
This addresses three concrete defects:
activeAgentsmap was unsafely accessed from concurrent stream handlersValidation
PATH="$HOME/go/bin:$PATH" make checkfmt-check,go vet,golangci-lint,go test ./...)