Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@shuyangli
Copy link
Member

@shuyangli shuyangli commented Jan 27, 2026

This implements the main set of inference queries: list/get inferences, insert inferences, count inferences, and so on.

There's some duplication across InferenceQueries and InferenceCountQueries - will remove the InferenceCountQueries later. (Those were directly ported from the frontend.)

Step towards #5691.


Note

Medium Risk
Adds a large new Postgres query implementation and routes core inference/batch write paths through a new dual-write abstraction, which could affect inference persistence and query correctness despite feature-flag gating.

Overview
Implements full Postgres support for InferenceQueries (list/count inferences, fetch outputs/tool params/output schema, and batch inserts for chat/json inferences), including SQL filter/order-by handling and UNION queries across chat/json tables.

Updates the DB abstraction to support inference reads/writes via DelegatingDatabaseConnection and adds optional dual-write of chat/json inference rows to Postgres behind feature flags, wiring this through /inference and batch inference persistence.

Refactors pagination validation into ListInferencesParams::validate_pagination, adds StoredInferenceDatabase::timestamp(), generates new .sqlx query metadata, and expands e2e inference query tests to run against both ClickHouse and Postgres.

Written by Cursor Bugbot for commit 49130eb. This will update automatically on new commits. Configure here.

@shuyangli shuyangli force-pushed the sl/postgres-inference-queries branch 4 times, most recently from f098854 to f98ca8b Compare January 27, 2026 22:35
@shuyangli shuyangli force-pushed the sl/postgres-feedback-tables-and-writes branch from 7c0807d to a662ea1 Compare January 27, 2026 23:24
@shuyangli shuyangli force-pushed the sl/postgres-inference-queries branch from f98ca8b to 73bf4fa Compare January 27, 2026 23:24
@shuyangli shuyangli force-pushed the sl/postgres-feedback-tables-and-writes branch from a662ea1 to 3d54063 Compare January 28, 2026 02:06
@shuyangli shuyangli force-pushed the sl/postgres-inference-queries branch from 73bf4fa to b30f8b4 Compare January 28, 2026 02:06
@shuyangli shuyangli force-pushed the sl/postgres-feedback-tables-and-writes branch from 3d54063 to cdfd5a9 Compare January 28, 2026 03:15
@shuyangli shuyangli force-pushed the sl/postgres-feedback-tables-and-writes branch 5 times, most recently from fd9a7b3 to a1c96c6 Compare January 28, 2026 14:51
@shuyangli shuyangli force-pushed the sl/postgres-inference-queries branch from b30f8b4 to e5d90b3 Compare January 28, 2026 15:01
@shuyangli shuyangli force-pushed the sl/postgres-inference-queries branch 3 times, most recently from 64cacd9 to 6e9cc21 Compare January 28, 2026 17:24
@shuyangli shuyangli force-pushed the sl/postgres-feedback-tables-and-writes branch from a1c96c6 to 9e2cdae Compare January 28, 2026 18:38
@shuyangli shuyangli force-pushed the sl/postgres-inference-queries branch 2 times, most recently from 5bcdb93 to cb64a5e Compare January 28, 2026 18:40
@shuyangli shuyangli force-pushed the sl/postgres-feedback-tables-and-writes branch 2 times, most recently from 4c85997 to b8838e8 Compare January 28, 2026 19:15
@shuyangli shuyangli force-pushed the sl/postgres-inference-queries branch from cb64a5e to ac7926c Compare January 28, 2026 19:17
@shuyangli shuyangli force-pushed the sl/postgres-inference-queries branch from ac7926c to 43cfaef Compare January 28, 2026 19:20
@shuyangli shuyangli force-pushed the sl/postgres-inference-queries branch from 43cfaef to c1ca825 Compare January 28, 2026 20:31
@shuyangli shuyangli force-pushed the sl/postgres-feedback-tables-and-writes branch from 8662a07 to 52b9905 Compare January 28, 2026 20:34
@shuyangli shuyangli force-pushed the sl/postgres-inference-queries branch 3 times, most recently from 6cb9d7d to 7bbd8c2 Compare January 28, 2026 20:57
Base automatically changed from sl/postgres-feedback-tables-and-writes to main January 28, 2026 22:05
@shuyangli shuyangli force-pushed the sl/postgres-inference-queries branch from 7bbd8c2 to e232cb9 Compare January 28, 2026 22:08
@shuyangli shuyangli force-pushed the sl/postgres-inference-queries branch 2 times, most recently from d9e5966 to 49130eb Compare January 28, 2026 22:41
@shuyangli shuyangli marked this pull request as ready for review January 28, 2026 22:41
Copy link
Member Author

@BugBot review

@shuyangli shuyangli force-pushed the sl/postgres-inference-queries branch from 49130eb to d749c33 Compare January 28, 2026 22:49
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@shuyangli shuyangli force-pushed the sl/postgres-inference-queries branch from d749c33 to a20bfa5 Compare January 28, 2026 23:10
message: "Filters are not yet supported for Postgres count queries".to_string(),
}));
}
if params.search_query_experimental.is_some() {
Copy link
Member Author

Choose a reason for hiding this comment

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

need to sort out the index on JSONB columns - we need to add a trgm index on the text representation, and use the same expression in the query

Copy link
Member Author

@codex review

@chatgpt-codex-connector
Copy link

Codex review is not enabled for this repo. Please contact the admins of this repo to enable Codex.

Copy link
Member Author

@claude review

Uncomment tests

Implement delegating trait

Push order and limit down to postgres
@shuyangli shuyangli force-pushed the sl/postgres-inference-queries branch from a20bfa5 to d5f421f Compare January 29, 2026 17:31
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