anthropic 1.48.2 → 1.49.0

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.
Files changed (212) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/README.md +1 -1
  4. data/lib/anthropic/client.rb +8 -2
  5. data/lib/anthropic/errors.rb +14 -0
  6. data/lib/anthropic/helpers/aws/client.rb +3 -3
  7. data/lib/anthropic/helpers/aws_auth.rb +39 -29
  8. data/lib/anthropic/helpers/bedrock/client.rb +99 -67
  9. data/lib/anthropic/helpers/bedrock/event_stream.rb +92 -0
  10. data/lib/anthropic/helpers/bedrock/mantle_client.rb +3 -3
  11. data/lib/anthropic/helpers/vertex/client.rb +99 -55
  12. data/lib/anthropic/internal/transport/base_client.rb +196 -33
  13. data/lib/anthropic/internal/util.rb +37 -1
  14. data/lib/anthropic/middleware.rb +435 -0
  15. data/lib/anthropic/models/beta/beta_advisor_tool_20260301.rb +3 -1
  16. data/lib/anthropic/models/beta/beta_code_execution_tool_20250522.rb +3 -1
  17. data/lib/anthropic/models/beta/beta_code_execution_tool_20250825.rb +3 -1
  18. data/lib/anthropic/models/beta/beta_code_execution_tool_20260120.rb +3 -1
  19. data/lib/anthropic/models/beta/beta_code_execution_tool_20260521.rb +86 -0
  20. data/lib/anthropic/models/beta/beta_content_block.rb +3 -3
  21. data/lib/anthropic/models/beta/beta_content_block_param.rb +10 -12
  22. data/lib/anthropic/models/beta/beta_fallback_block.rb +13 -5
  23. data/lib/anthropic/models/beta/beta_fallback_block_param.rb +22 -13
  24. data/lib/anthropic/models/beta/beta_fallback_refusal_trigger.rb +44 -0
  25. data/lib/anthropic/models/beta/beta_memory_tool_20250818.rb +3 -1
  26. data/lib/anthropic/models/beta/beta_raw_content_block_start_event.rb +3 -3
  27. data/lib/anthropic/models/beta/beta_refusal_stop_details.rb +3 -7
  28. data/lib/anthropic/models/beta/beta_tool.rb +3 -1
  29. data/lib/anthropic/models/beta/beta_tool_bash_20241022.rb +3 -1
  30. data/lib/anthropic/models/beta/beta_tool_bash_20250124.rb +3 -1
  31. data/lib/anthropic/models/beta/beta_tool_computer_use_20241022.rb +3 -1
  32. data/lib/anthropic/models/beta/beta_tool_computer_use_20250124.rb +3 -1
  33. data/lib/anthropic/models/beta/beta_tool_computer_use_20251124.rb +3 -1
  34. data/lib/anthropic/models/beta/beta_tool_search_tool_bm25_20251119.rb +3 -1
  35. data/lib/anthropic/models/beta/beta_tool_search_tool_regex_20251119.rb +3 -1
  36. data/lib/anthropic/models/beta/beta_tool_text_editor_20241022.rb +3 -1
  37. data/lib/anthropic/models/beta/beta_tool_text_editor_20250124.rb +3 -1
  38. data/lib/anthropic/models/beta/beta_tool_text_editor_20250429.rb +3 -1
  39. data/lib/anthropic/models/beta/beta_tool_text_editor_20250728.rb +3 -1
  40. data/lib/anthropic/models/beta/beta_tool_union.rb +4 -1
  41. data/lib/anthropic/models/beta/beta_web_fetch_tool_20250910.rb +3 -1
  42. data/lib/anthropic/models/beta/beta_web_fetch_tool_20260209.rb +3 -1
  43. data/lib/anthropic/models/beta/beta_web_fetch_tool_20260309.rb +3 -1
  44. data/lib/anthropic/models/beta/beta_web_search_tool_20250305.rb +3 -1
  45. data/lib/anthropic/models/beta/beta_web_search_tool_20260209.rb +3 -1
  46. data/lib/anthropic/models/beta/beta_webhook_event.rb +2 -2
  47. data/lib/anthropic/models/beta/beta_webhook_event_data.rb +3 -1
  48. data/lib/anthropic/models/beta/beta_webhook_session_updated_event_data.rb +41 -0
  49. data/lib/anthropic/models/beta/message_count_tokens_params.rb +6 -3
  50. data/lib/anthropic/models/beta/message_create_params.rb +2 -2
  51. data/lib/anthropic/models/beta/messages/batch_create_params.rb +2 -2
  52. data/lib/anthropic/models/beta/unwrap_webhook_event.rb +2 -2
  53. data/lib/anthropic/models/code_execution_tool_20250522.rb +3 -1
  54. data/lib/anthropic/models/code_execution_tool_20250825.rb +3 -1
  55. data/lib/anthropic/models/code_execution_tool_20260120.rb +3 -1
  56. data/lib/anthropic/models/code_execution_tool_20260521.rb +82 -0
  57. data/lib/anthropic/models/memory_tool_20250818.rb +3 -1
  58. data/lib/anthropic/models/message_count_tokens_params.rb +2 -2
  59. data/lib/anthropic/models/message_count_tokens_tool.rb +4 -1
  60. data/lib/anthropic/models/message_create_params.rb +2 -2
  61. data/lib/anthropic/models/messages/batch_create_params.rb +2 -2
  62. data/lib/anthropic/models/refusal_stop_details.rb +3 -7
  63. data/lib/anthropic/models/tool.rb +3 -1
  64. data/lib/anthropic/models/tool_bash_20250124.rb +3 -1
  65. data/lib/anthropic/models/tool_search_tool_bm25_20251119.rb +3 -1
  66. data/lib/anthropic/models/tool_search_tool_regex_20251119.rb +3 -1
  67. data/lib/anthropic/models/tool_text_editor_20250124.rb +3 -1
  68. data/lib/anthropic/models/tool_text_editor_20250429.rb +3 -1
  69. data/lib/anthropic/models/tool_text_editor_20250728.rb +3 -1
  70. data/lib/anthropic/models/tool_union.rb +4 -1
  71. data/lib/anthropic/models/web_fetch_tool_20250910.rb +3 -1
  72. data/lib/anthropic/models/web_fetch_tool_20260209.rb +3 -1
  73. data/lib/anthropic/models/web_fetch_tool_20260309.rb +3 -1
  74. data/lib/anthropic/models/web_search_tool_20250305.rb +3 -1
  75. data/lib/anthropic/models/web_search_tool_20260209.rb +3 -1
  76. data/lib/anthropic/models.rb +2 -0
  77. data/lib/anthropic/request_options.rb +9 -0
  78. data/lib/anthropic/resources/beta/messages.rb +3 -3
  79. data/lib/anthropic/resources/messages.rb +3 -3
  80. data/lib/anthropic/version.rb +1 -1
  81. data/lib/anthropic.rb +6 -0
  82. data/rbi/anthropic/client.rbi +7 -2
  83. data/rbi/anthropic/errors.rbi +5 -0
  84. data/rbi/anthropic/helpers/aws/client.rbi +3 -6
  85. data/rbi/anthropic/helpers/bedrock/client.rbi +24 -13
  86. data/rbi/anthropic/helpers/bedrock/event_stream.rbi +25 -0
  87. data/rbi/anthropic/helpers/bedrock/mantle_client.rbi +3 -6
  88. data/rbi/anthropic/helpers/vertex/client.rbi +28 -8
  89. data/rbi/anthropic/internal/transport/base_client.rbi +39 -4
  90. data/rbi/anthropic/internal/util.rbi +5 -0
  91. data/rbi/anthropic/middleware.rbi +338 -0
  92. data/rbi/anthropic/models/beta/beta_advisor_tool_20260301.rbi +7 -1
  93. data/rbi/anthropic/models/beta/beta_code_execution_tool_20250522.rbi +7 -1
  94. data/rbi/anthropic/models/beta/beta_code_execution_tool_20250825.rbi +7 -1
  95. data/rbi/anthropic/models/beta/beta_code_execution_tool_20260120.rbi +7 -1
  96. data/rbi/anthropic/models/beta/beta_code_execution_tool_20260521.rbi +178 -0
  97. data/rbi/anthropic/models/beta/beta_fallback_block.rbi +19 -4
  98. data/rbi/anthropic/models/beta/beta_fallback_block_param.rbi +23 -13
  99. data/rbi/anthropic/models/beta/beta_fallback_refusal_trigger.rbi +108 -0
  100. data/rbi/anthropic/models/beta/beta_memory_tool_20250818.rbi +7 -1
  101. data/rbi/anthropic/models/beta/beta_refusal_stop_details.rbi +3 -9
  102. data/rbi/anthropic/models/beta/beta_tool.rbi +7 -1
  103. data/rbi/anthropic/models/beta/beta_tool_bash_20241022.rbi +7 -1
  104. data/rbi/anthropic/models/beta/beta_tool_bash_20250124.rbi +7 -1
  105. data/rbi/anthropic/models/beta/beta_tool_computer_use_20241022.rbi +7 -1
  106. data/rbi/anthropic/models/beta/beta_tool_computer_use_20250124.rbi +7 -1
  107. data/rbi/anthropic/models/beta/beta_tool_computer_use_20251124.rbi +7 -1
  108. data/rbi/anthropic/models/beta/beta_tool_search_tool_bm25_20251119.rbi +7 -1
  109. data/rbi/anthropic/models/beta/beta_tool_search_tool_regex_20251119.rbi +7 -1
  110. data/rbi/anthropic/models/beta/beta_tool_text_editor_20241022.rbi +7 -1
  111. data/rbi/anthropic/models/beta/beta_tool_text_editor_20250124.rbi +7 -1
  112. data/rbi/anthropic/models/beta/beta_tool_text_editor_20250429.rbi +7 -1
  113. data/rbi/anthropic/models/beta/beta_tool_text_editor_20250728.rbi +7 -1
  114. data/rbi/anthropic/models/beta/beta_tool_union.rbi +1 -0
  115. data/rbi/anthropic/models/beta/beta_web_fetch_tool_20250910.rbi +7 -1
  116. data/rbi/anthropic/models/beta/beta_web_fetch_tool_20260209.rbi +7 -1
  117. data/rbi/anthropic/models/beta/beta_web_fetch_tool_20260309.rbi +7 -1
  118. data/rbi/anthropic/models/beta/beta_web_search_tool_20250305.rbi +7 -1
  119. data/rbi/anthropic/models/beta/beta_web_search_tool_20260209.rbi +7 -1
  120. data/rbi/anthropic/models/beta/beta_webhook_event.rbi +6 -3
  121. data/rbi/anthropic/models/beta/beta_webhook_event_data.rbi +2 -1
  122. data/rbi/anthropic/models/beta/beta_webhook_session_updated_event_data.rbi +63 -0
  123. data/rbi/anthropic/models/beta/message_count_tokens_params.rbi +5 -0
  124. data/rbi/anthropic/models/beta/message_create_params.rbi +4 -0
  125. data/rbi/anthropic/models/beta/messages/batch_create_params.rbi +4 -0
  126. data/rbi/anthropic/models/beta/unwrap_webhook_event.rbi +2 -1
  127. data/rbi/anthropic/models/code_execution_tool_20250522.rbi +7 -1
  128. data/rbi/anthropic/models/code_execution_tool_20250825.rbi +7 -1
  129. data/rbi/anthropic/models/code_execution_tool_20260120.rbi +7 -1
  130. data/rbi/anthropic/models/code_execution_tool_20260521.rbi +168 -0
  131. data/rbi/anthropic/models/memory_tool_20250818.rbi +7 -1
  132. data/rbi/anthropic/models/message_count_tokens_params.rbi +4 -0
  133. data/rbi/anthropic/models/message_count_tokens_tool.rbi +1 -0
  134. data/rbi/anthropic/models/message_create_params.rbi +4 -0
  135. data/rbi/anthropic/models/messages/batch_create_params.rbi +4 -0
  136. data/rbi/anthropic/models/refusal_stop_details.rbi +3 -9
  137. data/rbi/anthropic/models/tool.rbi +7 -1
  138. data/rbi/anthropic/models/tool_bash_20250124.rbi +7 -1
  139. data/rbi/anthropic/models/tool_search_tool_bm25_20251119.rbi +7 -1
  140. data/rbi/anthropic/models/tool_search_tool_regex_20251119.rbi +7 -1
  141. data/rbi/anthropic/models/tool_text_editor_20250124.rbi +7 -1
  142. data/rbi/anthropic/models/tool_text_editor_20250429.rbi +7 -1
  143. data/rbi/anthropic/models/tool_text_editor_20250728.rbi +7 -1
  144. data/rbi/anthropic/models/tool_union.rbi +1 -0
  145. data/rbi/anthropic/models/web_fetch_tool_20250910.rbi +7 -1
  146. data/rbi/anthropic/models/web_fetch_tool_20260209.rbi +7 -1
  147. data/rbi/anthropic/models/web_fetch_tool_20260309.rbi +7 -1
  148. data/rbi/anthropic/models/web_search_tool_20250305.rbi +7 -1
  149. data/rbi/anthropic/models/web_search_tool_20260209.rbi +7 -1
  150. data/rbi/anthropic/models.rbi +2 -0
  151. data/rbi/anthropic/request_options.rbi +5 -0
  152. data/rbi/anthropic/resources/beta/messages.rbi +3 -0
  153. data/rbi/anthropic/resources/messages.rbi +3 -0
  154. data/sig/anthropic/client.rbs +2 -1
  155. data/sig/anthropic/errors.rbs +3 -0
  156. data/sig/anthropic/helpers/bedrock/client.rbs +12 -4
  157. data/sig/anthropic/helpers/vertex/client.rbs +17 -4
  158. data/sig/anthropic/internal/transport/base_client.rbs +18 -3
  159. data/sig/anthropic/internal/util.rbs +2 -0
  160. data/sig/anthropic/middleware.rbs +117 -0
  161. data/sig/anthropic/models/beta/beta_advisor_tool_20260301.rbs +5 -1
  162. data/sig/anthropic/models/beta/beta_code_execution_tool_20250522.rbs +5 -1
  163. data/sig/anthropic/models/beta/beta_code_execution_tool_20250825.rbs +5 -1
  164. data/sig/anthropic/models/beta/beta_code_execution_tool_20260120.rbs +5 -1
  165. data/sig/anthropic/models/beta/beta_code_execution_tool_20260521.rbs +74 -0
  166. data/sig/anthropic/models/beta/beta_fallback_block.rbs +5 -0
  167. data/sig/anthropic/models/beta/beta_fallback_block_param.rbs +9 -2
  168. data/sig/anthropic/models/beta/beta_fallback_refusal_trigger.rbs +42 -0
  169. data/sig/anthropic/models/beta/beta_memory_tool_20250818.rbs +5 -1
  170. data/sig/anthropic/models/beta/beta_tool.rbs +5 -1
  171. data/sig/anthropic/models/beta/beta_tool_bash_20241022.rbs +5 -1
  172. data/sig/anthropic/models/beta/beta_tool_bash_20250124.rbs +5 -1
  173. data/sig/anthropic/models/beta/beta_tool_computer_use_20241022.rbs +5 -1
  174. data/sig/anthropic/models/beta/beta_tool_computer_use_20250124.rbs +5 -1
  175. data/sig/anthropic/models/beta/beta_tool_computer_use_20251124.rbs +5 -1
  176. data/sig/anthropic/models/beta/beta_tool_search_tool_bm25_20251119.rbs +5 -1
  177. data/sig/anthropic/models/beta/beta_tool_search_tool_regex_20251119.rbs +5 -1
  178. data/sig/anthropic/models/beta/beta_tool_text_editor_20241022.rbs +5 -1
  179. data/sig/anthropic/models/beta/beta_tool_text_editor_20250124.rbs +5 -1
  180. data/sig/anthropic/models/beta/beta_tool_text_editor_20250429.rbs +5 -1
  181. data/sig/anthropic/models/beta/beta_tool_text_editor_20250728.rbs +5 -1
  182. data/sig/anthropic/models/beta/beta_tool_union.rbs +1 -0
  183. data/sig/anthropic/models/beta/beta_web_fetch_tool_20250910.rbs +5 -1
  184. data/sig/anthropic/models/beta/beta_web_fetch_tool_20260209.rbs +5 -1
  185. data/sig/anthropic/models/beta/beta_web_fetch_tool_20260309.rbs +5 -1
  186. data/sig/anthropic/models/beta/beta_web_search_tool_20250305.rbs +5 -1
  187. data/sig/anthropic/models/beta/beta_web_search_tool_20260209.rbs +5 -1
  188. data/sig/anthropic/models/beta/beta_webhook_event_data.rbs +1 -0
  189. data/sig/anthropic/models/beta/beta_webhook_session_updated_event_data.rbs +39 -0
  190. data/sig/anthropic/models/beta/message_count_tokens_params.rbs +1 -0
  191. data/sig/anthropic/models/code_execution_tool_20250522.rbs +5 -1
  192. data/sig/anthropic/models/code_execution_tool_20250825.rbs +5 -1
  193. data/sig/anthropic/models/code_execution_tool_20260120.rbs +5 -1
  194. data/sig/anthropic/models/code_execution_tool_20260521.rbs +70 -0
  195. data/sig/anthropic/models/memory_tool_20250818.rbs +5 -1
  196. data/sig/anthropic/models/message_count_tokens_tool.rbs +1 -0
  197. data/sig/anthropic/models/tool.rbs +5 -1
  198. data/sig/anthropic/models/tool_bash_20250124.rbs +5 -1
  199. data/sig/anthropic/models/tool_search_tool_bm25_20251119.rbs +5 -1
  200. data/sig/anthropic/models/tool_search_tool_regex_20251119.rbs +5 -1
  201. data/sig/anthropic/models/tool_text_editor_20250124.rbs +5 -1
  202. data/sig/anthropic/models/tool_text_editor_20250429.rbs +5 -1
  203. data/sig/anthropic/models/tool_text_editor_20250728.rbs +5 -1
  204. data/sig/anthropic/models/tool_union.rbs +1 -0
  205. data/sig/anthropic/models/web_fetch_tool_20250910.rbs +5 -1
  206. data/sig/anthropic/models/web_fetch_tool_20260209.rbs +5 -1
  207. data/sig/anthropic/models/web_fetch_tool_20260309.rbs +5 -1
  208. data/sig/anthropic/models/web_search_tool_20250305.rbs +5 -1
  209. data/sig/anthropic/models/web_search_tool_20260209.rbs +5 -1
  210. data/sig/anthropic/models.rbs +2 -0
  211. data/sig/anthropic/request_options.rbs +4 -1
  212. metadata +19 -2
