Skip to content

Conversation

@frederic-openai
Copy link

  • So far if e.g. from_turn_number=3 is passed, only turns 1 and 2 are copied, not 3
  • This is unintuitive because the function is called branch_from_turn() and I would expect the passed turn to be copied as well
  • It is also limiting in that it doesn't allow branching from the last turn in the conversation (_validate_turn() raises an error if from_turn_number=n+1 is passed in an n-turn conversation, so users would have to hack their way around it by adding a dummy message as n+1st turn in order to copy the first n turns)
  • In case we're preventing branching from the latest turn on purpose for some reason please let me know
  • if so, what would be the preferred way to fork a conversation from the latest message? (My use case is that I want to produce multiple alternative messages from the same conversation history)

- So far if e.g. from_turn_number=3 is passed, only turns 1 and 2 are copied, not 3
- This is unintuitive because the function is called branch_from_turn()
- In conjunction with _validate_turn() it is also limiting functionality in that it doesn't allow branching from the latest turn (_validate_turn() raises an error if from_turn_number=n+1 is passed in an n-turn conversation, so users would have to hack their way around it by adding a dummy message as n+1st turn in order to copy the first n turns)
- In case we're preventing branching from the latest turn on purpose for some reason please let me know - if so, what would be the preferred way to fork a conversation from the latest message? (My use case is that I want to produce multiple alternative messages from the same conversation history)
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ 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".

Comment on lines 815 to 819
ms.tool_name
FROM message_structure ms
WHERE ms.session_id = ? AND ms.branch_id = ?
AND ms.branch_turn_number < ?
AND ms.branch_turn_number <= ?
ORDER BY ms.sequence_number

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve exclusive copy semantics when branching

Switching the filter in _copy_messages_to_new_branch from < to <= now copies the messages belonging to from_turn_number into the new branch. However create_branch_from_turn() is documented (docstring at line 597: “copy messages before the branch point”) and covered by tests such as test_branch_specific_operations to copy turns strictly before the branch point, leaving the branch empty when branching from turn 1. With this change create_branch_from_turn(1) will copy the turn‑1 messages, so the tests that expect the branch to contain only the newly added items will fail and existing callers now get a different conversation history than promised by the API. Please keep the comparison exclusive or update the API docs/tests accordingly.

Useful? React with 👍 / 👎.

@frederic-openai frederic-openai deleted the fix/conversation-branching-from-turn-number branch November 10, 2025 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants