fix: branch teammates from the last stable turn#36
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1fd451f0e0
ℹ️ 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".
| const candidate = path[i]; | ||
| if (!candidate) continue; | ||
| if (isUserMessageEntry(candidate)) { | ||
| return { leafId: candidate.id, adjusted: candidate.id !== requestedLeafId, reason: "clean-turn-user" }; |
There was a problem hiding this comment.
Keep branch leaf on persisted assistant path
Returning clean-turn-user here can select a user-only branch when the leader is in its first tool-use turn (no earlier completed assistant). In that case createSessionForTeammate() passes this user leaf to SessionManager.createBranchedSession(...), and the pi-coding-agent implementation does not persist a branched session file unless the branch contains an assistant message; the spawned worker then starts from a fresh/empty session instead of the intended branch context. This regresses branch mode specifically for first-turn delegation with in-flight tool use.
Useful? React with 👍 / 👎.
Findings
Verdictneeds attention — the new branch-selection flow has a broken user-fallback path that can start workers from an empty session, and the chosen stable branch point also strips the active user request from branched context. |
Findings
Verdictneeds attention — the follow-up fixes address the earlier file materialization, user-request replay, and test-cleanup gaps, but the cleaned-branch path still drops post-assistant context entries in compacted sessions. |
Summary
Testing
Closes #35