@@ -0,0 +1,435 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ # The per-attempt request object a middleware sees.
5
+ #
6
+ # Fields mirror what resource methods pass to `BaseClient#request` (see
7
+ # `RequestComponents`), with `path`/`query` resolved to a `URI::Generic`,
8
+ # headers fully normalized, and `retry_count`/`metadata` added.
9
+ #
10
+ # `body` is the **canonical** Anthropic request body — for JSON endpoints
11
+ # (`POST /v1/messages` etc.) a `Hash` like `{model:, messages:, max_tokens:}`,
12
+ # `nil` for body-less methods. It is *not* a serialized `String`: JSON
13
+ # encoding, 3p-provider rewrite (Bedrock/Vertex), and request signing all
14
+ # happen inside `nxt.call`, so a middleware that edits `body` via
15
+ # `req.with(body: ...)` does not need to re-serialize.
16
+ #
17
+ # Instances are frozen and the `headers`/`body`/`url`/`options` values the
18
+ # SDK supplies are deep-frozen — mutating them or any nested `Hash`/`Array`
19
+ # (e.g. `body[:messages]`) raises. Use {#with} to derive a copy. `metadata`
20
+ # is the one intentionally shared, mutable scratchpad that persists across
21
+ # retry attempts.
22
+ class APIRequest
23
+ # @api private
24
+ MEMBERS =
25
+ [:method, :url, :headers, :body, :stream, :cast_to, :unwrap, :options, :retry_count, :metadata].freeze
26
+
27
+ # @return [Symbol] the HTTP method (`:get`, `:post`, …)
28
+ attr_reader :method
29
+
30
+ # @return [URI::Generic] the resolved request URL (deep-frozen)
31
+ attr_reader :url
32
+
33
+ # @return [Hash{String=>String}] normalized request headers (deep-frozen)
34
+ attr_reader :headers
35
+
36
+ # @return [Object, nil] the canonical request body — usually a
37
+ # `Hash{Symbol=>Object}` for JSON endpoints, `nil` for body-less, but may
38
+ # be a `String`/`IO` for upload paths (see class doc; deep-frozen where
39
+ # structurally copyable)
40
+ attr_reader :body
41
+
42
+ # @return [Class, nil] the SSE stream class to decode into; `nil` for
43
+ # non-streaming
44
+ attr_reader :stream
45
+
46
+ # @return [Anthropic::Internal::Type::Converter::Input, nil] the model
47
+ # class the response body will be coerced to; `nil` for paginated
48
+ # requests
49
+ attr_reader :cast_to
50
+
51
+ # @return [Symbol, Integer, Array<Symbol, Integer>, Proc, nil] the envelope
52
+ # key(s) the SDK digs out of the decoded body before coercing
53
+ attr_reader :unwrap
54
+
55
+ # @return [Hash{Symbol=>Object}] request options (`:timeout`, …;
56
+ # deep-frozen)
57
+ attr_reader :options
58
+
59
+ # @return [Integer] number of prior attempts (`0` on the first)
60
+ attr_reader :retry_count
61
+
62
+ # @return [Hash{Symbol=>Object}] mutable cross-attempt scratchpad shared
63
+ # between retries
64
+ attr_reader :metadata
65
+
66
+ # @param method [Symbol]
67
+ # @param url [URI::Generic]
68
+ # @param headers [Hash{String=>String}]
69
+ # @param body [Object, nil]
70
+ # @param stream [Class, nil]
71
+ # @param cast_to [Anthropic::Internal::Type::Converter::Input, nil]
72
+ # @param unwrap [Symbol, Integer, Array<Symbol, Integer>, Proc, nil]
73
+ # @param options [Hash{Symbol=>Object}]
74
+ # @param retry_count [Integer]
75
+ # @param metadata [Hash{Symbol=>Object}]
76
+ def initialize(
77
+ method:,
78
+ url:,
79
+ headers:,
80
+ body:,
81
+ stream:,
82
+ cast_to:,
83
+ unwrap:,
84
+ options:,
85
+ retry_count:,
86
+ metadata:
87
+ )
88
+ @method = method
89
+ @url = url
90
+ @headers = headers
91
+ @body = body
92
+ @stream = stream
93
+ @cast_to = cast_to
94
+ @unwrap = unwrap
95
+ @options = options
96
+ @retry_count = retry_count
97
+ @metadata = metadata
98
+ freeze
99
+ end
100
+
101
+ # @return [Boolean] whether the SDK call is a streaming/SSE request
102
+ def streaming? = !@stream.nil?
103
+
104
+ # @return [Boolean] whether this is a retry attempt (`retry_count > 0`)
105
+ def retry? = @retry_count.positive?
106
+
107
+ # @return [Float] the request timeout in seconds. Informational only — the
108
+ # transport deadline is fixed when the SDK enters the middleware
109
+ # terminal, so deriving a request via `with(options: {timeout: …})` does
110
+ # not change it. Time spent inside middleware does not count against it.
111
+ def timeout = @options.to_h.fetch(:timeout, 0.0)
112
+
113
+ # Derive a copy with the given members replaced.
114
+ #
115
+ # @param method [Symbol]
116
+ # @param url [URI::Generic]
117
+ # @param headers [Hash{String=>String}]
118
+ # @param body [Object, nil]
119
+ # @param stream [Class, nil]
120
+ # @param cast_to [Anthropic::Internal::Type::Converter::Input, nil]
121
+ # @param unwrap [Symbol, Integer, Array<Symbol, Integer>, Proc, nil]
122
+ # @param options [Hash{Symbol=>Object}]
123
+ # @param retry_count [Integer]
124
+ # @param metadata [Hash{Symbol=>Object}]
125
+ # @return [Anthropic::APIRequest]
126
+ def with(**changes)
127
+ unknown = changes.keys - MEMBERS
128
+ unless unknown.empty?
129
+ raise ArgumentError,
130
+ "unknown keyword#{'s' if unknown.length > 1}: #{unknown.map(&:inspect).join(', ')}"
131
+ end
132
+ self.class.new(**to_h, **changes)
133
+ end
134
+
135
+ # @return [Hash{Symbol=>Object}]
136
+ def to_h = MEMBERS.to_h { [_1, instance_variable_get(:"@#{_1}")] }
137
+ end
138
+
139
+ # The per-attempt response object a middleware sees.
140
+ #
141
+ # `nxt.call(req)` returns an `APIResponse` for **all** HTTP status codes —
142
+ # 4xx and 5xx included. It does **not** raise on error status; the SDK
143
+ # converts to a typed `APIError` only after the chain completes. This lets a
144
+ # middleware inspect `res.status` on a 5xx and choose to substitute, retry
145
+ # differently, or pass through. Connection-level failures
146
+ # ({Anthropic::Errors::APITimeoutError}, {Anthropic::Errors::APIConnectionError})
147
+ # **do** raise from `nxt.call`.
148
+ class APIResponse
149
+ # Raised when a middleware returns an {APIResponse} whose body enumerator was
150
+ # already consumed without first calling {APIResponse#buffer!}. The SDK cannot
151
+ # parse a drained, unbuffered body. Fix by calling `res.buffer!` (or
152
+ # `res.parse`) before reading, or by using `res.wrap_body` to transform the
153
+ # stream without consuming it.
154
+ class ConsumedBodyError < Anthropic::Errors::Error
155
+ end
156
+
157
+ # @return [Integer] HTTP status code
158
+ attr_reader :status
159
+
160
+ # @return [Hash{String=>String}] normalized response headers
161
+ attr_reader :headers
162
+
163
+ # @return [Net::HTTPResponse, nil] the raw response. `nil` for an
164
+ # `APIResponse.new(...)` constructed by a middleware (e.g. a mock).
165
+ attr_reader :raw
166
+
167
+ # @return [Anthropic::APIRequest, nil] the request that produced this
168
+ # response. {#parse} uses it to recover the SDK return type; a fabricated
169
+ # response without one parses to the decoded body only.
170
+ attr_reader :request
171
+
172
+ # @api private
173
+ #
174
+ # Wraps the `[status, Net::HTTPResponse, Enumerable<String>]` tuple the
175
+ # pooled requester returns.
176
+ #
177
+ # @param status [Integer]
178
+ # @param raw [Net::HTTPResponse]
179
+ # @param stream [Enumerable<String>]
180
+ # @param request [Anthropic::APIRequest, nil]
181
+ # @return [Anthropic::APIResponse]
182
+ def self.wrap(status, raw, stream, request: nil)
183
+ # `initialize` normalizes `headers`, so pass the raw header hash straight
184
+ # through rather than normalizing twice on every response.
185
+ new(status: status, headers: raw.each_header.to_h, body: stream, raw: raw, request: request)
186
+ end
187
+
188
+ # @param status [Integer]
189
+ # @param headers [Hash{String=>String}]
190
+ # @param body [Enumerable<String>, String, nil]
191
+ # @param raw [Net::HTTPResponse, nil]
192
+ # @param streaming [Boolean, nil] override `streaming?`; inferred from
193
+ # `request` if `nil`
194
+ # @param request [Anthropic::APIRequest, nil]
195
+ def initialize(status:, headers: {}, body: nil, raw: nil, streaming: nil, request: nil)
196
+ @status = status
197
+ @headers = Anthropic::Internal::Util.normalized_headers(headers)
198
+ @raw = raw
199
+ @request = request
200
+ @streaming = streaming
201
+ @buffered = nil
202
+ @drained = false
203
+ @parsed = Anthropic::Internal::OMIT
204
+
205
+ @body =
206
+ case body
207
+ in nil
208
+ @buffered = [].freeze
209
+ in String
210
+ @buffered = [body].freeze
211
+ in Array
212
+ @buffered = body.dup.freeze
213
+ else
214
+ # Wrap once so the first pull flips `@drained`; `to_tuple`/`buffer!`
215
+ # then detect a body that was iterated without buffering. Fused so
216
+ # `Util.close_fused!` (stream `close`, connection reaping) propagates
217
+ # to the upstream enum without first pulling a chunk off the socket.
218
+ Anthropic::Internal::Util.chain_fused(body) do |y|
219
+ @drained = true
220
+ body.each { y << _1 }
221
+ end
222
+ end
223
+ end
224
+
225
+ # @return [Enumerable<String>] the response body. **Single-consumer**
226
+ # unless {#buffer!} has been called. After `buffer!`, this is a
227
+ # rewindable `Array`.
228
+ def body = @buffered || @body
229
+
230
+ # @return [Boolean] whether the request that produced this response is a
231
+ # streaming/SSE request.
232
+ def streaming?
233
+ return @streaming unless @streaming.nil?
234
+ @request&.streaming? || false
235
+ end
236
+
237
+ # @return [Boolean] whether the SDK would retry this status under its
238
+ # default policy — parity with the Python SDK's `Response.is_retryable`.
239
+ # Useful for middleware that wants to match the SDK's own retry decision.
240
+ def retryable?
241
+ Anthropic::Internal::Transport::BaseClient.should_retry?(@status, headers: @headers)
242
+ end
243
+
244
+ # Drain the body into memory so it can be re-read. Idempotent once
245
+ # buffered.
246
+ #
247
+ # @param force [Boolean] allow buffering a streaming response. By default
248
+ # this raises because buffering an SSE stream defeats streaming; pass
249
+ # `force: true` if you know the stream is bounded.
250
+ # @return [self]
251
+ # @raise [ArgumentError] if `streaming?` and `force` is false.
252
+ # @raise [Anthropic::APIResponse::ConsumedBodyError] if the body was
253
+ # already drained by a raw `body.each` without buffering.
254
+ def buffer!(force: false)
255
+ return self if @buffered
256
+
257
+ if streaming? && !force
258
+ raise ArgumentError,
259
+ "Refusing to buffer a streaming response; pass `force: true` " \
260
+ "or use `wrap_body` to transform the stream without buffering."
261
+ end
262
+
263
+ if @drained
264
+ raise ConsumedBodyError,
265
+ "Response body was already consumed. Call `buffer!` (or " \
266
+ "`parse`) before reading the body, or use `wrap_body` to " \
267
+ "transform the stream without consuming it."
268
+ end
269
+
270
+ @buffered = @body.to_a.freeze
271
+ @drained = true
272
+ self
273
+ end
274
+
275
+ # Replace the body with the block's return value — the composable way to
276
+ # intercept streamed chunks without buffering.
277
+ #
278
+ # @param streaming [Boolean] value for the new response's `streaming?`.
279
+ # Pass `false` if the wrapper collapses the stream to a buffered body.
280
+ # @yieldparam upstream [Enumerable<String>]
281
+ # @yieldreturn [Enumerable<String>]
282
+ # @return [Anthropic::APIResponse]
283
+ def wrap_body(streaming: streaming?)
284
+ raise ArgumentError, "wrap_body requires a block" unless block_given?
285
+ self.class.new(
286
+ status: @status,
287
+ headers: @headers,
288
+ body: yield(body),
289
+ raw: @raw,
290
+ streaming: streaming,
291
+ request: @request
292
+ )
293
+ end
294
+
295
+ # Decode and coerce the body to the SDK-typed result the original caller
296
+ # would have received (e.g. `Anthropic::Message`). Internally `buffer!`s
297
+ # first, so calling `parse` does not steal the body from downstream — the
298
+ # SDK reuses the buffered copy.
299
+ #
300
+ # For non-streaming responses the decoded value is coerced to the request's
301
+ # return type and memoized — repeated calls across the chain cost a single
302
+ # decode. A fabricated response without a `request:` parses to the decoded
303
+ # body (e.g. a `Hash`) instead of an SDK model.
304
+ #
305
+ # For streaming requests, returns a typed stream reading an independent
306
+ # buffered copy of the response body — iterating (or `break`ing out of) it
307
+ # neither consumes nor cancels the events the SDK caller will read. Streams
308
+ # are single-consumer, so each call returns a fresh stream rather than a
309
+ # memoized one.
310
+ #
311
+ # @example
312
+ # usage_logger = lambda do |req, nxt|
313
+ # res = nxt.call(req)
314
+ # LOGGER.info("usage: #{res.parse.usage}") if res.status < 300
315
+ # res
316
+ # end
317
+ #
318
+ # @return [Object]
319
+ def parse
320
+ return parse_stream if streaming?
321
+ return @parsed unless Anthropic::Internal::OMIT.equal?(@parsed)
322
+
323
+ buffer!
324
+ decoded = Anthropic::Internal::Util.decode_content(@headers, stream: body.each)
325
+ unwrapped = Anthropic::Internal::Util.dig(decoded, @request&.unwrap)
326
+ cast_to = @request&.cast_to || Anthropic::Internal::Type::Unknown
327
+ @parsed = Anthropic::Internal::Type::Converter.coerce(cast_to, unwrapped)
328
+ end
329
+
330
+ # @api private
331
+ #
332
+ # Back to the `[Integer, Net::HTTPResponse|nil, Hash, Enumerable<String>]`
333
+ # tuple shape `send_request` works with internally. Headers come from
334
+ # {#headers} — never re-derived from `raw` — so a middleware that returns
335
+ # a modified header set over the original raw response is honored.
336
+ #
337
+ # @return [Array(Integer, Net::HTTPResponse|nil, Hash{String=>String}, Enumerable<String>)]
338
+ def to_tuple
339
+ if @buffered.nil? && @drained
340
+ raise ConsumedBodyError,
341
+ "Middleware consumed the response body without buffering it. " \
342
+ "Call `buffer!` (or `parse`) before reading, or use `wrap_body`."
343
+ end
344
+ [status, @raw, @headers, @buffered || @body]
345
+ end
346
+
347
+ private
348
+
349
+ # A fresh typed stream over a buffered copy of the response body.
350
+ #
351
+ # @return [Anthropic::Internal::Type::BaseStream, Enumerable]
352
+ def parse_stream
353
+ buffer!(force: true)
354
+ decoded = Anthropic::Internal::Util.decode_content(@headers, stream: body.each)
355
+ stream = @request&.stream
356
+ return decoded unless stream
357
+
358
+ stream.new(
359
+ model: @request.cast_to,
360
+ url: @request.url,
361
+ status: status,
362
+ headers: @headers,
363
+ response: @raw,
364
+ unwrap: @request.unwrap,
365
+ stream: decoded
366
+ )
367
+ end
368
+ end
369
+
370
+ # HTTP around-middleware.
371
+ #
372
+ # A middleware is any object that responds to `#call(request, nxt)` and
373
+ # returns an {Anthropic::APIResponse}. `nxt` is itself a `#call(request)`-able
374
+ # that invokes the rest of the chain and, ultimately, a single HTTP attempt.
375
+ # The chain runs **per attempt, inside the SDK's retry loop** — the same
376
+ # placement as Go, TypeScript, Java, and Python.
377
+ #
378
+ # Register middleware at the client level via `Anthropic::Client.new(middleware: [...])`,
379
+ # or per request via `request_options: {middleware: [...]}`. Request-level
380
+ # entries run innermost (below client-level entries), so client-level
381
+ # middleware still wraps every request a per-call middleware fabricates or
382
+ # retries.
383
+ #
384
+ # On provider clients (Bedrock/Vertex/AWS), a provider middleware is
385
+ # appended below all user entries on every dispatch: it rewrites the
386
+ # canonical request into the provider's wire shape and applies provider
387
+ # auth (SigV4/OAuth), so user middleware always sees the canonical
388
+ # Anthropic request and every re-issued or retried leg is re-signed.
389
+ #
390
+ # @example
391
+ # log = ->(req, nxt) { res = nxt.call(req); LOGGER.info(res.status); res }
392
+ # Anthropic::Client.new(middleware: [log])
393
+ module Middleware
394
+ # Optional mixin that names the middleware contract for users who prefer a
395
+ # class to a lambda. `include Anthropic::Middleware` and implement
396
+ # `#call(request, nxt)`. The SDK treats *any* `#call(req, nxt)` object as
397
+ # middleware (lambdas, procs, `Method`s included), so including this is for
398
+ # discovery and type-checking — under Sorbet the method is `abstract`, so a
399
+ # missing or mis-typed `#call` is a static error — not a runtime
400
+ # requirement.
401
+ #
402
+ # @example
403
+ # class AddTeamHeader
404
+ # include Anthropic::Middleware
405
+ #
406
+ # def initialize(team) = @team = team
407
+ #
408
+ # def call(request, nxt)
409
+ # nxt.call(request.with(headers: request.headers.merge("x-team" => @team)))
410
+ # end
411
+ # end
412
+ #
413
+ # @param request [Anthropic::APIRequest] the per-attempt request
414
+ # @param nxt [#call] invokes the rest of the chain; returns an {APIResponse}
415
+ # @return [Anthropic::APIResponse]
416
+ def call(request, nxt)
417
+ raise NotImplementedError, "#{self.class} must implement #{Anthropic::Middleware}#call(request, nxt)"
418
+ end
419
+
420
+ class << self
421
+ # @api private
422
+ #
423
+ # Compose `list` into a single callable. `list[0]` is outermost.
424
+ #
425
+ # @param list [Array<#call>]
426
+ # @param terminal [#call] the innermost callable — the actual HTTP attempt
427
+ # @return [#call]
428
+ def build_chain(list, terminal)
429
+ list.reverse.reduce(terminal) do |inner, mw|
430
+ ->(req) { mw.call(req, inner) }
431
+ end
432
+ end
433
+ end
434
+ end
435
+ end
@@ -106,13 +106,15 @@ module Anthropic
106
106
  # Values: direct: The model can call this tool directly. code_execution_20250825:
