ruby_llm-bedrock_invoke 0.1.0.pre.1 → 0.1.0.pre.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 911a2cdfef791e621f685c7560906cd38bb3c6362303d7a488799617c0a66d65
4
- data.tar.gz: 76efc4ffcf2932e7baf423a9498044f9e47eccc9bb478bd56f75adb4f3c1f95f
3
+ metadata.gz: 2f11b9070aa14278c81991a58dfb1cf31c6a7c500db12d4c0396587a668c1185
4
+ data.tar.gz: 164e91d6fe0957ee43122ca891b3652110f5ecf795d21eb51d19881904b28968
5
5
  SHA512:
6
- metadata.gz: b5c1b976369f15fc99ad75f1b6661fda71ec07ceafc2db7595af8d8ad159525c152dd5b9f22187c43b389813b8d14e5b9346e4f8fb21cd818a7f61013635ffe0
7
- data.tar.gz: 0c03c773fb9f8ea9505a90734e677db5d3803c6c5aeeabe6e67574d0dc0dc6862f4c6f7fac90b6e27fb80d8bdfd4e0e82cc7c5f2b10886ce658b6b07bbf3f10b
6
+ metadata.gz: 73fee9053d1ff92e1cf064743f0462e1c1a1daa8361d94d71b09ddc186ec484c9e8d67af67554a75cce61306c4e55e6cc3460b248e378c8eece94b1320a5d73d
7
+ data.tar.gz: 48721d75269e23c872208d6edb39613cdd98c68fbe5700e2f7171a1162a9dc0c06b0ce470af008c3ae07de2dcdc84308143c09d1c85cdd2bf17a040524106960
@@ -51,10 +51,27 @@ module RubyLLM
51
51
  return payload unless definitions.any? { |d| deferred_definition?(d) }
52
52
 
53
53
  inject_search_tool!(definitions)
54
+ mark_cache_breakpoint!(definitions)
54
55
  payload[:anthropic_beta] = Array(payload[:anthropic_beta]) | [BETA_FLAG]
55
56
  payload
56
57
  end
57
58
 
59
+ # Cache the eager (non-deferred) tool-definitions prefix. Deferred tools
60
+ # can't carry cache_control (the API returns 400) and are excluded from the
61
+ # cached prefix anyway, so the breakpoint goes on the last NON-deferred
62
+ # tool. This preserves prompt caching across turns (the discovered tools
63
+ # load inline as tool_reference blocks, never touching this prefix) and,
64
+ # crucially, gives the request the >=1 cache_control marker that turns on
65
+ # the API's automatic caching of server tool-search results.
66
+ def mark_cache_breakpoint!(definitions)
67
+ return if definitions.any? { |d| d.is_a?(Hash) && definition_value(d, :cache_control) }
68
+
69
+ last_eager = definitions.reverse.find { |d| d.is_a?(Hash) && !deferred_definition?(d) }
70
+ return unless last_eager
71
+
72
+ last_eager[:cache_control] = { type: 'ephemeral' }
73
+ end
74
+
58
75
  # Both generations deep-merge user params (with_params /
59
76
  # with_provider_options) over the rendered payload AFTER apply! runs,
60
77
  # and deep_merge REPLACES arrays — silently dropping the beta flag.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RubyLLM
4
4
  module BedrockInvoke
5
- VERSION = '0.1.0.pre.1'
5
+ VERSION = '0.1.0.pre.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_llm-bedrock_invoke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.1
4
+ version: 0.1.0.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Petersen