Skip to content

Releases: MyPrototypeWhat/context-chef

@context-chef/tanstack-ai@0.6.0

Choose a tag to compare

@github-actions github-actions released this 13 Jul 11:42
4cc85f6

Minor Changes

  • #45 09ba1d6 Thanks @MyPrototypeWhat! - Conversation isolation: compression state (fed token usage, compression suppression, the failure circuit breaker) is now tracked per ctx.conversationId instead of per middleware instance. Calls without a conversationId share one default slot (prior behavior). New maxSessions option caps concurrently tracked conversations (default 256, LRU-evicted). Previously a middleware instance reused across chat() calls leaked Janitor state across every conversation it served. Compression flattening now reuses flattenForCompression from @context-chef/core (behavior unchanged).

    An empty-string conversationId now warns once and routes to the default slot (previously it was silently treated as a distinct conversation, diverging from the AI SDK middleware's semantics). The Janitor missing-compression-config nag fires once per middleware instead of once per conversation.

Patch Changes

  • Updated dependencies [09ba1d6]:
    • @context-chef/core@3.9.0

@context-chef/core@3.9.0

Choose a tag to compare

@github-actions github-actions released this 13 Jul 11:42
4cc85f6

Minor Changes

  • #45 09ba1d6 Thanks @MyPrototypeWhat! - Fix Gemini tool call correlation, harden Janitor compression failure paths, and add shared middleware infrastructure.

    • fromGemini now synthesizes tool call IDs with per-name counters spanning the whole conversation and correlates each functionResponse to the oldest unconsumed call of the same name (FIFO). Previously the correlation state was scoped to a single message, so responses arriving in a later content entry always fell back to the -0 suffix — repeat calls of the same tool produced duplicate IDs and misattributed results.
    • When the compression model throws, the raw error is no longer appended to the LLM-bound fallback summary. It now goes to the configured logger (default console) instead, keeping stack traces out of model context.
    • A throwing/rejecting onCompress hook no longer aborts compile(). It is caught and logged via logger; the compression result is kept. Hooks that follow the documented "must not throw" contract see no behavior change.
    • onBeforeCompress (and the deprecated onBudgetExceeded) now degrade the same way: a throwing hook is caught, logged via logger, and treated as if it returned null — default compression proceeds. Both hooks now share one failure stance: a broken hook never fails compile().
    • The text-placeholder vocabulary is centralized in Prompts: new getAttachmentPlaceholder (previously janitor-internal), getToolResultFilePlaceholder, and getToolResultPartPlaceholder. Formats are unchanged — this gives each convention a single source instead of scattered string literals.
    • New export SessionPool<T> — a keyed instance pool with LRU eviction, used by the middleware packages to hold one Janitor per conversation. maxSize is validated (throws RangeError unless a positive integer — a non-positive cap would silently evict every entry on insert, disabling pooling). Companion exports DEFAULT_SESSION_KEY, normalizeSessionKey, and dedupeConstructionWarnings back the middlewares' shared session-key normalization and construction-nag dedupe.
    • New export flattenForCompression(messages) — the canonical role-flattening implementation required by the summarizeHistory compress-callback contract (tool results → user messages, tool calls → assistant text).
    • OpenAIAdapter.compile replaces its per-message JSON.parse(JSON.stringify(...)) deep clone with a direct clone that skips undefined properties — same output, no string serialization detour (noticeable with base64 attachments). The clone honors toJSON, so a Date still lands as its ISO string.

@context-chef/ai-sdk-middleware@2.1.0

Choose a tag to compare

@github-actions github-actions released this 13 Jul 11:42
4cc85f6

Minor Changes

  • #45 09ba1d6 Thanks @MyPrototypeWhat! - Session isolation, lossless-er tool output flattening, and tighter peer ranges.

    • Session isolation: compression state (fed token usage, compression suppression, the failure circuit breaker) is now tracked per session instead of per middleware instance. Pass providerOptions: { contextChef: { sessionId } } on each call; calls without a sessionId share one default session (prior behavior). New maxSessions option caps concurrently tracked sessions (default 256, LRU-evicted). Previously a middleware created at module scope leaked Janitor state across every conversation it served.
    • stringifyToolOutput no longer silently drops non-text content parts: file/media parts flatten to a [tool result file: <mediaType>] placeholder so compression and truncation see that they exist. The truncator's duplicate text extraction now delegates to the same implementation.
    • Tighten peerDependency ranges from >=4 / >=7 to ^4.0.0 / ^7.0.0. The middleware depends on LanguageModelV4* type shapes from @ai-sdk/provider v4 — an unbounded range would let a future major install silently and fail at runtime.
    • Compression flattening now reuses flattenForCompression from @context-chef/core (behavior unchanged).
    • An invalid sessionId (empty string, non-string, or a malformed contextChef namespace) now warns once and routes to the default session instead of failing silently. The Janitor missing-compression-config nag fires once per middleware instead of once per session.

Patch Changes

  • Updated dependencies [09ba1d6]:
    • @context-chef/core@3.9.0

@context-chef/ai-sdk-middleware@2.0.0

Choose a tag to compare

@github-actions github-actions released this 26 Jun 14:03
3d8b524

Major Changes

  • #43 e8ae66a Thanks @MyPrototypeWhat! - Support AI SDK v7 (provider spec V4).

    The middleware now targets ai@>=7 / @ai-sdk/provider@>=4: it implements the V4
    language-model middleware spec (specificationVersion: 'v4') and all public types
    move from LanguageModelV3* to LanguageModelV4*. AI SDK v7's wrapLanguageModel
    rejects a v3-spec middleware, so this is a breaking change that requires AI SDK v7.

    Migration

    • On AI SDK v7 (ai@7): upgrade to @context-chef/ai-sdk-middleware@2.
    • Still on AI SDK v6 (ai@6): stay on @context-chef/ai-sdk-middleware@1 — the 1.x
      line continues to support the v3 spec. No code change is forced on you.

    Removed (deprecated APIs that were slated for removal in the next major):

    • planCompaction, compactHistory, and the CompactionPlan type (the provider-prompt
      altitude variants) — use planCompactionModelMessages / compactModelMessages /
      CompactionPlanModelMessages at the ModelMessage altitude instead.
    • onBudgetExceeded on ContextChefOptions — use onBeforeCompress instead.

    Runtime behavior is unchanged. The only V4 nuance: provider-level FilePart.data
    became a tagged union (SharedV4FileData); the prompt adapter handles it
    transparently and the binary/URL payload still round-trips losslessly.

    On v7, durable in-loop compaction via compactModelMessages inside a
    ToolLoopAgent prepareStep now persists across steps (AI SDK v7 carries
    prepareStep-returned messages forward into later steps — v6 did not).

@context-chef/ai-sdk-middleware@1.6.0

Choose a tag to compare

@github-actions github-actions released this 17 Jun 16:19
f7765bf

Minor Changes

  • #40 55d5c27 Thanks @MyPrototypeWhat! - Add ModelMessage-altitude durable compaction.

    compactModelMessages, planCompactionModelMessages, and summarizeModelMessages operate on ModelMessage[] — the message type generateText/prepareStep actually use — so you can run durable compaction directly against your own message store, or inside a ToolLoopAgent prepareStep. They reuse the provider-agnostic core engine, and compactModelMessages preserves the no-op reference-identity contract (returns the input array unchanged when there is nothing old enough to compact, so callers can skip persistence).

    createCompressionAdapter now accepts ai's LanguageModel (a model id string, or a V3/V2 model) — matching what prepareStep/generateText hand you — instead of only LanguageModelV3.

    Deprecates the LanguageModelV3Prompt-typed compactHistory / planCompaction (still exported and fully working) in favor of the ModelMessage variants; they are slated for removal in the next major. summarizeMessages is unchanged.

    Also fixes three round-trip issues in both AI-SDK adapters (V3 and ModelMessage): provider-executed (inline) tool-results no longer trigger a spurious [No tool result available] placeholder; tool-message-level providerOptions (e.g. Anthropic cache control) is now preserved; and a tool-call with undefined input serializes to "{}" instead of a non-string value.

@context-chef/tanstack-ai@0.5.2

Choose a tag to compare

@github-actions github-actions released this 16 Jun 12:24
0c28e55

Patch Changes

  • Updated dependencies [a461ef8]:
    • @context-chef/core@3.8.0

@context-chef/core@3.8.0

Choose a tag to compare

@github-actions github-actions released this 16 Jun 12:24
0c28e55

Minor Changes

  • a461ef8 Thanks @MyPrototypeWhat! - Add caller-owned durable compaction helpers (provider-agnostic in core), and warn when in-flight compress is used without persistence.

    • @context-chef/coreplanCompaction / compactHistory: the durable compaction engine, operating on the IR Message[] so any provider path can use it.
      • compactHistory(history, compress, options): one-shot durable compaction — splits on turn boundaries, summarizes the old slice via summarizeHistory, and returns a new history ready to persist ([...system, <wrapped summary>, ...recent turns]). Returns the input history reference unchanged when there is nothing old enough to compact or the summarizer yields no text, so callers can skip persistence via result === history. compress is injected (core never calls a model directly).
      • planCompaction(history, { keepRecentTurns }): the synchronous split, returning { system, toSummarize, toKeep }. Cuts only on turn boundaries (an assistant + its tool results stay together), so it never orphans a tool result or splits a multi-block assistant message; system messages are preserved verbatim and never summarized. Input is a flat Message[] with system inline.
    • @context-chef/ai-sdk-middlewarecompactHistory(prompt, model, options) / planCompaction(prompt, options): thin AI-SDK wrappers over the core engine — they convert the prompt to core's IR and back, and bind the model into the compression callback. Same signatures and behavior as before, including the no-op reference guarantee.
    • Persistence warning: the middleware now logs a one-time warning when compress keeps firing without an onCompress hook. In-flight compression only rewrites each outgoing request — without write-back the history re-expands every call and the payload grows unbounded. Steers users toward onCompress persistence or compactHistory for sustained over-budget conversations.

    No behavior change to existing configurations; the new exports are additive.

@context-chef/ai-sdk-middleware@1.5.2

Choose a tag to compare

@github-actions github-actions released this 16 Jun 12:24
0c28e55

Patch Changes

  • a461ef8 Thanks @MyPrototypeWhat! - Add caller-owned durable compaction helpers (provider-agnostic in core), and warn when in-flight compress is used without persistence.

    • @context-chef/coreplanCompaction / compactHistory: the durable compaction engine, operating on the IR Message[] so any provider path can use it.
      • compactHistory(history, compress, options): one-shot durable compaction — splits on turn boundaries, summarizes the old slice via summarizeHistory, and returns a new history ready to persist ([...system, <wrapped summary>, ...recent turns]). Returns the input history reference unchanged when there is nothing old enough to compact or the summarizer yields no text, so callers can skip persistence via result === history. compress is injected (core never calls a model directly).
      • planCompaction(history, { keepRecentTurns }): the synchronous split, returning { system, toSummarize, toKeep }. Cuts only on turn boundaries (an assistant + its tool results stay together), so it never orphans a tool result or splits a multi-block assistant message; system messages are preserved verbatim and never summarized. Input is a flat Message[] with system inline.
    • @context-chef/ai-sdk-middlewarecompactHistory(prompt, model, options) / planCompaction(prompt, options): thin AI-SDK wrappers over the core engine — they convert the prompt to core's IR and back, and bind the model into the compression callback. Same signatures and behavior as before, including the no-op reference guarantee.
    • Persistence warning: the middleware now logs a one-time warning when compress keeps firing without an onCompress hook. In-flight compression only rewrites each outgoing request — without write-back the history re-expands every call and the payload grows unbounded. Steers users toward onCompress persistence or compactHistory for sustained over-budget conversations.

    No behavior change to existing configurations; the new exports are additive.

  • Updated dependencies [a461ef8]:

    • @context-chef/core@3.8.0

@context-chef/tanstack-ai@0.5.1

Choose a tag to compare

@github-actions github-actions released this 14 Jun 07:46
49cc570

Patch Changes

  • Updated dependencies [63e857c]:
    • @context-chef/core@3.7.1

@context-chef/core@3.7.1

Choose a tag to compare

@github-actions github-actions released this 14 Jun 07:46
49cc570

Patch Changes

  • #36 63e857c Thanks @MyPrototypeWhat! - Expose one-shot history summarization as a standalone API.

    • summarizeHistory(messages, compress, opts?) (core): produces a compression summary for a message slice using the same prompt, attachment/tool-result stripping, and <summary> extraction as the in-flight compress path. Extracted from Janitor.executeCompression, which now delegates to it (behavior-identical). Pure — an empty slice returns '' without a model call, and it throws on model failure (the Janitor keeps its own circuit breaker + fallback). The compress callback must role-flatten tool/assistant-tool-call messages.
    • summarizeMessages(prompt, model, opts?) (ai-sdk-middleware): thin AI-SDK wrapper — fromAISDK (drops system messages) → compression adapter (role-flattening) → summarizeHistory. Returns the raw summary text (wrap with Prompts.getCompactSummaryWrapper for the continuation framing).

    For hosts that own their conversation store and persist compression themselves (durable compaction) rather than relying on in-flight middleware compression. When driving summarization this way, do not also configure compress (with a model) on the same path — that would compress twice. A notification-only onCompress, plus truncate/clear/dynamicState, remain safe alongside.