107
107
  # The tool can be called from the code execution environment (v1).
108
108
  # code_execution_20260120: The tool can be called from the code execution
109
- # environment (v2 with persistence).
109
+ # environment (v2 with persistence). code_execution_20260521: The tool can be
110
+ # called from the code execution environment (v2 with persistence).
110
111
  module AllowedCaller
111
112
  extend Anthropic::Internal::Type::Enum
112
113
 
113
114
  DIRECT = :direct
114
115
  CODE_EXECUTION_20250825 = :code_execution_20250825
115
116
  CODE_EXECUTION_20260120 = :code_execution_20260120
117
+ CODE_EXECUTION_20260521 = :code_execution_20260521
116
118
 
117
119
  # @!method self.values
118
120
  # @return [Array<Symbol>]
@@ -63,13 +63,15 @@ module Anthropic
63
63
  # Values: direct: The model can call this tool directly. code_execution_20250825:
64
64
  # The tool can be called from the code execution environment (v1).
65
65
  # code_execution_20260120: The tool can be called from the code execution
66
- # environment (v2 with persistence).
66
+ # environment (v2 with persistence). code_execution_20260521: The tool can be
67
+ # called from the code execution environment (v2 with persistence).
67
68
  module AllowedCaller
68
69
  extend Anthropic::Internal::Type::Enum
