Skip to content

Client AI: do not send temperature unless explicitly configured - #108014

Merged
alexey-milovidov merged 1 commit into
masterfrom
ai-sql-optional-temperature
Jun 24, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
ai-sql-optional-temperature

Conversation

@alexey-milovidov

Copy link
Copy Markdown
Member

The AI SQL generation feature in clickhouse-client / clickhouse-local (the ?? prompt) always sent a temperature parameter to the model, because AIConfiguration::temperature defaulted to 0.0 and was unconditionally copied into the request options.

Some models reject the temperature parameter outright — for example, reasoning models served behind OpenAI-compatible gateways respond with temperature is deprecated for this model — which made AI SQL generation fail for those models regardless of configuration.

This makes temperature a std::optional<double> that is left unset by default and only sent to the model when the user explicitly configures ai.temperature. The request builder already omits the field when the option has no value, so there is no behavior change for users who do set a temperature.

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

AI SQL generation in the client no longer sends the temperature parameter unless it is explicitly set via ai.temperature in the configuration. This fixes AI SQL generation for models that reject the temperature parameter.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

The AI SQL generation feature (`??` prompt) always sent a `temperature`
parameter to the model, because `AIConfiguration::temperature` defaulted
to `0.0` and was unconditionally copied into the request options.

Some models reject the `temperature` parameter outright (for example,
reasoning models served behind OpenAI-compatible gateways respond with
`temperature is deprecated for this model`), which made AI SQL generation
fail for those models regardless of configuration.

Make `temperature` a `std::optional<double>` that is left unset by default
and only sent to the model when the user explicitly configures
`ai.temperature` in the client configuration. The request builder already
omits the field when the option has no value, so no behavior changes for
users who do set a temperature.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ca91c12]

Summary: ✅


AI Review

Summary

This PR makes AIConfiguration::temperature optional so AI SQL generation in clickhouse-client / clickhouse-local omits the temperature request parameter unless ai.temperature is explicitly configured. Config loading preserves the unset state, AISQLGenerator forwards the optional unchanged, and the SDK request builders only serialize temperature when it has a value. The added factory test covers both the unset default and explicit 0.0; I found no line-level correctness issues.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jun 20, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.20% 85.20% +0.00%
Functions 92.50% 92.50% +0.00%
Branches 77.40% 77.50% +0.10%

Changed lines: Changed C/C++ lines covered by tests: 15/15 (100.00%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@alexey-milovidov

Copy link
Copy Markdown
Member Author

@groeneai, fix the test for RabbitMQ and send a PR.

@groeneai

Copy link
Copy Markdown
Collaborator

@alexey-milovidov done in a separate PR: #108253.

test_rabbitmq_csv_with_delimiter is unrelated to this PR; it polls for the 50 published rows against a fixed 60s wall-clock deadline that is never extended, so on a contended sanitizer runner full delivery can exceed 60s and the loop fails mid-consumption (the failing run's isolated retry passed in 65.27s). CIDB: 14 such timeouts in 30d across 11 unrelated PRs + 3 master runs. Fix resets the deadline while rows keep arriving, matching the existing check_expected_result_polling logic; final correctness assertion unchanged.

@pamarcos pamarcos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good. Ship it 🚀

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 24, 2026
Merged via the queue into master with commit 87b534e Jun 24, 2026
486 of 490 checks passed
@alexey-milovidov
alexey-milovidov deleted the ai-sql-optional-temperature branch June 24, 2026 14:10
ylw510 pushed a commit to ylw510/ClickHouse that referenced this pull request Jun 24, 2026
Direct SELECT from `RabbitMQ` consumes rows, so tests must accumulate returned batches. Reset the polling deadline whenever accumulated rows increase to avoid failing while sanitizer/db-disk runs are still making progress.

CI report:

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108014&sha=ca91c12b238e033b5dc8c7453295e4e7017ac997

Related PR: ClickHouse#108014
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 24, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…temperature

Client AI: do not send `temperature` unless explicitly configured
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Direct SELECT from `RabbitMQ` consumes rows, so tests must accumulate returned batches. Reset the polling deadline whenever accumulated rows increase to avoid failing while sanitizer/db-disk runs are still making progress.

CI report:

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108014&sha=ca91c12b238e033b5dc8c7453295e4e7017ac997

Related PR: ClickHouse#108014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants