Add Agents array to CommittedMetadata for multi-agent checkpoints#98
Add Agents array to CommittedMetadata for multi-agent checkpoints#98
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an Agents array field to CommittedMetadata to support tracking multiple agents in multi-session checkpoints. The implementation maintains full backwards compatibility with existing single-agent checkpoints while enabling proper tracking when multiple AI agents collaborate on the same checkpoint.
Changes:
- Added
Agents []stringfield toCommittedMetadatafor tracking all contributing agents in multi-session checkpoints - Implemented agent merging logic with deduplication while preserving order
- Maintained backwards compatibility by keeping the singular
Agentfield populated with the first agent
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cmd/entire/cli/checkpoint/checkpoint.go | Added Agents field to CommittedMetadata struct with appropriate JSON tag and documentation |
| cmd/entire/cli/checkpoint/committed.go | Implemented agent merging logic in writeMetadataJSON and added mergeAgents helper function |
| cmd/entire/cli/checkpoint/checkpoint_test.go | Added comprehensive test coverage for single-session (no Agents array), multi-session merge (multiple agents), and same-agent deduplication scenarios |
b18efb4 to
07ba5c6
Compare
07ba5c6 to
00fadc8
Compare
| for i := 1; i <= 2; i++ { | ||
| err = store.WriteCommitted(context.Background(), WriteCommittedOptions{ | ||
| CheckpointID: checkpointID, | ||
| SessionID: "session-" + string(rune('0'+i)), |
There was a problem hiding this comment.
The session ID generation using string(rune('0'+i)) is unconventional and could be confusing to readers. While it works correctly for i=1 and i=2 (producing "session-1" and "session-2"), a more idiomatic approach would be using fmt.Sprintf("session-%d", i) or strconv.Itoa(i) for better readability and maintainability.
00fadc8 to
fee19d0
Compare
fee19d0 to
8466902
Compare
8466902 to
b543b3a
Compare
| err := store.WriteCommitted(context.Background(), WriteCommittedOptions{ | ||
| CheckpointID: checkpointID, | ||
| SessionID: "session-" + string(rune('0'+i)), | ||
| Strategy: "auto-commit", |
There was a problem hiding this comment.
The session ID generation is incorrect. string(rune('0'+i)) creates a single-character string from a rune, which for i=1 gives '1' and for i=2 gives '2'. This means the session IDs will be "session-1" and "session-2", but if the loop were to iterate beyond i=9, it would produce non-digit characters. A safer approach would be to use string formatting like fmt.Sprintf("session-%d", i) or strconv.Itoa(i).
Note
Introduces multi-agent tracking for committed checkpoints while preserving backwards compatibility.
Agentsarray toCommittedMetadata; keepAgentas the first agent for compat (single-session omitsagents)writeMetadataJSONto merge multi-session data: deduplicate/mergeagents,session_ids,files_touched, and incrementsession_countmergeAgentshelper for order-preserving deduplicationagents), multi-session (ordered agents array), and deduplication; plus helper to read metadata from branchRisk: Low — additive metadata field and merge logic covered by tests; existing reads continue using
agentfieldWritten by Cursor Bugbot for commit b543b3a. This will update automatically on new commits. Configure here.