squishling 0.5.1 → 0.7.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14b40817f3f49682f1ed311aa5c05007dfc7f55957c9cf89683fd26fea962aa7
4
- data.tar.gz: 32b93a239eaa8f5994675a24fca6598e5e0a9edeb8d77efa97ebcf9783db6aa4
3
+ metadata.gz: 9f314a037f76cbb7f5537e24e772c2e943271263be0170c4d87a2216085cb5c0
4
+ data.tar.gz: b8898c499589a5a5a82673497eb424737bab2a63fc322c6b962af21f8ba72498
5
5
  SHA512:
6
- metadata.gz: 184955d83ece437fbf86d7f93c2103a1c61302d8df9b70f7430b49b2896c7aab42e04d1f7503203979ff1087ed8e05b67baeb767c9283c43f4bafa82c720abd8
7
- data.tar.gz: 351cdbe7b06b587e2c236ff75012fae0bf2fa526613a2d79e6b6c37aac643547bc22cfc74f73cb2e965dc31dd5f0234a7addf034fce8b1de5ea8dd74dab529d3
6
+ metadata.gz: ac738f44d710e2b3e4e956eb4a04dac914e827aa3eaebb96e42ff14c5f2a122ec39ec6e6c68ad39397e033e1b61bb1f2cfa1e2793df0966de5b219118e836e33
7
+ data.tar.gz: e91629b891c59a9df7b2e3e1ee6bb4b7306d89ed31c4b537353221057e3d36fa1e61472d47e67d904f77991d7e10847c5974db2064191006bc45b5f173defa91
data/CHANGELOG.md CHANGED
@@ -7,6 +7,99 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.7.0] - 2026-11-23
11
+
12
+ Images as call inputs, mixing adapters in one escalation, and structured Ruby values that now reach the model as
13
+ structure. Read **Changed** before upgrading: a `Struct`, `Data`, `OpenStruct`, or `Set` argument is sent differently.
14
+
15
+ ### Added
16
+
17
+ - `Squishling::Image`: a squished method can read images. Build one from bytes (`Image.new(data:)`, the media type read
18
+ from the bytes), a file (`Image.from_path`), or a URL the provider fetches (`Image.from_url`), with an optional
19
+ `detail: :low | :high`, and pass it as an argument, inside a Hash or Array, or as a `squish_context` value. The JSON
20
+ input carries `{"attached_image": N}` in its place and the images go with each chat's first message, after the text;
21
+ the Ruby path gets the `Image` unchanged. A retry continues the chat, an escalation starts a fresh chat that carries
22
+ them again, samples and a `:chat` judge are sent them, and a `type: :judgment` judge can't see them, so that
23
+ combination raises `ConfigurationError`. PNG, JPEG, GIF, and WebP are supported. An image's `inspect`, `to_s`,
24
+ `as_json`, `to_json`, and YAML describe it (media type and size, or a URL without its query), and `Marshal` refuses
25
+ it, so its bytes don't reach logs, errors, or `squawk`. Known risk: with the RubyLLM adapter, RubyLLM may download an
26
+ image's URL from your process, from any host it can reach, so only build an `Image` from a URL or path you trust: see
27
+ [Images](docs/images.md#untrusted-urls-and-paths). (#110)
28
+ - `Adapter::Base#images?` (default `false`): an adapter that takes images sets it, and then receives a chat's first
29
+ message as content parts (`{ type: :text, ... }`, then `{ type: :image, image: Squishling::Image }`). A call with
30
+ images through an adapter without it, on any of its steps, raises `ConfigurationError` before the first request, so
31
+ existing custom adapters keep getting String content. The RubyLLM and OpenAI-compatible adapters take images, and
32
+ `Testing::Request#images` and `squishling_preview`'s `images:` show what was sent. See [Images](docs/images.md). (#110)
33
+ - `config.adapters`, a Hash of named adapters (each value takes anything `config.adapter` does, and is built when
34
+ assigned), and an `adapter:` key on escalation steps, so one escalation can run, say, Apple FM, Claude Code, and Ollama
35
+ in sequence. A step without `adapter:` keeps using `config.adapter`. `adapter:` also works on `squish!`'s
36
+ `escalation:`, on `default_escalation`, and on a harness's `judge:` step. An unknown adapter name raises
37
+ `ConfigurationError` before the call's first request (judge steps and custom-harness stages included), and
38
+ `Squishling.verify` reports it ahead of time. Error semantics are unchanged: an `LLMError` moves to the next step; a
39
+ `ConfigurationError` still ends the call. See [Mixing adapters](docs/adapters.md#mixing-adapters-in-one-escalation).
40
+ (#100)
41
+ - `Adapter::Request#adapter`, `Observer::Call#adapter`, and `Testing::Request#adapter` carry the step's adapter name
42
+ (`nil` for the default adapter). In tests, `step(adapter: :name)` selects a reply by it, and `Squishling::Testing`
43
+ routes every name in `config.adapters` to its scripted adapter. (#100)
44
+
45
+ ### Changed
46
+
47
+ - **Behavior change:** a `Struct`, `Data`, or `OpenStruct` argument or `squish_context` value now reaches the model as an
48
+ object of its members (its `to_h`), and a `Set` as an array, instead of Ruby's `inspect` text such as
49
+ `#<struct S a="secret">`. A model that was reading `#<struct S a="x">` now receives `{"a": "x"}`, and the class name is
50
+ no longer sent. All members are sent, so pass a Hash or define `to_h` to leave a field out. A value that contains
51
+ itself, or whose `to_h` doesn't return a Hash, raises `ConfigurationError`. `assert_sent_arguments` compares against what was actually sent. See
52
+ [Routing](docs/routing.md). (#95, #106)
53
+ - `Squishling.verify` checks the default adapter only for the steps that use it when `config.adapters` is set, and checks
54
+ every `adapter:` a step or judge names. (#100)
55
+
56
+ ### Internal
57
+
58
+ - Development dependencies: `ruby_llm` 2.2, `coolhand` 0.11, RuboCop 1.92.2, and `ostruct` (no longer a default gem on
59
+ Ruby 4.0); `ruby/setup-ruby` 1.338.0 in CI. (#103, #107, #108, #109, #106)
60
+ - The `prep-release` and `finish-release` skills credit outside and first-time contributors. (#105)
61
+
62
+ ## [0.6.0] - 2026-11-01
63
+
64
+ Prompt caching, on by default. Read **Changed** before upgrading: requests now ask the provider to cache the stable
65
+ prompt, which can bill a cache write on providers that charge for one.
66
+
67
+ ### Added
68
+
69
+ - Prompt caching: a `cache` setting that asks the provider to cache the stable prompt (the purpose and the input note in
70
+ the system prompt), so a repeated call can read it back instead of paying for it again. It is `true`, `false`, or a
71
+ Hash of options such as `{ ttl: "1h" }`, set with `config.default_cache`, `squishling cache:`, `squish :method,
72
+ cache:`, `squish!(cache:)`, or an escalation step's `cache:`; the more specific level wins. There is no class-level
73
+ `cache false` macro, since it would collide with `ActiveRecord::Base.cache`: use `squishling cache: false`. The RubyLLM
74
+ adapter asks for it with `Chat#with_caching` and sends no cache controls when it is off; a System One judgment is never
75
+ cached. See [Prompt caching](docs/configuration.md#prompt-caching). (#79, #80)
76
+ - `Observer::Usage` gains `cache_read_tokens` and `cache_write_tokens`, and `Adapter::Request`, `ModelPath::Step`, and
77
+ `Testing::Request` gain a `cache` member (defaulting to `false`, so existing constructors keep working). Adapters that
78
+ report cache usage put `:cache_read_tokens` and `:cache_write_tokens` in `Adapter::Response#tokens`. (#79, #80)
79
+ - `config.budget_counts_cache_reads` (default `false`, `true` or `false` only): whether the tokens a request reads from the
80
+ provider's prompt cache count toward `max_total_input_tokens`. (#97)
81
+
82
+ ### Changed
83
+
84
+ - **Behavior change:** prompt caching is on by default (`config.default_cache` is `true`). With the RubyLLM adapter, a
85
+ provider that bills for cache writes (such as Anthropic Claude) may charge a write premium on the first call. Set
86
+ `config.default_cache = false`, or `cache: false` on a class, method, or step, to opt out. A model that can't take
87
+ cache controls may reject the request, which raises `ConfigurationError`: set `cache: false` for that model. The
88
+ OpenAI-compatible adapter ignores the setting. (#79, #80)
89
+ - **Behavior change:** `max_total_input_tokens` now counts the tokens written to the prompt cache, which RubyLLM
90
+ reports apart from `input_tokens`, so a call that writes a large cached prompt can reach the budget sooner than before.
91
+ Tokens read from the cache are left out unless `budget_counts_cache_reads` is `true`. Output tokens are unchanged.
92
+ (#79, #80, #97)
93
+ - **Behavior change:** the OpenAI-compatible adapter reports `input_tokens` net of cached tokens, as every adapter
94
+ does (the cached reads go to `cache_read_tokens`, and a server's cache writes to `cache_write_tokens`). A custom
95
+ adapter's `input_tokens` should likewise exclude cached tokens. Code that read `input_tokens` from `squawk` usage or an
96
+ observer for this adapter will see a smaller number on cache hits. (#79, #80)
97
+
98
+ ### Documented
99
+
100
+ - The adapter docs list the separate [`squishling-apple_fm`](https://github.com/Coolhand-Labs/squishling-apple-fm-adapter)
101
+ and [`squishling-claude_code`](https://github.com/Coolhand-Labs/squishling-claude-code-adapter) adapter gems. (#94)
102
+
10
103
  ## [0.5.1] - 2026-10-31
11
104
 
12
105
  The v0.5.0 red-team follow-ups (#70): data-egress, secret-leakage, and misclassification fixes. Several of them change
data/README.md CHANGED
@@ -172,7 +172,7 @@ sees it right where the value goes, and the purpose stays short and about the go
172
172
  the OpenAI-compatible adapter (OpenAI, Ollama, vLLM, LM Studio, Together, Groq, … over plain HTTP), or write your
173
173
  own in one method.
174
174
  - **Any provider and model**: set a universal, per-class, per-method, or per-call model, plus layered generation params (temperature,
175
- reasoning effort, top_p, …).
175
+ reasoning effort, top_p, …) and [prompt caching](docs/configuration.md#prompt-caching) (on by default, opt out per class, method, or call).
176
176
  - **Model escalation**: declare an `escalation:` instead of a `model:`, with per-step `attempts:`, `priority:` (models tied on priority take turns going first), provider,
177
177
  params, `forward_rejected:`, `retry_temperature:`, and `include_when:` (leave a model out of calls where a Proc is falsy). Invalid output (with its errors fed back) or a provider failure moves on to the next attempt. Steps can
178
178
  cross providers, e.g. a local Qwen model on Ollama, then Anthropic Claude Haiku on AWS Bedrock, then Claude Opus:
@@ -222,9 +222,10 @@ sees it right where the value goes, and the purpose stays short and about the go
222
222
  - [Explainer site](https://coolhand-labs.github.io/squishling/): interactive walkthrough, spectrum slider, and
223
223
  token-cost calculator
224
224
  - [Configuration](docs/configuration.md): options, models and escalation, providers, generation params, inheritance
225
- - [Adapters](docs/adapters.md): the RubyLLM and OpenAI-compatible adapters, and writing your own
225
+ - [Adapters](docs/adapters.md): the RubyLLM and OpenAI-compatible adapters, mixing them in one escalation, and your own
226
226
  - [Routing](docs/routing.md): when a call goes to the LLM, `squish!`, `append_to_purpose`, hardening a path,
227
227
  what the LLM sees
228
+ - [Images](docs/images.md): pass a `Squishling::Image` (bytes, a file, or a URL) for the model to read
228
229
  - [Output schemas](docs/schemas.md): schema forms, strict mode, typed results, optional vs. empty, contracts
229
230
  - [Failure handling](docs/failures.md): escalation, `squish_validate`, error classes, fallbacks
230
231
  - [Harnesses](docs/harnesses.md): escalation, squishsum, judges (chat or Jev), and custom harnesses
data/docs/adapters.md CHANGED
@@ -3,12 +3,14 @@
3
3
  An **adapter** is how Squishling reaches a model. Squishling builds the request (system prompt, conversation so far,
4
4
  strict output schema, generation params), the adapter makes one completion and returns the model's output, and
5
5
  Squishling does the rest: validation, `squish_validate`, retries and escalation, harnesses, `squawk`, and fallbacks.
6
- Two adapters ship, and you can write your own.
6
+ Two adapters ship, separate gems add more (below), and you can write your own.
7
7
 
8
8
  | Adapter | Reaches | Needs |
9
9
  |---|---|---|
10
10
  | [`:ruby_llm`](#ruby_llm) | OpenAI, Anthropic Claude, Google Gemini, AWS Bedrock, OpenRouter, and every provider [RubyLLM](https://rubyllm.com) supports | `gem "ruby_llm"` |
11
11
  | [`:openai_compatible`](#openai-compatible-endpoints) | Any server that speaks OpenAI's Chat Completions API: OpenAI, Ollama, vLLM, LM Studio, llama.cpp, Together, Groq, … | nothing (Ruby's `Net::HTTP`) |
12
+ | [`squishling-apple_fm`](https://github.com/Coolhand-Labs/squishling-apple-fm-adapter) (separate gem) | The on-device model built into macOS (Apple Intelligence): free and offline, for development | `gem "squishling-apple_fm"`, macOS 26+ on Apple Silicon |
13
+ | [`squishling-claude_code`](https://github.com/Coolhand-Labs/squishling-claude-code-adapter) (separate gem) | Your local Claude Code CLI (`claude -p`), on your own Claude subscription instead of API billing, for development | `gem "squishling-claude_code"`, Claude Code installed and logged in |
12
14
  | [Your own](#writing-your-own) | Anything | a class with one method |
13
15
 
14
16
  Squishling itself depends on neither RubyLLM nor any provider SDK.
@@ -24,13 +26,71 @@ end
24
26
  ```
25
27
 
26
28
  An adapter is built when you assign it, so a missing gem or a bad option fails at boot, not on the first request.
27
- There is one adapter per process; every squishling class, method, and escalation step goes through it.
29
+ `config.adapter` is the default: every squishling class, method, and escalation step goes through it unless the step
30
+ picks another one (see [Mixing adapters](#mixing-adapters-in-one-escalation)).
28
31
 
29
32
  **When you set none**, Squishling uses the RubyLLM adapter if the `ruby_llm` gem is in your bundle, so apps that
30
33
  configured RubyLLM before adapters existed keep working. Squishling no longer requires `ruby_llm` when it loads, so an
31
34
  app that doesn't load its Gemfile with `Bundler.require` should `require "ruby_llm"` before `RubyLLM.configure`. Without the gem, the first squished call
32
35
  raises `Squishling::ConfigurationError` saying what to add.
33
36
 
37
+ ### Known risk: the RubyLLM adapter downloads some image URLs itself
38
+
39
+ When a call carries an [image given by URL](images.md#adapters), the RubyLLM adapter hands the URL to RubyLLM, which
40
+ downloads it from your process whenever it can't tell the image type from the URL's path (any path with no image
41
+ extension) or the provider can't fetch URLs itself. That download follows redirects and doesn't filter hosts, so a URL
42
+ that points at `localhost`, a private address, or a cloud metadata endpoint is fetched, and what comes back is sent to
43
+ the provider. If a user can choose an image URL, that is a server-side request forgery risk that comes with the RubyLLM
44
+ adapter: allow-list the URL's host and scheme before building the `Image`, or download it yourself and pass the bytes
45
+ with `Image.new(data:)`. The OpenAI-compatible adapter never downloads an image: it sends the URL on for the provider
46
+ to fetch.
47
+
48
+ ## Mixing adapters in one escalation
49
+
50
+ Give `config.adapters` a name for each extra adapter, and pick one per step with `adapter:`:
51
+
52
+ ```ruby
53
+ Squishling.configure do |config|
54
+ config.adapters = {
55
+ apple: :apple_fm, # squishling-apple_fm
56
+ claude: :claude_code, # squishling-claude_code
57
+ local: { type: :openai_compatible, base_url: "http://localhost:11434/v1" }
58
+ }
59
+ end
60
+
61
+ class Triage
62
+ include Squishling
63
+
64
+ squishling escalation: [
65
+ { model: "apple-fm", adapter: :apple },
66
+ { model: "sonnet", adapter: :claude },
67
+ { model: "llama3.2", adapter: :local, attempts: 2 },
68
+ "claude-opus-5-5" # no adapter: the default one (config.adapter, else RubyLLM)
69
+ ]
70
+ end
71
+ ```
72
+
73
+ Each value takes anything `config.adapter` does and is built when assigned. A step that names no adapter uses
74
+ `config.adapter`, so existing setups are unchanged; if every step names one, you need no default (and no `ruby_llm`).
75
+ `adapter:` works on any escalation step, on `squish!`'s `escalation:`, on `default_escalation`, and on a harness's
76
+ `judge:` step. A single `model:` takes a bare name only, so use a one-step `escalation:` to put it on an adapter.
77
+
78
+ - **The rest of the step is the adapter's to read.** `provider:` and `params:` mean what the chosen adapter makes of
79
+ them, so a step on `:local` doesn't need RubyLLM's `provider:`.
80
+ - **An unknown name is a `ConfigurationError`** (naming the configured ones), raised when a call starts (before its first
81
+ request), not when the class loads, since a class can load before `Squishling.configure` runs.
82
+ [`Squishling.verify`](verifying.md) finds it ahead of time.
83
+ - **Failures keep their meaning.** Each adapter classifies its own errors, then Squishling treats them as always: a
84
+ down Ollama is an `LLMError` and the call moves on to the next step, but a `ConfigurationError` (say, Claude Code
85
+ isn't logged in) ends the call and is never handed to the next adapter or to `squish_fallback`.
86
+ - **Rejected output crosses adapters.** The step after a failed one is shown the failed step's rejected output (see
87
+ [escalation](configuration.md#models-and-escalation)), so it goes to the next step's adapter, possibly a different
88
+ vendor. Set `forward_rejected: false` on a step that shouldn't see it.
89
+ - **A judge's adapter sees the full input**, like any judge's provider (see [the judge](harnesses.md#the-judge)).
90
+ `type: :judgment` judges need an adapter with judgments; the check is on the judge's own adapter.
91
+ - **Observers and tests** are told the name: `Observer::Call#adapter`, `Adapter::Request#adapter` (handed to your
92
+ adapter, `nil` for the default), and `Testing::Request#adapter`.
93
+
34
94
  ## `:ruby_llm`
35
95
 
36
96
  Everything works as it did before adapters: configure provider API keys with `RubyLLM.configure`, name models, and
@@ -172,19 +232,22 @@ Squishling.register_adapter(:acme, AcmeAdapter)
172
232
  |---|---|
173
233
  | `label` | `"Class#method"`, to prefix your error messages (the `configuration_error` / `llm_error` helpers do; `http_failure(request, status:, body:, via:)` sorts an HTTP failure; `rejected_request_error(request, via:, body:, http_status:)` builds the error for a rejected request, from a JSON String or String-keyed Hash body). |
174
234
  | `model`, `provider` | The escalation step's, or `nil` when it names none (use your own default). What `provider:` means is up to you. |
235
+ | `adapter` | The name your adapter was configured under in `config.adapters`, or `nil` when it is the default adapter. |
175
236
  | `instructions` | The system prompt. |
176
- | `messages` | The conversation so far, ending with the user message to answer. After invalid output, Squishling appends your previous answer and a retry message; you never keep history. |
237
+ | `messages` | The conversation so far, ending with the user message to answer. After invalid output, Squishling appends your previous answer and a retry message; you never keep history. Each `content` is a String, except a chat's first user message in a call with [images](#images). |
177
238
  | `schema` | `{ "name", "description", "schema", "strict" => true }`: the strict structured-output payload, without the conditional keywords providers can't take. |
178
239
  | `params` | The resolved [generation params](configuration.md#generation-params): the portable `:temperature`, `:max_output_tokens`, `:thinking`, plus provider-specific keys. Squishling has already rejected the keys it owns. Translate the portable ones for your provider; pass the rest through if it takes them. |
240
+ | `cache` | The [prompt caching](configuration.md#prompt-caching) to ask for: `false` (none), or a Hash of options (`{}` for the provider's default, `{ ttl: "1h" }`). Ignore it if your provider has no prompt caching or caches on its own. |
179
241
 
180
242
  ### The response
181
243
 
182
244
  `Squishling::Adapter::Response.new(content:, model:, tokens:, finish_reason:)`. `content` is the model's output as a
183
245
  String, or a Hash if you parsed it; `nil` or empty counts as invalid output and is retried. `model` is the id the
184
- provider reports. `tokens` is a Hash (`:input_tokens`, `:output_tokens`, and anything else you have); `{}` when
246
+ provider reports. `tokens` is a Hash (`:input_tokens`, which leaves out the tokens read from or written to the prompt cache, `:output_tokens`, `:cache_read_tokens`, `:cache_write_tokens`, and anything else you have); `{}` when
185
247
  unknown. These feed [`squawk`'s `usage`](failures.md#observing-every-attempt-squawk), the [observer](observers.md)'s `Usage`, and the
186
- [token budget](failures.md#capping-a-calls-cost-token-budgets), which counts `:input_tokens` and `:output_tokens`
187
- (a response with none never exhausts a budget).
248
+ [token budget](failures.md#capping-a-calls-cost-token-budgets), which counts `:input_tokens`, `:cache_write_tokens` and
249
+ `:output_tokens`, and `:cache_read_tokens` only with `budget_counts_cache_reads` (a response with none never exhausts a
250
+ budget).
188
251
  `finish_reason` is why the provider stopped, as a Symbol: `:stop`, `:max_tokens` (the output cap cut the reply off),
189
252
  `:content_filter`, `:tool_calls`, or the provider's own spelling; leave it out (`nil`) when unknown. Map your
190
253
  provider's "length" reason to `:max_tokens`, so Squishling can [tell a cutoff from a wrong
@@ -234,6 +297,15 @@ exception propagates unwrapped and is never retried, so map your transport's err
234
297
  worker threads. `capture_context` runs on the caller's thread and returns whatever your tracing needs; `with_context`
235
298
  re-establishes it around each worker's request. The RubyLLM adapter uses this for its instrumentation workflow.
236
299
 
300
+ ### Images
301
+
302
+ A call can carry [images](images.md). To take them, return `true` from `images?`; then a chat's first user message has
303
+ an Array of content parts instead of a String: `{ type: :text, text: String }`, then `{ type: :image, image:
304
+ Squishling::Image }` per image. An `Image` gives you `data` (the bytes) with `media_type`, `data_uri`, and
305
+ `filename`, or, for `url?` images, the `url` for the provider to fetch, plus the `detail` asked for (`:low`, `:high`,
306
+ or `nil`). Without `images?`, a call with images raises `ConfigurationError` before any request, so adapters that
307
+ predate images keep getting Strings.
308
+
237
309
  ### Thread safety
238
310
 
239
311
  Adapters are called concurrently from worker threads when a harness takes samples. Keep no unsynchronized mutable
@@ -28,11 +28,14 @@ end
28
28
  | Option | Default | Description |
29
29
  |---|---|---|
30
30
  | `adapter` | `nil` (RubyLLM, when its gem is available) | How requests reach a model: `:ruby_llm`, `:openai_compatible`, a [registered](adapters.md#writing-your-own) name, a Hash with `type:` and that adapter's options, or an adapter instance. See [Adapters](adapters.md). |
31
+ | `adapters` | `{}` | More adapters by name, for escalation steps that pick one with `adapter:`. Each value takes what `adapter` does. See [Mixing adapters](adapters.md#mixing-adapters-in-one-escalation). |
31
32
  | `default_model` | `nil` | The universal model (a single attempt) for every squishling class that doesn't declare one. `nil` uses the adapter's own default (RubyLLM's `default_model`; the OpenAI-compatible adapter's `default_model:` option). |
32
33
  | `default_escalation` | `nil` | The universal [escalation](#models-and-escalation): models tried in order. Assigning it clears `default_model`, and vice versa. |
33
34
  | `default_provider` | `nil` | The provider for `default_model`/`default_escalation` steps that don't name one. What it means depends on the adapter: RubyLLM needs it only for models missing from its registry (see below); the OpenAI-compatible adapter ignores it. |
34
35
  | `default_params` | `{}` | Generation params for every call (temperature, reasoning effort, top_p, …), overridable per class, per method, and per escalation step. See [Generation params](#generation-params). |
36
+ | `default_cache` | `true` | Asks the provider to cache the stable prompt on every request: `true`, `false`, or a Hash of options such as `{ ttl: "1h" }`. Overridable per class, per method, per escalation step, and per `squish!` call. See [Prompt caching](#prompt-caching). |
35
37
  | `default_max_total_output_tokens`, `default_max_total_input_tokens` | `nil` (no limit) | The most output (or input) tokens one call may use across all its requests; once reached, the call raises `BudgetExhaustedError` instead of making another attempt. Overridable per class (`squishling max_total_output_tokens: ...`), per method, and per `squish!` call. See [Capping a call's cost](failures.md#capping-a-calls-cost-token-budgets). |
38
+ | `budget_counts_cache_reads` | `false` | Whether the input tokens a request reads from the provider's prompt cache count toward `max_total_input_tokens`. Off by default, since reads are cheap; tokens written to the cache always count. Global only. See [Capping a call's cost](failures.md#capping-a-calls-cost-token-budgets). |
36
39
  | `squawk` | `nil` | A callable run after every LLM attempt (see `squawk_on`), and once more when a token budget or a disagreement stops the call, with the raw output, for sending it to an error tracker or tracing tool. Also settable per class and per method. See [Observing every attempt](failures.md#observing-every-attempt-squawk). |
37
40
  | `squawk_on` | `:all` | Which attempts reach the `squawk` hook: `:all`, `:rejections` (errors only), `:retries` (errors plus any accepted attempt after the first), `:final` (the last attempt the escalation allows), or a list of them (any one holding runs the hook). A call [stopped](failures.md#a-call-that-is-stopped) by a token budget or a disagreement is always reported. Also settable per class and per method. |
38
41
  | `observer` | `nil` | An around-style hook for every provider request: `:coolhand`, any object responding to `around(call)`, or `false` for none. `nil` uses the [Coolhand observer](coolhand.md) when the `coolhand` gem is configured. See [Observers](observers.md). |
@@ -73,9 +76,11 @@ Each step is a model name, or a Hash with:
73
76
  | `rotate:` | `true` | Set `false` on a step to keep its tier in the order written instead of rotating it. |
74
77
  | `include_when:` | always | A Proc that leaves this step out of any call where it returns falsy (see [Excluding a model per call](#excluding-a-model-per-call)). |
75
78
  | `provider:` | the level's `provider:` | See [Providers](#providers-and-newly-released-models). |
79
+ | `adapter:` | `config.adapter` | The name of an adapter from `config.adapters` that makes this step's requests, so one escalation can mix adapters. See [Mixing adapters](adapters.md#mixing-adapters-in-one-escalation). |
76
80
  | `retry_temperature:` | none | A Numeric `temperature` for this step's retries in the same chat (not its first attempt), to nudge a model that keeps sending the same rejected reply. Don't use it on a step that sets `thinking`, since reasoning models reject `temperature`. |
77
81
  | `forward_rejected:` | `true` | Set `false` to start this step from the original input alone, without the previous step's rejected output and its errors (see below). |
78
82
  | `params:` | `{}` | [Generation params](#generation-params) for this step, merged over the class and method params key by key. |
83
+ | `cache:` | the level's `cache:` | [Prompt caching](#prompt-caching) for this step: `false`, `true`, or a Hash of options. It replaces the level's value, since caching behaves differently per model and provider. |
79
84
 
80
85
  Without `priority:`, steps run in the order written. With it, the order is explicit and doesn't depend on position:
81
86
 
@@ -166,7 +171,7 @@ end
166
171
  Passing both `model:` and `escalation:` in one declaration raises `ConfigurationError`, and so does a list passed as
167
172
  `model:`. Across separate declarations (a reopened class, or two config assignments), the latest one wins.
168
173
 
169
- Consecutive attempts of the same step (same model, provider, params, `forward_rejected:`, and `retry_temperature:`, e.g. `attempts: 2`)
174
+ Consecutive attempts of the same step (same model, provider, adapter, params, `cache:`, `forward_rejected:`, and `retry_temperature:`, e.g. `attempts: 2`)
170
175
  continue one conversation. Moving to a different step starts a fresh chat with the original input plus the previous
171
176
  output and why it was rejected, so no provider-specific history crosses providers. That rejected output is
172
177
  model-generated and is sent to the next step's provider, even when it is a different one, truncated to 4,000
@@ -257,9 +262,53 @@ end
257
262
  - If a provider rejects a param, the call raises `Squishling::ConfigurationError` naming the params. It isn't
258
263
  retried or sent to `squish_fallback`. See [Failure handling](failures.md).
259
264
 
265
+ ## Prompt caching
266
+
267
+ Squishling puts the stable text (the purpose and the note on the inputs) in the system prompt and the
268
+ per-call data in the user message, which is the order provider prompt caches want. With the RubyLLM adapter, caching is
269
+ on by default: each request goes out with RubyLLM's `with_caching`, so Anthropic Claude (whose caching is opt-in) caches
270
+ the prompt, and a call's retries within one escalation step reuse it. The cache point RubyLLM sets covers the request up
271
+ to its last message, so the per-call data is written to the cache too, and only a later request that shares that prefix
272
+ reads it back. The OpenAI-compatible adapter ignores the setting, and providers that cache on their own (OpenAI, Google
273
+ Gemini) still do.
274
+
275
+ `cache` is `true`, `false`, or a Hash of options for the provider (`{ ttl: "1h" }`). Each level overrides the one above
276
+ it, and `nil` inherits; a Hash replaces the level above's rather than merging into it:
277
+
278
+ ```ruby
279
+ Squishling.configure { |c| c.default_cache = false } # every call (default: true)
280
+
281
+ class Triager
282
+ include Squishling
283
+ squishling cache: false # this class (and subclasses)
284
+
285
+ squish :triage, cache: { ttl: "1h" } do # one method
286
+ string :priority
287
+ end
288
+ end
289
+
290
+ squish!(cache: false, escalation: ["claude-opus-5-5"]) # one hand-off
291
+ # escalation: [{ model: "claude-haiku-4-5", cache: false }, "claude-sonnet-5-5"] # one step
292
+ ```
293
+
294
+ - **Writing a cache entry costs extra.** Anthropic charges a premium for the write (about 1.25x the input price for the
295
+ 5-minute lifetime, more for `ttl: "1h"`) and pays it back only when a later request reads the entry. A class with a
296
+ long prompt that is called once and never again costs slightly more with caching on; set `cache: false` for it.
297
+ - **Not every model takes cache controls.** A model that can't cache may reject them (a provider 400, which is a
298
+ `ConfigurationError`, never retried); set `cache: false` for it, per class, method, or escalation step.
299
+ - **A prefix below the model's minimum is not cached.** Providers ignore caching under a model-specific minimum, so a
300
+ short prompt is a harmless no-op, not an error.
301
+ - **An option the provider doesn't take raises `ConfigurationError`** when the request is made (Anthropic accepts `ttl`,
302
+ for instance). Explicit Gemini content caches (`id:`) are not supported.
303
+ - **Judgments** (`type: :judgment` judges) don't use a chat, so they are never cached.
304
+ - **Token budgets** count the tokens written to the cache but not those read back, so a hit doesn't spend
305
+ `max_total_input_tokens`; `budget_counts_cache_reads = true` counts reads too.
306
+ - **See whether it hits** in `cache_read_tokens` and `cache_write_tokens`: they are in `squawk`'s `usage` and on the
307
+ [observer](observers.md#what-yield-returns)'s `Usage` (nil when the provider reports none).
308
+
260
309
  ## Inheritance
261
310
 
262
- Subclasses inherit the model or escalation and its provider (as a pair), harness, generation params (merged key by key), token budgets (limit by limit), purpose, output schema,
311
+ Subclasses inherit the model or escalation and its provider (as a pair), harness, generation params (merged key by key), prompt caching, token budgets (limit by limit), purpose, output schema,
263
312
  `squish_when` predicate, `squish_context` names, `squish_validate`, `squish_fallback`, and every `squish` declaration. Overrides in a subclass, including
264
313
  overridden methods, are routed the same way.
265
314
 
@@ -269,6 +318,6 @@ overridden methods, are routed the same way.
269
318
  ## Per-call overrides
270
319
 
271
320
  Inside a squished method, `squish!` sends the call to the LLM with its own `purpose:`,
272
- `append_to_purpose:`, `context:`, `model:` or `escalation:` (with `provider:`), `params:`, `harness:`, and
321
+ `append_to_purpose:`, `context:`, `model:` or `escalation:` (with `provider:`), `params:`, `cache:`, `harness:`, and
273
322
  `max_total_output_tokens:`/`max_total_input_tokens:`. Each layers over the method and class
274
323
  settings the same way they layer over each other. See [Handing off to the LLM](routing.md#handing-off-to-the-llm-with-squish).
data/docs/failures.md CHANGED
@@ -155,7 +155,10 @@ Things to know:
155
155
  limit by one request (for the squishsum harnesses, one round of samples).
156
156
  - Tokens are the counts the [adapter](adapters.md) reports (`output_tokens` includes a reasoning model's thinking
157
157
  tokens for providers that count them that way). A request that failed reports none, and a provider that reports no
158
- usage never exhausts a budget.
158
+ usage never exhausts a budget. The input total includes the tokens written to the prompt cache
159
+ (`cache_write_tokens`) but not those read from it (`cache_read_tokens`), which adapters report apart from
160
+ `input_tokens`: with [prompt caching](configuration.md#prompt-caching) on, a hit on a long cached prompt doesn't spend
161
+ the budget. Set `config.budget_counts_cache_reads = true` in `Squishling.configure` to count reads too.
159
162
  - The limits are positive Integers. Set them with `Squishling.configure` (`default_max_total_output_tokens`,
160
163
  `default_max_total_input_tokens`), `squishling`, `squish :method, ...`, or a [`squish!`](routing.md#handing-off-to-the-llm-with-squish) call.
161
164
  The more specific level wins, limit by limit, and `false` lifts a limit set at a wider level.
data/docs/images.md ADDED
@@ -0,0 +1,92 @@
1
+ # Images
2
+
3
+ A squished method can read images: pass a `Squishling::Image` as an argument, and the model gets it with the call's
4
+ input. Use it for receipts, screenshots, scanned forms, or anything you'd otherwise run through OCR first.
5
+
6
+ ```ruby
7
+ class ReceiptReader
8
+ include Squishling
9
+
10
+ squishling escalation: [{ model: "gpt-5-mini", attempts: 2 }, "gpt-5"]
11
+ purpose "Read the totals off this receipt."
12
+ output_schema do
13
+ optional(:total_cents, description: "The amount charged, tip included, in cents") { integer }
14
+ optional(:date, description: "The transaction date, YYYY-MM-DD") { string }
15
+ end
16
+ end
17
+
18
+ ReceiptReader.call(image: Squishling::Image.from_path("receipt.jpg"), note: "team lunch")
19
+ ```
20
+
21
+ ## Making an image
22
+
23
+ | | |
24
+ |---|---|
25
+ | `Squishling::Image.from_path(path)` | Reads the file. The media type comes from the bytes (or the extension). |
26
+ | `Squishling::Image.new(data: bytes)` | Bytes you already have (an upload, an ActiveStorage download). Pass `media_type:` if it can't be read from them. |
27
+ | `Squishling::Image.from_url(url)` | An http(s) URL the provider fetches itself. Nothing is downloaded here, so the URL has to be reachable from the provider (a signed URL works). |
28
+
29
+ PNG, JPEG, GIF, and WebP are supported. `detail: :low` or `:high` asks the provider to spend fewer or more tokens on
30
+ the image; providers without the setting ignore it. For a PDF, render its pages to images (one `Image` per page) and
31
+ pass them as an Array; text you can extract from the PDF can go alongside as a plain argument.
32
+
33
+ ## What the model sees
34
+
35
+ Each image is replaced in the JSON input by `{"attached_image": N}`, and the images go with the call's first message,
36
+ after the text, in that order. The system prompt gets one line explaining the placeholders. So for
37
+ `call(front: a, back: b)` the input is `{"arguments":{"front":{"attached_image":1},"back":{"attached_image":2}}}`, with
38
+ `a` and `b` attached. The same `Image` passed twice is attached once. Images can sit inside Hashes and Arrays, and in
39
+ `squish_context` values.
40
+
41
+ The Ruby path gets the `Image` objects as they were passed.
42
+
43
+ Every chat starts with the images: a retry continues the same chat (the model already has them), an escalation to a new
44
+ step starts a fresh chat that carries them again, and a sample harness sends them to every sample. A `:chat` judge is
45
+ sent them with the input it judges. A `type: :judgment` judge can't see images, so a call with images and such a judge
46
+ raises `ConfigurationError` before any request.
47
+
48
+ ## Adapters
49
+
50
+ The RubyLLM adapter sends images as RubyLLM attachments, and the OpenAI-compatible adapter as `image_url` content parts
51
+ (a `data:` URI, or the image's own URL); the model has to accept images. RubyLLM downloads a URL image itself when the
52
+ URL's path has no image extension (to tell its type) or when the provider can't fetch URLs, so with RubyLLM a URL has to
53
+ be reachable from your process too. A [custom adapter](adapters.md#images) opts
54
+ in with `images?`. A call with images through an adapter that doesn't take them raises `ConfigurationError` before any
55
+ request is made.
56
+
57
+ ## Untrusted URLs and paths
58
+
59
+ Build an `Image` only from sources you trust, or check them first. Squishling doesn't filter hosts or paths:
60
+
61
+ - **`Image.from_url` with the RubyLLM adapter is a known risk.** RubyLLM, not Squishling, may download the URL from your
62
+ own process (see [Adapters](#adapters)), following redirects, from any host it can reach, including `localhost`,
63
+ private addresses, and cloud metadata endpoints, and what it fetches is then sent to the provider. If a user can
64
+ choose the URL, allow-list its host and scheme before building the `Image`, or download it yourself and pass the
65
+ bytes with `Image.new(data:)`. See [the adapter note](adapters.md#known-risk-the-rubyllm-adapter-downloads-some-image-urls-itself).
66
+ The OpenAI-compatible adapter never downloads: the provider fetches the URL.
67
+ - **`Image.from_path`** reads whatever file the path names, so never pass it a path a user chose without confining it
68
+ to a directory you control.
69
+
70
+ ## Privacy and logs
71
+
72
+ An image is input, like any argument: it goes to the provider (and to a judge's provider). It never goes anywhere else.
73
+ `Image#inspect`, `#to_s`, `#as_json`, `#to_json`, and YAML describe the image (media type and size, or the URL without its
74
+ query or credentials), so an image that ends up in a log line, an error, or a serialized object carries no content. `Marshal.dump` of an
75
+ image raises `TypeError`: keep the bytes (or a URL) in your own storage and build the `Image` where the call is made.
76
+ `squawk` reports carry the JSON input with its placeholders, never the bytes, and observers never see input.
77
+
78
+ Images are billed as input tokens by the provider, and the [token budget](failures.md#capping-a-calls-cost-token-budgets)
79
+ counts them through the usage the provider reports. [Prompt caching](configuration.md#prompt-caching) still caches the
80
+ system prompt; the images are part of the message, not the cached prefix.
81
+
82
+ ## Testing
83
+
84
+ `Squishling::Testing::Request#images` lists the images a request was sent with, and `arguments` shows their
85
+ placeholders. `squishling_preview` returns them as `images:`.
86
+
87
+ ```ruby
88
+ fake = fake_squishling { |llm| llm.step(:any).reply({ "total_cents" => 1234 }) }
89
+ ReceiptReader.call(image:)
90
+ fake.requests.first.images # => [image]
91
+ fake.requests.first.arguments # => { "image" => { "attached_image" => 1 } }
92
+ ```
@@ -93,7 +93,8 @@ can meter spend knowing which method, escalation level, sample, or judge made th
93
93
  ```ruby
94
94
  class SpendObserver
95
95
  def around(call)
96
- usage = yield # input_tokens, output_tokens (nil if unreported), and model; never the content
96
+ usage = yield # input_tokens (not counting cached ones), output_tokens, cache_read_tokens, cache_write_tokens
97
+ # (each nil if unreported), and model; never the content
97
98
  tags = ["label:#{call.label}", "role:#{call.role || 'squish'}", "model:#{usage.model}"]
98
99
  Metrics.increment("squishling.tokens.in", usage.input_tokens.to_i, tags:)
99
100
  Metrics.increment("squishling.tokens.out", usage.output_tokens.to_i, tags:)
data/docs/observers.md CHANGED
@@ -26,7 +26,8 @@ raises `ConfigurationError`.
26
26
 
27
27
  ## What `yield` returns
28
28
 
29
- The block returns a `Squishling::Observer::Usage`: the request's `input_tokens` and `output_tokens` (nil when the
29
+ The block returns a `Squishling::Observer::Usage`: the request's `input_tokens` and `output_tokens`, the
30
+ `cache_read_tokens` and `cache_write_tokens` of [prompt caching](configuration.md#prompt-caching) (each nil when the
30
31
  provider didn't report them) and the `model` that answered. That is enough to meter spend:
31
32
 
32
33
  ```ruby
@@ -67,6 +68,7 @@ Anything else raises `ConfigurationError` when you assign it.
67
68
  | `sample` | `"a"`, `"b"`, ... for a sample, else `nil` |
68
69
  | `attempt`, `attempts` | This request's 1-based position in the steps it was asked on, and how many there are: the escalation's expanded steps (or, for a custom harness, those passed to `run.escalate`), the sample's stage, or the judge's steps |
69
70
  | `model`, `provider` | The step's model and provider (`provider` is `nil` unless declared) |
71
+ | `adapter` | The name of the [adapter](adapters.md#mixing-adapters-in-one-escalation) the step picked (`nil` for the default one) |
70
72
  | `request` | `:chat`, or `:judgment` for a System One judge |
71
73
 
72
74
  It carries metadata, plus the rendered `purpose`. The method's inputs, its context, and the model's output never reach an
data/docs/routing.md CHANGED
@@ -98,7 +98,7 @@ end
98
98
  - `purpose:` (replaces the class's)
99
99
  - `append_to_purpose:` (added to the class's, see [Appending to the purpose](#appending-to-the-purpose))
100
100
  - `output_schema:` (or a schema block)
101
- - `model:` or `escalation:`, `provider:`, and `params:` (generation params; see [Configuration](configuration.md))
101
+ - `model:` or `escalation:`, `provider:`, `params:` (generation params), and `cache:` (prompt caching); see [Configuration](configuration.md)
102
102
  - `harness:` (see [Harnesses](harnesses.md), including your own)
103
103
  - `max_total_output_tokens:` and `max_total_input_tokens:` (see [Capping a call's cost](failures.md#capping-a-calls-cost-token-budgets))
104
104
  - `when:`, a predicate proc
@@ -143,6 +143,7 @@ end
143
143
  | `append_to_purpose:` | Added to the declared sections; `false` (alone or first in an Array) drops them for this call |
144
144
  | `purpose:` | Replaces the purpose |
145
145
  | `model:` or `escalation:`, `provider:`, `params:` | E.g. send this call to a stronger model, or a whole [escalation](configuration.md#models-and-escalation), when Ruby fails. A `provider:` needs a `model:` or `escalation:`; `params:` merge key by key over the declared ones. |
146
+ | `cache:` | Replaces the declared [prompt caching](configuration.md#prompt-caching) setting; `false` turns it off for this call |
146
147
  | `harness:` | Replaces the declared [harness](harnesses.md), e.g. `harness: :judged_squishsum` to double-check a hand-off |
147
148
  | `max_total_output_tokens:`, `max_total_input_tokens:` | Cap what this call may spend, e.g. a tighter budget for a hand-off; `false` lifts a declared cap. See [Capping a call's cost](failures.md#capping-a-calls-cost-token-budgets). |
148
149
 
@@ -231,6 +232,14 @@ Source is read with Ruby's own parser (Prism) the first time it's needed and cac
231
232
  `forward_rejected: false` on a step to start it from the original input only, without the rejected output or
232
233
  its errors. Don't put data in those messages that you wouldn't send as an argument.
233
234
 
235
+ Arguments and context are converted to JSON before they are sent. A `Struct`, `Data`, or `OpenStruct` goes as an
236
+ object of its members (its `to_h`, which must return a Hash, is the hook: a `to_json` on these types is not consulted,
237
+ and the class name is not sent), a `Set` as an array, and Hashes and Arrays are walked
238
+ recursively. An exception goes as its class and message. A value that contains itself raises a `ConfigurationError`.
239
+ All members are sent, so pass a Hash or define `to_h` to leave a field out. Any other object goes as the loaded JSON
240
+ library writes it (plain `JSON.generate` sends a `Range`, a `Time`, or a plain object as its `to_s`), so pass a Hash,
241
+ or an object whose `to_json` sends what you mean, when that text isn't what the model should see.
242
+
234
243
  `squish_context` names are read from a method of that name if there is one, otherwise from the instance
235
244
  variable. Only context you name is sent. Instance variables are never dumped wholesale, so API clients,
236
245
  database connections, and secrets stay out of the prompt.
data/docs/testing.md CHANGED
@@ -19,7 +19,8 @@ still hold what the helpers set), so the rest of your `Squishling.configure` sur
19
19
 
20
20
  The helpers change global state (`Squishling.config` and the stubbed classes), so tests that use them must not run
21
21
  in parallel threads. That includes `no_llm_call` / `assert_no_llm_call`, which swap the process-wide `config.adapter`
22
- for the block: a request another thread makes meanwhile is forbidden too, and may be counted in the block's calls.
22
+ (routing every name in `config.adapters` to the guard too) for the block: a request another thread makes meanwhile is
23
+ forbidden too, and may be counted in the block's calls.
23
24
 
24
25
  ## Scripting the model
25
26
 
@@ -58,9 +59,11 @@ A reply is one of:
58
59
  | `:rate_limit`, `:server_error`, `:overloaded`, `:timeout`, `:context_length` | `LLMError` (the next attempt is tried) |
59
60
  | `:bad_request`, `:unauthorized`, `:forbidden` | `ConfigurationError` (never retried, never given to a fallback) |
60
61
 
61
- **Selecting what a rule answers.** `step(model)`, `step(provider: :vertexai)`, and `step(:any)` answer escalation
62
- attempts; `attempt: 2` narrows a step rule to one attempt of the escalation. Rules are matched most specific first
63
- (a sample or the judge, then the rule naming the most of model, provider and attempt, then `step(:any)`), and by
62
+ **Selecting what a rule answers.** `step(model)`, `step(provider: :vertexai)`, `step(adapter: :local)`, and `step(:any)`
63
+ answer escalation attempts; `attempt: 2` narrows a step rule to one attempt of the escalation. The scripted adapter
64
+ answers for every name in `config.adapters`, so `adapter:` selects on the name a step asked for. Rules are matched most
65
+ specific first (a sample or the judge, then the rule naming the most of model, provider, adapter and attempt, then
66
+ `step(:any)`), and by
64
67
  declaration order within that.
65
68
  Scripts are keyed by model, so a rotated tier (`priority:`) gets the same answers whichever model goes first. Which
66
69
  model goes first still depends on how many calls the class has had, so don't assert the order of `fake.models` for a
@@ -91,8 +94,9 @@ and `#verdict` are the real ones; rescue them as you would in production.
91
94
  | | |
92
95
  |---|---|
93
96
  | `arguments`, `context` | the method's arguments and the `squish_context` / `squish!` context the model was sent |
97
+ | `images` | the [`Squishling::Image`s](images.md) sent with the conversation's first message (`[]` when none were) |
94
98
  | `system_prompt`, `output_schema` | the purpose (with `append_to_purpose` sections) and the strict schema |
95
- | `model`, `provider`, `params` | the step it went to |
99
+ | `model`, `provider`, `adapter`, `params`, `cache` | the step it went to (`adapter` is its name from `config.adapters`, `nil` for the default; `cache` is `false` when [prompt caching](configuration.md#prompt-caching) was off for it) |
96
100
  | `role`, `sample`, `attempt`, `attempts` | `nil`/`:sample`/`:judge`, `"a"`, and where it is in the escalation |
97
101
  | `conversation` | the chat it belongs to |
98
102
  | `errors` | the validation messages a retry or escalation carried back to the model |
@@ -142,7 +146,7 @@ removed the stub (it is inert, but keeps the class alive), so stub the classes o
142
146
  squishling_validate(Klass, { "regex" => "[bad(" }, text: "x") # => ["regex is not a valid Ruby regex"]
143
147
  squishling_fallback_for(Klass, Squishling::LLMError.new("x"), text: "x") # the typed fallback result
144
148
  squishling_preview(Klass, text: "x")
145
- # => { system_prompt:, user_message:, output_schema:, step: } # for snapshot tests; makes no request
149
+ # => { system_prompt:, user_message:, images:, output_schema:, step: } # for snapshot tests; makes no request
146
150
  ```
147
151
 
148
152
  Arguments are keywords, or `args: [...]` for positional ones; `receiver:` supplies an instance for a class whose
@@ -181,7 +185,8 @@ can't tell which request is which.
181
185
 
182
186
  ## How it works
183
187
 
184
- `fake_squishling` assigns a `Squishling::Testing::Adapter` (a `Squishling::Adapter::Base`) as `config.adapter`, and an
185
- observer that tells it which role, sample, and attempt each request is. Because it sits behind the same interface as
186
- the real adapters, it needs no knowledge of RubyLLM or any provider, and it is covered by Squishling's own specs.
188
+ `fake_squishling` assigns a `Squishling::Testing::Adapter` (a `Squishling::Adapter::Base`) as `config.adapter`
189
+ (routing every name in `config.adapters` to it too), and an observer that tells it which role, sample, and attempt
190
+ each request is. Because it sits behind the same interface as the real adapters, it needs no knowledge of RubyLLM or
191
+ any provider, and it is covered by Squishling's own specs.
187
192
  Call `Squishling::Testing.install` and `.reset!` yourself if you use a test framework other than the two above.
data/docs/verifying.md CHANGED
@@ -40,7 +40,9 @@ For each squished method (inherited ones too, with the subclass's settings) it c
40
40
  keywords) can't take. Add `**` to accept any. A method that takes `**` or has no implementation can receive any
41
41
  keyword, so nothing is reported for it. `squish_fallback` and `squish_validate` are called with the inputs too, but
42
42
  aren't checked.
43
- - **The adapter** (once): that `config.adapter`, or RubyLLM's, can be built.
43
+ - **The adapter** (once): that `config.adapter`, or RubyLLM's, can be built. When `config.adapters` names others, that
44
+ check moves to each method: every `adapter:` a step or judge names must be configured, and the default adapter is
45
+ only checked for the steps that use it.
44
46
 
45
47
  A problem in an inherited method is reported once for each subclass, since each is checked with its own settings.
46
48