69
70
 
70
71
  DIRECT = :direct
71
72
  CODE_EXECUTION_20250825 = :code_execution_20250825
72
73
  CODE_EXECUTION_20260120 = :code_execution_20260120
74
+ CODE_EXECUTION_20260521 = :code_execution_20260521
73
75
 
74
76
  # @!method self.values
75
77
  # @return [Array<Symbol>]
@@ -63,13 +63,15 @@ module Anthropic
63
63
  # Values: direct: The model can call this tool directly. code_execution_20250825:
64
64
  # The tool can be called from the code execution environment (v1).
65
65
  # code_execution_20260120: The tool can be called from the code execution
66
- # environment (v2 with persistence).
66
+ # environment (v2 with persistence). code_execution_20260521: The tool can be
67
+ # called from the code execution environment (v2 with persistence).
67
68
  module AllowedCaller
68
69
  extend Anthropic::Internal::Type::Enum
69
70
 
70
71
  DIRECT = :direct
71
72
  CODE_EXECUTION_20250825 = :code_execution_20250825
72
73
  CODE_EXECUTION_20260120 = :code_execution_20260120
74
+ CODE_EXECUTION_20260521 = :code_execution_20260521
73
75
 
74
76
  # @!method self.values
75
77
  # @return [Array<Symbol>]
