Skip to content

fix: claude and gemini AI drivers for current models, with Claude reasoning and opt-in prompt caching - #10073

Merged
nishantmonu51 merged 4 commits into
mainfrom
paragjain/fix-ai-drivers-current-models
Oct 29, 2026
Merged

nishantmonu51 merged 4 commits into
mainfrom
paragjain/fix-ai-drivers-current-models

Conversation

@pjain1

@pjain1 pjain1 commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Fixes AI chat failing on current models with the existing AI drivers, found while building the Bedrock driver (#10069) and from a report that every chat failed on Claude Sonnet 5.5, Opus 5.5, and Haiku 5.5 through the claude connector. The reasoning and prompt caching changes follow the approach in #10074.

Driver fixes (first commit)

  • claude: only send temperature if configured (Opus 4.7+ rejects sampling parameters, and Sonnet/Haiku 5.5 reject non-default values), and keep $defs in tool schemas (BetaToolInputSchemaParam dropped every keyword except type/properties/required, so $ref params like time_range/where pointed at nothing). Empty text blocks are skipped in requests and responses.
  • gemini: only send temperature if configured (Google recommends the default 1.0 for Gemini 3 and warns lower values can cause looping).
  • openai: no driver change. Its default temperature of 0.1 is accepted by the default model (gpt-5.2) and is already omitted when reasoning_effort is set, so the docs now say to set reasoning_effort for models that reason by default.
  • Behavior change: when not configured, Claude and Gemini models now sample at their own default temperature instead of 0.1, including Rill-managed AI on those drivers.

Opt-in prompt caching for Claude (second commit)

  • New prompt_caching option on the claude connector (off by default) marks the tools, system prompt, and conversation as cache breakpoints. Rill-managed AI can enable it with RILL_ADMIN_CLAUDE_PROMPT_CACHING.
  • Cache writes (billed at 1.25x input) are reported as a new CompleteResult.CacheWriteInputTokens, passed through the admin Complete API, and emitted as a cache_write_input_tokens metric. Billing will need to price this new metric before enabling caching for managed AI.

Claude reasoning within the tool loop (third commit)

  • Anthropic requires thinking blocks to be passed back unmodified within a tool-use turn. New Reasoning block on rill.ai.v1.ContentBlock (text, signature, or redacted data).
  • Reasoning is kept in memory until the tool loop completes (not added to the session). It's removed when the history is truncated and on the final no-tools iteration, since thinking blocks are bound to the history and tools they were produced with (removing all of them is allowed).
  • The admin Complete API removes reasoning from responses unless the client sets include_reasoning, so older runtimes (e.g. older Rill Developer versions on managed AI) keep working.
  • The gemini driver and the metrics view / canvas generators skip reasoning blocks instead of erroring.

Tests: drivers are tested against fake servers through their real SDKs (request body assertions); the tool loop, truncation, and admin stripping have unit tests. The key tests fail against the code without the corresponding fix. Not yet run against the real APIs.

Not in scope: moving the openai driver to the Responses API (the newest OpenAI models only support tool calling there).

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

Developed in collaboration with Claude Code

- claude: only send temperature if configured (current models reject it),
  keep $defs in tool schemas (the SDK type dropped every key except type/properties/required),
  and stop turning thinking blocks into (empty) text blocks, which the API rejects on the next tool loop iteration
- openai: only send temperature if configured (reasoning models reject it unless reasoning effort is "none")
- gemini: only send temperature if configured (Google warns lower values cause looping on Gemini 3)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nishantmonu51
nishantmonu51 requested a balanced review from Copilot October 28, 2026 07:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@nishantmonu51 nishantmonu51 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍 , LGTM

Not sending temperature by default changed sampling for the default setup (gpt-5.2 accepts temperature)
from 0.1 to OpenAI's default of 1.0, including Rill-managed AI, while the failing case (reasoning models)
already has a workaround: setting reasoning_effort omits temperature.
Documents that workaround and tests the existing behavior instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pjain1 pjain1 changed the title fix: claude, openai, and gemini AI drivers for current models fix: claude and gemini AI drivers for current models Oct 28, 2026
pjain1 and others added 2 commits October 28, 2026 18:50
- Adds a `prompt_caching` option to the `claude` connector (off by default) that marks the tools,
  system prompt, and conversation as cache breakpoints, so later steps of a tool loop read them from the prompt cache.
  Rill-managed AI can enable it with RILL_ADMIN_CLAUDE_PROMPT_CACHING.
- Reports cache writes (Claude bills them at a premium) as a new CompleteResult.CacheWriteInputTokens field,
  passed through the admin Complete API and emitted as a cache_write_input_tokens metric.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude requires thinking blocks to be passed back unmodified within a tool call loop.
- Adds a Reasoning content block (text, signature, or redacted data) to rill.ai.v1.ContentBlock.
- The claude driver returns thinking and redacted thinking blocks as reasoning, and passes them back as thinking blocks.
  Since thinking blocks are bound to the tools offered, they are removed when no tools are offered (the final iteration).
- The tool call loop keeps reasoning in memory until the loop completes (it isn't added to the session),
  and message truncation removes all reasoning, since thinking blocks are bound to the history they were produced from.
- The admin Complete API removes reasoning from responses unless the client sets include_reasoning, for older runtimes.
- The gemini driver and the metrics view and canvas generators skip reasoning blocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pjain1 pjain1 changed the title fix: claude and gemini AI drivers for current models fix: claude and gemini AI drivers for current models, with Claude reasoning and opt-in prompt caching Oct 28, 2026
@pjain1
pjain1 requested a balanced review from Copilot October 29, 2026 04:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@nishantmonu51
nishantmonu51 self-requested a review October 29, 2026 07:57

@nishantmonu51 nishantmonu51 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This review was posted by an AI agent (OpenHands).

No material correctness, security, or design issues found in this head. Reviewed driver conversion, reasoning lifetime and truncation, admin backward compatibility, and cache-write token propagation.

Focused Go tests passed in runtime/drivers/claude, runtime/drivers/gemini, runtime/drivers/openai, runtime/ai, and admin/server, covering temperature, schema preservation, caching, reasoning round-trips, truncation, and legacy response stripping. All 16 current GitHub checks passed. Provider requests were exercised through fake servers; I did not validate against live model APIs.

✅ APPROVED

LLM profile: unknown · Model: gpt-6-astra

@nishantmonu51
nishantmonu51 merged commit 2bb80c0 into main Oct 29, 2026
17 checks passed
@nishantmonu51
nishantmonu51 deleted the paragjain/fix-ai-drivers-current-models branch October 29, 2026 10:18
nishantmonu51 pushed a commit that referenced this pull request Oct 29, 2026
… reasoning and opt-in prompt caching (#10073)

* fix: AI drivers for current Claude, OpenAI, and Gemini models

- claude: only send temperature if configured (current models reject it),
  keep $defs in tool schemas (the SDK type dropped every key except type/properties/required),
  and stop turning thinking blocks into (empty) text blocks, which the API rejects on the next tool loop iteration
- openai: only send temperature if configured (reasoning models reject it unless reasoning effort is "none")
- gemini: only send temperature if configured (Google warns lower values cause looping on Gemini 3)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* revert: keep the default OpenAI temperature

Not sending temperature by default changed sampling for the default setup (gpt-5.2 accepts temperature)
from 0.1 to OpenAI's default of 1.0, including Rill-managed AI, while the failing case (reasoning models)
already has a workaround: setting reasoning_effort omits temperature.
Documents that workaround and tests the existing behavior instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: opt-in prompt caching for Claude and cache write reporting

- Adds a `prompt_caching` option to the `claude` connector (off by default) that marks the tools,
  system prompt, and conversation as cache breakpoints, so later steps of a tool loop read them from the prompt cache.
  Rill-managed AI can enable it with RILL_ADMIN_CLAUDE_PROMPT_CACHING.
- Reports cache writes (Claude bills them at a premium) as a new CompleteResult.CacheWriteInputTokens field,
  passed through the admin Complete API and emitted as a cache_write_input_tokens metric.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat: pass Claude's reasoning back within the tool call loop

Claude requires thinking blocks to be passed back unmodified within a tool call loop.
- Adds a Reasoning content block (text, signature, or redacted data) to rill.ai.v1.ContentBlock.
- The claude driver returns thinking and redacted thinking blocks as reasoning, and passes them back as thinking blocks.
  Since thinking blocks are bound to the tools offered, they are removed when no tools are offered (the final iteration).
- The tool call loop keeps reasoning in memory until the loop completes (it isn't added to the session),
  and message truncation removes all reasoning, since thinking blocks are bound to the history they were produced from.
- The admin Complete API removes reasoning from responses unless the client sets include_reasoning, for older runtimes.
- The gemini driver and the metrics view and canvas generators skip reasoning blocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 2bb80c0)
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.

3 participants