Skip to content

v0.8.1

Latest

Choose a tag to compare

@mikecarroll mikecarroll released this 30 Nov 17:55
a84c9e5

πŸš€ What's New

Squishling v0.8.1 gives a rate limit its own error (RateLimitError, with retry_after) and moves an escalation on to the next model instead of retrying the throttled one. It lets an app pick its adapter from a list of candidates or with SQUISHLING_ADAPTER, lets an outer-loop agent take squawk's reports through an optional report method, and types results through chained and recursive $refs. It also hardens inputs (a 100 MB cap on the files of one call) and makes every sample of a round reach squawk. A few things change behavior, so read the upgrade notes first.

gem "squishling", "~> 0.8"

Requires Ruby 3.3+ and an adapter: the ruby_llm gem (2.2+) or any OpenAI-compatible endpoint.


⚠️ Upgrading from 0.8.0

A 429 no longer spends a step's remaining attempts. It used to be a plain LLMError and was retried on the same model. Now an escalation skips the rest of that step's attempts and moves to the next step; with no next step the RateLimitError is raised (or handed to squish_fallback). A sample raises it at once, and a judge skips the same way. A test that scripted fail(:rate_limit) and relied on the same-model retry now moves to the next step: use :server_error for a failure you want retried. (#147)

A call that sends more than 100 MB of files is refused with InputRejectedError before any request. That is above what any provider takes in one request, so such a call was already failing after the bytes had been read and encoded. config.max_total_file_bytes = nil restores the old behavior. (#146)

A schema that loops back on itself is a ConfigurationError when it is built (a $ref to itself, or through nothing but allOf, anyOf, oneOf, not or if), and Squishling.verify reports it. It used to overflow the validator's stack after the request was paid for. Recursion through properties or items is fine. A schema first reached through a longer $ref chain now also gets the checks an inline one gets, so set type: "object" where it has properties, and rename a reserved property name. (#152, thanks @yorzi)

Smaller behavior changes

  • In a sample round (:squishsum, :judged_squishsum, a custom harness), every sample that was asked is now reported to squawk and the outer-loop agent before the first terminal error is raised. A sibling's output is checked after another sample failed for good, so an exception from squish_validate, a field's validate:, the squawk hook or an outer-loop agent raised there replaces the sample's error, and a squish_fallback that would have run before doesn't. (#153, thanks @yorzi, and #156)
  • InputRejectedError paths quote only an identifier-shaped Symbol Hash key; every String key is masked as [key]. (#144)
  • An outer-loop agent that already has an unrelated method named report is now treated as the new hook, and positional arguments raise ConfigurationError when it is assigned. Rename the method. (#145)

🚦 RateLimitError

A 429, once the adapter's own retries are used up, raises Squishling::RateLimitError, an LLMError with the provider's wait in seconds (capped at an hour, or nil). A rescue LLMError and squish_fallback still catch it. Squishling never sleeps; retry_after is yours to use:

begin
  Triager.call(text: ticket)
rescue Squishling::RateLimitError => e
  RetryJob.set(wait: e.retry_after || 60).perform_later(ticket.id)
end

Both built-in adapters raise it, a custom adapter gets it through http_failure(status, retry_after:), and the OpenAI-compatible adapter's own backoff now honors an HTTP-date Retry-After too. Squishling::Testing scripts it with fail(:rate_limit, retry_after: 30). See Rate limits. (#147)

πŸ”Œ Choosing the adapter: candidates and SQUISHLING_ADAPTER

config.adapter takes a list and uses the first entry that is registered, has its gem, and answers available? (a new optional Adapter::Base hook):

Squishling.configure do |config|
  config.adapter = [{ type: :apple_fm, ignore_unsupported_params: true }, :ruby_llm]
end

With no usable entry the first call, and Squishling.verify, raises a ConfigurationError naming each skipped candidate and why, never its options. SQUISHLING_ADAPTER=<name> replaces the default adapter ahead of config.adapter, so a developer or a deploy can pick another one without a code change. The name is a config.adapters entry or a candidate, else the adapter you configured of that class (so SQUISHLING_ADAPTER=openai_compatible uses your base_url, not OpenAI's), else a registered adapter built with no options; two configured adapters of one class is a ConfigurationError asking you to name one. An escalation step's own adapter: and Squishling::Testing still win. See Adapters. (#148, #167)

πŸ“‘ Outer-loop agents can take reports

An outer-loop agent can define an optional report(output:, metadata:, error:) and be sent the reports squawk gets: same keywords, same squawk_on: gate, the stopped call's final report once.

class AuditAgent
  def around(call) = yield
  def report(output:, metadata:, error:)
    Audit.record(metadata[:call_id], output: output, error: error&.class&.name)
  end
end

It is the deliberate opt-in to output reaching an agent: around and an agent without report (the Coolhand one among them) still never see output, and squawk: false silences report too. See Outer-loop agents. (#145)

🧩 Results typed through chained and recursive schemas

A result typed through a $ref chain longer than two hops, an escaped name, an array index, or a recursive schema used to lose its fields and come back as a plain Hash (or raise). The builder now follows json_schemer's resolved references for as long as nothing typed it, and a result that was typed before is typed the same. Thanks @yorzi. (#152)


πŸ”’ Security and Fixes

  • A 100 MB cap on the files of one call (config.max_total_file_bytes), checked before each read where the size is known so the file that would cross it is refused unread. Image.from_path holds a file to max_file_bytes too, checking its size before reading it. See Inputs. (#146)
  • A String Hash key such as "jane_doe" or "MRN12345" no longer shows up in an InputRejectedError path. (#144)
  • A URL that Image.from_url refuses, or an OpenAI-compatible base_url the parser refuses, no longer stays on the error as its cause (the parser's message quotes the whole URL, query string and credentials included).
  • An apprentice running on a non-inline runner gets a copy of the call's inputs, so a caller changing them after returning can't alter what compare:, squish_validate, include_when: or the report see; an input nested past JSON's limit is refused instead of overflowing the stack. (#146)
  • Squishling.verify checks the include_when: keywords of an escalation step declared on a squish_rescue, which it skipped, so a mismatched one failed with ArgumentError at runtime. Thanks @yorzi. (#136)
  • Every sample of a round now reaches squawk, a sample's request is produced only once Run#samples returns (so accepted_request_id names the right request), and a BudgetExhaustedError lists each completed round's models. Thanks @yorzi. (#153, #156)
  • A judged harness no longer raises a bare JSON::NestingError when a candidate reply sits at JSON's nesting limit, and concurrent sample requests are stopped if a later request thread can't be created.
  • Data.define(:"a=") while building a result class is now a ConfigurationError, and Perplexity's preset is a reserved params: key. (#146)

⚠️ Worth Knowing

  • #133: partly fixed (the file-bytes cap and Image.from_path). Still open: a Pathname argument reads any file it names, including through symlinks, so never pass one a path a user chose; and squish_rescue leaves the original Ruby error as the cause of an InputRejectedError raised in the hand-off, which can carry a path.
  • #134: RubyLLM can still download a URL image from your process for providers that can't take a URL (such as Gemini and Bedrock). If a user can choose the URL, allow-list its host and scheme, or pass the bytes with Image.new(data:).
  • #149: the lower-severity findings from the v0.8.0 review (sample reporting and Image.from_url's cause are fixed in this release; the rest are still open).
  • #150: a hook that takes the method's inputs raises a raw ArgumentError for an omitted defaulted keyword, and Squishling.verify doesn't flag it.
  • #91, #92, #93: reserved params keys are matched case-sensitively; some overlong-prompt detection still follows message text; and whether the API key can be captured from in-flight local variables is being investigated.
  • Found in this release's review and filed to investigate: #158 (a schema that loops through then, dependentSchemas or $dynamicRef can overflow the stack at validation), #159 (a reply of 5.0 for an integer field comes back as a Float), #160 (failed validation of a huge reply is expensive), and #161 through #166.

πŸ™ Thanks

Thank you to @yorzi for three fixes in this release: #136 (include_when: checks for squish_rescue escalations), #152 (results typed through chained and recursive schema references) and #153 (every completed sample reaching squawk).


πŸ”— Resources