@@ -66,13 +66,15 @@ module Anthropic
66
66
  # Values: direct: The model can call this tool directly. code_execution_20250825:
67
67
  # The tool can be called from the code execution environment (v1).
68
68
  # code_execution_20260120: The tool can be called from the code execution
69
- # environment (v2 with persistence).
69
+ # environment (v2 with persistence). code_execution_20260521: The tool can be
70
+ # called from the code execution environment (v2 with persistence).
70
71
  module AllowedCaller
71
72
  extend Anthropic::Internal::Type::Enum
72
73
 
73
74
  DIRECT = :direct
74
75
  CODE_EXECUTION_20250825 = :code_execution_20250825
75
76
  CODE_EXECUTION_20260120 = :code_execution_20260120
77
+ CODE_EXECUTION_20260521 = :code_execution_20260521
76
78
 
77
79
  # @!method self.values
78
80
  # @return [Array<Symbol>]
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Anthropic
4
+ module Models
5
+ module Beta
6
+ class BetaCodeExecutionTool20260521 < Anthropic::Internal::Type::BaseModel
7
+ # @!attribute name
8
+ # Name of the tool.
9
+ #
10
+ # This is how the tool will be called by the model and in `tool_use` blocks.
11
+ #
12
+ # @return [Symbol, :code_execution]
13
+ required :name, const: :code_execution
14
+
15
+ # @!attribute type
16
+ #
17
+ # @return [Symbol, :code_execution_20260521]
18
+ required :type, const: :code_execution_20260521
19
+
20
+ # @!attribute allowed_callers
21
+ #
22
+ # @return [Array<Symbol, Anthropic::Models::Beta::BetaCodeExecutionTool20260521::AllowedCaller>, nil]
23
+ optional :allowed_callers,
24
+ -> { Anthropic::Internal::Type::ArrayOf[enum: Anthropic::Beta::BetaCodeExecutionTool20260521::AllowedCaller] }
25
+
26
+ # @!attribute cache_control
27
+ # Create a cache control breakpoint at this content block.
28
+ #
29
+ # @return [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil]
30
+ optional :cache_control, -> { Anthropic::Beta::BetaCacheControlEphemeral }, nil?: true
31
+
32
+ # @!attribute defer_loading
33
+ # If true, tool will not be included in initial system prompt. Only loaded when
34
+ # returned via tool_reference from tool search.
35
+ #
36
+ # @return [Boolean, nil]
37
+ optional :defer_loading, Anthropic::Internal::Type::Boolean
38
+
39
+ # @!attribute strict
40
+ # When true, guarantees schema validation on tool names and inputs
41
+ #
42
+ # @return [Boolean, nil]
43
+ optional :strict, Anthropic::Internal::Type::Boolean
44
+
45
+ # @!method initialize(allowed_callers: nil, cache_control: nil, defer_loading: nil, strict: nil, name: :code_execution, type: :code_execution_20260521)
46
+ # Some parameter documentations has been truncated, see
47
+ # {Anthropic::Models::Beta::BetaCodeExecutionTool20260521} for more details.
48
+ #
49
+ # Code execution tool with REPL state persistence.
50
+ #
51
+ # @param allowed_callers [Array<Symbol, Anthropic::Models::Beta::BetaCodeExecutionTool20260521::AllowedCaller>]
52
+ #
53
+ # @param cache_control [Anthropic::Models::Beta::BetaCacheControlEphemeral, nil] Create a cache control breakpoint at this content block.
54
+ #
55
+ # @param defer_loading [Boolean] If true, tool will not be included in initial system prompt. Only loaded when re
56
+ #
57
+ # @param strict [Boolean] When true, guarantees schema validation on tool names and inputs
58
+ #
59
+ # @param name [Symbol, :code_execution] Name of the tool.
60
+ #
61
+ # @param type [Symbol, :code_execution_20260521]
62
+
63
+ # Specifies who can invoke a tool.
64
+ #
65
+ # Values: direct: The model can call this tool directly. code_execution_20250825:
66
+ # The tool can be called from the code execution environment (v1).
67
+ # code_execution_20260120: The tool can be called from the code execution
68
+ # environment (v2 with persistence). code_execution_20260521: The tool can be
69
+ # called from the code execution environment (v2 with persistence).
70
+ module AllowedCaller
71
+ extend Anthropic::Internal::Type::Enum
72
+
73
+ DIRECT = :direct
74
+ CODE_EXECUTION_20250825 = :code_execution_20250825
75
+ CODE_EXECUTION_20260120 = :code_execution_20260120
76
+ CODE_EXECUTION_20260521 = :code_execution_20260521
77
+
78
+ # @!method self.values
79
+ # @return [Array<Symbol>]
80
+ end
81
+ end
82
+ end
83
+
84
+ BetaCodeExecutionTool20260521 = Beta::BetaCodeExecutionTool20260521
85
+ end
86
+ end
@@ -51,9 +51,9 @@ module Anthropic
51
51
  # Marks the point in `content` where one model's output gives way to the next.
