fix: write messages from session in a batch for efficiency#5598
fix: write messages from session in a batch for efficiency#5598michaelneale wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes database operations by introducing a batch insert method for adding multiple messages to a session. Instead of executing individual INSERT and UPDATE statements for each message, the new add_messages method wraps all operations in a single transaction, reducing database round-trips and improving performance.
Key Changes:
- Added
add_messagesmethod to batch-insert multiple messages in a single transaction - Refactored the agent loop to use the new batch insert method instead of individual message inserts
- Added comprehensive test coverage for the batch insert functionality
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/goose/src/session/session_manager.rs | Implements add_messages method for batch message insertion with transaction support and adds corresponding test coverage |
| crates/goose/src/agents/agent.rs | Updates agent loop to use the new batch insert method instead of iterating through messages individually |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I actually don't think this is the fix for the reported issue; that was talking about how web hammers the database. if you do a web session and then open that web session in goose, you can clearly see what happens. web writes streaming messages in one by one and then agent writes the resulting message. so the fix is really simple: |
|
#5601 has been merged. going to close this out now, but feel free to reopen if there is still something missing @michaelneale |
|
yep, not needed, and not in right area. |
fixes: #5576
this will write it at once, vs message by message. I have tested this cli and desktop, and even with mobile following along reading the DB, and seemed fine (fast even?)
@DOsinga I don't know what downside of doing this is vs status quo, I don't think it is a massive saving, "felt fast" but surely there aren't that many messages coming in.