Skip to content

Commit 87798bd

Browse files
fix: AdvcancedSQLiteSession conversation branching from turn number
- 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)
1 parent 73e7843 commit 87798bd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/agents/extensions/memory/advanced_sqlite_session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ def _copy_sync():
815815
ms.tool_name
816816
FROM message_structure ms
817817
WHERE ms.session_id = ? AND ms.branch_id = ?
818-
AND ms.branch_turn_number < ?
818+
AND ms.branch_turn_number <= ?
819819
ORDER BY ms.sequence_number
820820
""",
821821
(self.session_id, self._current_branch_id, from_turn_number),

0 commit comments

Comments
 (0)