52
52
  #
53
53
  # One block appears per hop where a preceding model actually ran this turn and
54
- # declined. A turn routed directly by the sticky decision has no such boundary
55
- # and carries no block — the signal for whether a fallback model served the
56
- # response is the presence of a `fallback_message` entry in
54
+ # declined. A turn where no preceding model ran and declined has no such
55
+ # boundary and carries no block — the signal for whether a fallback model
56
+ # served the response is the presence of a `fallback_message` entry in
57
57
  # `usage.iterations`, not this block.
58
58
  #
59
59
  # The block is treated like a server-tool content block for streaming: it
@@ -76,19 +76,17 @@ module Anthropic
76
76
 
77
77
  # A `fallback` block echoed back from a prior response.
78
78
  #
79
- # Accepted in `messages[].content` and never rendered into the prompt,
80
- # not validated against the request's `fallbacks` chain or top-level
81
- # `model`, and stripped before the sticky-routing cache key is computed.
79
+ # Accepted in `messages[].content` and not rendered into the prompt; not
80
+ # validated against the request's `fallbacks` chain or top-level `model`.
82
81
  #
83
- # Callers should echo the assistant turn verbatim block included. The
84
- # block's position is load-bearing for thinking verification: the thinking
85
- # runs on either side of a fallback hop carry independently-rooted
86
- # verification hash chains, and this block is the only record of where one
87
- # chain ends and the next begins. When thinking runs flank the boundary,
88
- # omitting the block merges the runs into one contiguous span whose hashes
89
- # cannot verify (the request is rejected), and moving it into the middle of
90
- # a single run splits that run's chain and is likewise rejected; between
91
- # non-thinking blocks the block's placement has no verification effect.
82
+ # Echo the assistant turn back verbatim, including this block in its
83
+ # original position. The block marks the boundary between content produced
84
+ # before and after a fallback hop, and the server relies on that boundary
85
+ # to validate the turn: when thinking runs flank the boundary, omitting
86
+ # the block merges them into one span the server cannot validate (the
87
+ # request is rejected), and moving it into the middle of a single run is
88
+ # likewise rejected; between non-thinking blocks the block's placement has
89
+ # no validation effect.
92
90
  variant :fallback, -> { Anthropic::Beta::BetaFallbackBlockParam }
