Skip to content

Commit 990b4f5

Browse files
authored
Fix an issue where the AI Assistant was not retaining conversation context between messages, with chat history compaction to manage token budgets.
* Address CodeRabbit review feedback for chat context and compaction. - Track tool-use turns as groups instead of one-to-one pairs, so multi-tool assistant messages don't leave orphaned results. - Add fallback to shrink the recent window when protected messages alone exceed the token budget, preventing compaction no-ops. - Fix low-value test fixtures to keep transient messages short so they actually classify as low-importance. - Guard Clear button against in-flight stream race conditions by adding a clearedRef flag and cancelling active streams. - Assert that conversation history is actually passed through to chat_with_database in the "With History" test. * Address remaining CodeRabbit review feedback for compaction module. - Expand protected set to cover full tool groups, preventing orphaned tool call/result messages when a turn straddles the recent window. - Add input validation in deserialize_history() for non-list/non-dict data. - Strengthen test assertion for preserved recent window tail. * Fix CI test failures in compaction and NLQ chat tests. - Lower max_tokens budget in test_drops_low_value to reliably force compaction (500 was borderline, use 200). - Consume SSE response data before asserting mock calls in NLQ chat test, since Flask's streaming generator only executes on iteration. * Clarify mock patch target in NLQ chat test. Add comment explaining why we patch the source module rather than the use site: the endpoint uses a local import inside the function body, so there is no module-level binding to patch.
1 parent 74b1a3b commit 990b4f5

7 files changed

Lines changed: 935 additions & 14 deletions

File tree

docs/en_US/release_notes_9_14.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Bug fixes
3232
*********
3333

3434
| `Issue #9279 <https://github.com/pgadmin-org/pgadmin4/issues/9279>`_ - Fixed an issue where OAuth2 authentication fails with 'object has no attribute' if OAUTH2_AUTO_CREATE_USER is False.
35+
| `Issue #9736 <https://github.com/pgadmin-org/pgadmin4/issues/9736>`_ - Fixed an issue where the AI Assistant was not retaining conversation context between messages, with chat history compaction to manage token budgets.
3536
| `Issue #9392 <https://github.com/pgadmin-org/pgadmin4/issues/9392>`_ - Ensure that the Geometry Viewer refreshes when re-running queries or switching geometry columns, preventing stale data from being displayed.
3637
| `Issue #9694 <https://github.com/pgadmin-org/pgadmin4/issues/9694>`_ - Fixed an issue where AI Reports are grayed out after setting an API key by auto-selecting the default provider.
3738
| `Issue #9702 <https://github.com/pgadmin-org/pgadmin4/issues/9702>`_ - Fixed misleading AI activity messages that could be mistaken for actual database operations.

0 commit comments

Comments
 (0)