Skip to content

Chat fixes#537

Merged
lossyrob merged 2 commits intomainfrom
users/rde/chat-fixes
Apr 10, 2025
Merged

Chat fixes#537
lossyrob merged 2 commits intomainfrom
users/rde/chat-fixes

Conversation

@lossyrob
Copy link
Copy Markdown
Contributor

@lossyrob lossyrob commented Apr 9, 2025

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.

lossyrob added 2 commits April 9, 2025 11:23
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.
@lossyrob lossyrob requested review from a team as code owners April 9, 2025 15:28
@lossyrob lossyrob merged commit aaf7090 into main Apr 10, 2025
2 checks passed
@lossyrob lossyrob deleted the users/rde/chat-fixes branch April 10, 2025 04:08
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.

2 participants