93
91
 
94
92
  # @!method self.variants
@@ -20,22 +20,28 @@ module Anthropic
20
20
  # @return [Anthropic::Models::Beta::BetaFallbackInfo]
21
21
  required :to, -> { Anthropic::Beta::BetaFallbackInfo }
22
22
 
23
+ # @!attribute trigger
24
+ # What caused the `from` model to hand over at this hop.
25
+ #
26
+ # @return [Anthropic::Models::Beta::BetaFallbackRefusalTrigger]
27
+ required :trigger, -> { Anthropic::Beta::BetaFallbackRefusalTrigger }
28
+
23
29
  # @!attribute type
24
30
  #
25
31
  # @return [Symbol, :fallback]
26
32
  required :type, const: :fallback
27
33
 
28
- # @!method initialize(from:, to:, type: :fallback)
34
+ # @!method initialize(from:, to:, trigger:, type: :fallback)
29
35
  # Some parameter documentations has been truncated, see
30
36
  # {Anthropic::Models::Beta::BetaFallbackBlock} for more details.
31
37
  #
32
38
  # Marks the point in `content` where one model's output gives way to the next.
33
39
  #
34
40
  # One block appears per hop where a preceding model actually ran this turn and
35
- # declined. A turn routed directly by the sticky decision has no such boundary and
36
- # carries no block — the signal for whether a fallback model served the response
37
- # is the presence of a `fallback_message` entry in `usage.iterations`, not this
38
- # block.
41
+ # declined. A turn where no preceding model ran and declined has no such boundary
42
+ # and carries no block — the signal for whether a fallback model served the
43
+ # response is the presence of a `fallback_message` entry in `usage.iterations`,
44
+ # not this block.
39
45
  #
40
46
  # The block is treated like a server-tool content block for streaming: it arrives
41
47
  # via the standard `content_block_start` / `content_block_stop` pair and carries
@@ -45,6 +51,8 @@ module Anthropic
45
51
  #
46
52
  # @param to [Anthropic::Models::Beta::BetaFallbackInfo] The fallback model producing the content that follows this block. Its `model` is
47
53
  #
54
+ # @param trigger [Anthropic::Models::Beta::BetaFallbackRefusalTrigger] What caused the `from` model to hand over at this hop.
55
+ #
48
56
  # @param type [Symbol, :fallback]
49
57
  end
50
58
  end