Skip to content

Conversation

@michaelneale
Copy link
Collaborator

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.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_messages method 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.

@michaelneale michaelneale changed the title fix: write things in one go fix: write messages from session in a batch for efficiency Nov 6, 2025
@DOsinga
Copy link
Collaborator

DOsinga commented Nov 6, 2025

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

@alexhancock
Copy link
Collaborator

#5601 has been merged. going to close this out now, but feel free to reopen if there is still something missing @michaelneale

@alexhancock alexhancock closed this Nov 6, 2025
@michaelneale
Copy link
Collaborator Author

yep, not needed, and not in right area.

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.

Reduce Excessive Database Writes from Agent Stream Messages in goose Web

5 participants