Merged
Conversation
Previously, the user message hash was used to identify a spot in a conversation history that the tool call history should be inserted. This presented an issue whe messages from the user were the same - particularly, "yes" is a common message because the model often asks "would you like me to proceed?". This would cause an error when the chat history manager attempted to insert a tool call history multiple times. Instead, we use the index of the user message in the chat history as the identifier. This should remain consistent across CompletionRequest calls as the history is append-only for a single session.
Errors were popping up around psycopg-generated prepared statements not existing. This is likely due to the sharing of connections via the connection pool in different scenarios. This change avoid psycopg from automatically triggering a prepared statement when a statement occurs 3 times. This may result in some performance hit for queries that happen over and over, but avoid correct queries returning errors. We'll need to manually prepare statements when using pooled connections if we want that speedup.
mmcfarland
approved these changes
Apr 9, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes two issues:
Chat history hashing issue
Previously, the user message hash was used to identify a spot in a conversation history that the tool call history should be inserted. This presented an issue whe messages from the user were the same - particularly, "yes" is a common message because the model often asks "would you like me to proceed?". This would cause an error when the chat history manager attempted to insert a tool call history multiple times.
Instead, we use the index of the user message in the chat history as the identifier. This should remain consistent across CompletionRequest calls as the history is append-only for a single session.
Prepared statements in pooled connections
Errors were popping up around psycopg-generated prepared statements not existing. This is likely due to the sharing of connections via the connection pool in different scenarios. This change avoids psycopg from automatically triggering a prepared statement when a statement occurs 3 times. This may result in some performance hit for queries that happen over and over, but avoid correct queries returning errors. We'll need to manually prepare statements when using pooled connections if we want that speedup.