Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crates/goose/src/session/session_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,10 @@ impl SessionStorage {
async fn get_conversation(&self, session_id: &str) -> Result<Conversation> {
let pool = self.pool().await?;
let rows = sqlx::query_as::<_, (String, String, i64, Option<String>, Option<String>)>(
"SELECT role, content_json, created_timestamp, metadata_json, message_id FROM messages WHERE session_id = ? ORDER BY timestamp",
// Order by created_timestamp, then by id to break ties. created_timestamp is in seconds,
// so messages created in the same second (e.g., tool request and response) need to
// maintain their insertion order via the auto-increment id.
"SELECT role, content_json, created_timestamp, metadata_json, message_id FROM messages WHERE session_id = ? ORDER BY created_timestamp, id",
)
.bind(session_id)
.fetch_all(pool)
Expand Down
Loading