Skip to content

v0.3.0

Latest

Choose a tag to compare

@github-actions github-actions released this 16 Aug 00:29
v0.3.0
a47ef7b

Breaking changes

  • Stream chunks are now incremental deltas. Session::stream_response previously delivered the framework's cumulative snapshot on every callback; it now delivers only the newly generated suffix, so concatenating chunks yields the full response (Unicode-safe, computed on UTF-8 bytes). stream_json keeps cumulative-snapshot semantics and now documents them.
  • TokenUsage gained an estimated: bool field. The chars/4 heuristic fallback is now distinguishable from a framework tokenizer measurement. Code constructing or exhaustively destructuring TokenUsage must be updated.
  • ContextUsage::utilization changed denominator. It is now measured against the available budget (window minus reserved response tokens) so it aligns with over_limit, instead of the raw window size.
  • Compaction fails fast instead of degrading silently. compact_transcript errors on an empty summarizer response, and compact_session_if_needed errors when the compacted session still exceeds the budget.

New

  • Session::cancellation_handle() — a Send + Sync handle that cancels an in-flight blocking or streaming generation from another thread and exposes is_responding(). Handles are session-scoped: cancel() targets whichever generation is active at call time.
  • Error::Cancelled — cancellation is now a typed error preserving the framework message (Python: still raised as GenerationError, matching the documented contract).
  • Stream callbacks no longer require 'static, so they can borrow local accumulators.

Fixed

  • Tool-enabled sessions leaked their ToolCallbackData (and every registered tool) for the life of the process (#3, thanks @maxiboch).
  • Panics in Tool::call, stream chunk callbacks, or tool Drop impls no longer abort the host process; they surface as tool/stream errors, and a chunk-callback panic now cancels the generation.
  • Blocking generations are registered for cancellation, and completion vs. cancellation is arbitrated under a lock — a cancel landing after the last chunk no longer misreports a delivered stream, and cancel/timeout now unblocks a generation stuck inside a blocking Rust tool.
  • Error strings returned over FFI are owned copies (strdup) instead of pointers into bridged temporaries.
  • Tool dispatch: names are matched trimmed end to end, schema-declared string arguments are no longer coerced to numbers/booleans, and the model is told which required arguments it omitted so it retries instead of the tool silently running on defaults.
  • Tool callbacks run off the Swift cooperative thread pool, removing a deadlock path for re-entrant tools.
  • Compaction splits messages that exceed the chunk budget (single pass) so summarization can no longer blow the very context window it protects.
  • Streaming clears stale per-response usage; extractBalancedJson is linear instead of quadratic.
  • iOS builds get the correct Swift runtime search path, and the Swift FFI layer is compiled with -O/-Osize matching the Cargo profile instead of always -Onone.

Docs

  • SystemTool::Ocr/BarcodeReader: label image attachments with with_label(...) and reference the label in the prompt for reliable tool invocation.
  • Timeout methods document that cooperative cancellation lets an abandoned generation drain in the background (ConcurrentRequests on retry, late tool side effects).

Rust

[dependencies]
fm-rs = "0.3.0"

Python

pip install fm-rs==0.3.0

Documentation

What's Changed

  • fix: reclaim ToolCallbackData handed to Swift by @maxiboch in #3
  • style: format leak_repro and fix clippy pedantic lints by @blacktop in #4

New Contributors

Full Changelog: v0.2.1...v0.3.0