feat: allow disabling prompt caching per model via a0_explicit_caching kwarg#1654
Open
akshay-sood wants to merge 1 commit into
Open
feat: allow disabling prompt caching per model via a0_explicit_caching kwarg#1654akshay-sood wants to merge 1 commit into
akshay-sood wants to merge 1 commit into
Conversation
…g kwarg Models that don't support prompt caching (e.g. NVIDIA Nemotron on Bedrock) fail with 403 errors when cache_control headers are present in messages. This adds support for a new model kwarg `a0_explicit_caching: false` that can be set in preset additional settings to disable prompt caching for specific models. The check is placed before _convert_messages() so cache_control markers are never injected into the message payload.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Models that don't support prompt caching (e.g. NVIDIA Nemotron on AWS Bedrock) fail with
403 Forbiddenerrors because Agent Zero unconditionally addscache_control: {type: 'ephemeral'}markers to messages viaexplicit_caching=Trueincall_chat_model().The Bedrock error message is:
Solution
Add support for a new model kwarg
a0_explicit_cachingthat, when set tofalse, disables prompt caching for that specific model. This allows users to configure it in their preset's Additional Settings:Or in
presets.yaml:Implementation
a0_explicit_cachingfrom model kwargs before_convert_messages()is called (critical ordering — must happen before cache_control markers are injected)False, overrideexplicit_cachingtoFalsefor that callcall_kwargsbefore passing to LiteLLMExample Use Case
NVIDIA Nemotron on Bedrock preset:
This follows the same pattern as existing A0-specific kwargs (
a0_retry_attempts,a0_retry_delay_seconds) that are stripped before reaching LiteLLM.Testing
nvidia.nemotron-super-3-120b) responds successfully with this fix