Releases: MyPrototypeWhat/context-chef
Release list
@context-chef/tanstack-ai@0.6.0
Minor Changes
-
#45
09ba1d6Thanks @MyPrototypeWhat! - Conversation isolation: compression state (fed token usage, compression suppression, the failure circuit breaker) is now tracked perctx.conversationIdinstead of per middleware instance. Calls without aconversationIdshare one default slot (prior behavior). NewmaxSessionsoption 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 reusesflattenForCompressionfrom@context-chef/core(behavior unchanged).An empty-string
conversationIdnow 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
Minor Changes
-
#45
09ba1d6Thanks @MyPrototypeWhat! - Fix Gemini tool call correlation, harden Janitor compression failure paths, and add shared middleware infrastructure.fromGemininow synthesizes tool call IDs with per-name counters spanning the whole conversation and correlates eachfunctionResponseto 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-0suffix — 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(defaultconsole) instead, keeping stack traces out of model context. - A throwing/rejecting
onCompresshook no longer abortscompile(). It is caught and logged vialogger; the compression result is kept. Hooks that follow the documented "must not throw" contract see no behavior change. onBeforeCompress(and the deprecatedonBudgetExceeded) now degrade the same way: a throwing hook is caught, logged vialogger, and treated as if it returnednull— default compression proceeds. Both hooks now share one failure stance: a broken hook never failscompile().- The text-placeholder vocabulary is centralized in
Prompts: newgetAttachmentPlaceholder(previously janitor-internal),getToolResultFilePlaceholder, andgetToolResultPartPlaceholder. 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.maxSizeis validated (throwsRangeErrorunless a positive integer — a non-positive cap would silently evict every entry on insert, disabling pooling). Companion exportsDEFAULT_SESSION_KEY,normalizeSessionKey, anddedupeConstructionWarningsback the middlewares' shared session-key normalization and construction-nag dedupe. - New export
flattenForCompression(messages)— the canonical role-flattening implementation required by thesummarizeHistorycompress-callback contract (tool results → user messages, tool calls → assistant text). OpenAIAdapter.compilereplaces its per-messageJSON.parse(JSON.stringify(...))deep clone with a direct clone that skipsundefinedproperties — same output, no string serialization detour (noticeable with base64 attachments). The clone honorstoJSON, so aDatestill lands as its ISO string.
@context-chef/ai-sdk-middleware@2.1.0
Minor Changes
-
#45
09ba1d6Thanks @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 asessionIdshare one default session (prior behavior). NewmaxSessionsoption caps concurrently tracked sessions (default 256, LRU-evicted). Previously a middleware created at module scope leaked Janitor state across every conversation it served. stringifyToolOutputno 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/>=7to^4.0.0/^7.0.0. The middleware depends onLanguageModelV4*type shapes from@ai-sdk/providerv4 — an unbounded range would let a future major install silently and fail at runtime. - Compression flattening now reuses
flattenForCompressionfrom@context-chef/core(behavior unchanged). - An invalid
sessionId(empty string, non-string, or a malformedcontextChefnamespace) 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.
- Session isolation: compression state (fed token usage, compression suppression, the failure circuit breaker) is now tracked per session instead of per middleware instance. Pass
Patch Changes
- Updated dependencies [
09ba1d6]:- @context-chef/core@3.9.0
@context-chef/ai-sdk-middleware@2.0.0
Major Changes
-
#43
e8ae66aThanks @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 fromLanguageModelV3*toLanguageModelV4*. AI SDK v7'swrapLanguageModel
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 theCompactionPlantype (the provider-prompt
altitude variants) — useplanCompactionModelMessages/compactModelMessages/
CompactionPlanModelMessagesat theModelMessagealtitude instead.onBudgetExceededonContextChefOptions— useonBeforeCompressinstead.
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
compactModelMessagesinside a
ToolLoopAgentprepareStepnow persists across steps (AI SDK v7 carries
prepareStep-returned messages forward into later steps — v6 did not). - On AI SDK v7 (
@context-chef/ai-sdk-middleware@1.6.0
Minor Changes
-
#40
55d5c27Thanks @MyPrototypeWhat! - Add ModelMessage-altitude durable compaction.compactModelMessages,planCompactionModelMessages, andsummarizeModelMessagesoperate onModelMessage[]— the message typegenerateText/prepareStepactually use — so you can run durable compaction directly against your own message store, or inside aToolLoopAgentprepareStep. They reuse the provider-agnostic core engine, andcompactModelMessagespreserves the no-op reference-identity contract (returns the input array unchanged when there is nothing old enough to compact, so callers can skip persistence).createCompressionAdapternow acceptsai'sLanguageModel(a model id string, or a V3/V2 model) — matching whatprepareStep/generateTexthand you — instead of onlyLanguageModelV3.Deprecates the
LanguageModelV3Prompt-typedcompactHistory/planCompaction(still exported and fully working) in favor of the ModelMessage variants; they are slated for removal in the next major.summarizeMessagesis 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-levelproviderOptions(e.g. Anthropic cache control) is now preserved; and a tool-call withundefinedinput serializes to"{}"instead of a non-string value.
@context-chef/tanstack-ai@0.5.2
Patch Changes
- Updated dependencies [
a461ef8]:- @context-chef/core@3.8.0
@context-chef/core@3.8.0
Minor Changes
-
a461ef8Thanks @MyPrototypeWhat! - Add caller-owned durable compaction helpers (provider-agnostic in core), and warn when in-flightcompressis used without persistence.@context-chef/core—planCompaction/compactHistory: the durable compaction engine, operating on the IRMessage[]so any provider path can use it.compactHistory(history, compress, options): one-shot durable compaction — splits on turn boundaries, summarizes the old slice viasummarizeHistory, and returns a new history ready to persist ([...system, <wrapped summary>, ...recent turns]). Returns the inputhistoryreference unchanged when there is nothing old enough to compact or the summarizer yields no text, so callers can skip persistence viaresult === history.compressis 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 flatMessage[]with system inline.
@context-chef/ai-sdk-middleware—compactHistory(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
compresskeeps firing without anonCompresshook. In-flight compression only rewrites each outgoing request — without write-back the history re-expands every call and the payload grows unbounded. Steers users towardonCompresspersistence orcompactHistoryfor sustained over-budget conversations.
No behavior change to existing configurations; the new exports are additive.
@context-chef/ai-sdk-middleware@1.5.2
Patch Changes
-
a461ef8Thanks @MyPrototypeWhat! - Add caller-owned durable compaction helpers (provider-agnostic in core), and warn when in-flightcompressis used without persistence.@context-chef/core—planCompaction/compactHistory: the durable compaction engine, operating on the IRMessage[]so any provider path can use it.compactHistory(history, compress, options): one-shot durable compaction — splits on turn boundaries, summarizes the old slice viasummarizeHistory, and returns a new history ready to persist ([...system, <wrapped summary>, ...recent turns]). Returns the inputhistoryreference unchanged when there is nothing old enough to compact or the summarizer yields no text, so callers can skip persistence viaresult === history.compressis 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 flatMessage[]with system inline.
@context-chef/ai-sdk-middleware—compactHistory(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
compresskeeps firing without anonCompresshook. In-flight compression only rewrites each outgoing request — without write-back the history re-expands every call and the payload grows unbounded. Steers users towardonCompresspersistence orcompactHistoryfor 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
Patch Changes
- Updated dependencies [
63e857c]:- @context-chef/core@3.7.1
@context-chef/core@3.7.1
Patch Changes
-
#36
63e857cThanks @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-flightcompresspath. Extracted fromJanitor.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). Thecompresscallback 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 withPrompts.getCompactSummaryWrapperfor 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 amodel) on the same path — that would compress twice. A notification-onlyonCompress, plustruncate/clear/dynamicState, remain safe alongside.