You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add immutable, request-scoped knowledge snapshots to Python and TypeScript agents
propagate the same selected knowledge through direct, draft, verifier, streaming, and tool execution paths
use content-bound native prompt-cache hints for OpenAI and Anthropic while keeping all other providers correct without cache support
expose cached input/write token telemetry
add an optional tool-first MCP server adapter for ChatGPT, Claude, and Claude Desktop
document the correctness model, cost constraints, and MCP deployment choices
Why
Model cascades could switch providers without an explicit versioned knowledge handoff, creating two failure modes: a verifier starting without the selected knowledge, or a later/concurrent request inheriting stale implicit state. Replaying full histories and knowledge bases also undermines cascadeflow's cost-saving goal.
This change makes knowledge immutable and request-scoped. Every selected model receives the same stable prefix. Provider prompt caches are treated only as a billing/latency optimization, never as the source of correctness.
Provider cache keys include both logical identity and content digest, preventing stale provider-side reuse even after local LRU eviction or process restart. Applications are expected to retrieve only the relevant passages before constructing a snapshot.
MCP integration
The new optional MCP factory resolves knowledge server-side from a key/version. Clients send only the current query and an optional bounded conversation handoff; private knowledge text is not returned in the tool result.
This lets ChatGPT and Claude invoke cascadeflow routing, but it does not replace the host model. The host tool-selection turn remains part of end-to-end cost and latency. The initial adapter is tool-first; a standard MCP Apps routing/savings panel can be layered on later without changing routing logic.
Validation
Python: 1,320 passed, 91 skipped
TypeScript: 1,100 passed, 21 skipped
TypeScript typecheck passed
TypeScript production build passed
Ruff passed
Black passed
Python compileall passed
ESLint completed with zero errors (existing repository warnings remain)
git diff checks passed
API examples
Python:
knowledge=KnowledgeSnapshot(
key="support-manual",
version="2026-08-06",
content=retrieved_text,
cache_ttl="1h",
)
result=awaitagent.run("How do I reset it?", knowledge=knowledge)
TypeScript:
constresult=awaitagent.run("How do I reset it?",{knowledge: {key: "support-manual",version: "2026-08-06",content: retrievedText,cacheTtl: "1h",},});
The benchmark found and fixed an important GPT-5.6 edge: prompt_cache_key alone does not prevent a changing query suffix from becoming a new cache write. Commit eb9ae9b places an explicit breakpoint at the stable knowledge boundary and enables explicit cache mode for GPT-5.6+, across Python and TypeScript, streaming, tools, Responses, and Chat Completions.
These are deterministic payload/token and official-rate-model results, not live billed API calls, because no OpenAI or Anthropic API keys were configured in the test environment. Provider payload shape, read/write telemetry extraction, and cache-boundary behavior are covered by tests.
Commit 4d63adb additionally makes reported result costs cache-aware in both SDKs. OpenAI costs now distinguish uncached input, 0.1x cache reads, and GPT-5.6 1.25x cache writes. Anthropic costs distinguish base input, 0.1x reads, 1.25x five-minute writes, and 2x one-hour writes. The mappings use provider-reported usage categories and recognize current aliases, including vendor-prefixed model IDs.
Validation after the cost-accounting update:
Python: 1,324 passed, 91 skipped
TypeScript: 1,111 passed, 21 skipped
provider-focused Python: 37 passed, 1 skipped
Python formatting/lint, TypeScript typecheck/build, and diff checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
Model cascades could switch providers without an explicit versioned knowledge handoff, creating two failure modes: a verifier starting without the selected knowledge, or a later/concurrent request inheriting stale implicit state. Replaying full histories and knowledge bases also undermines cascadeflow's cost-saving goal.
This change makes knowledge immutable and request-scoped. Every selected model receives the same stable prefix. Provider prompt caches are treated only as a billing/latency optimization, never as the source of correctness.
Provider cache keys include both logical identity and content digest, preventing stale provider-side reuse even after local LRU eviction or process restart. Applications are expected to retrieve only the relevant passages before constructing a snapshot.
MCP integration
The new optional MCP factory resolves knowledge server-side from a key/version. Clients send only the current query and an optional bounded conversation handoff; private knowledge text is not returned in the tool result.
This lets ChatGPT and Claude invoke cascadeflow routing, but it does not replace the host model. The host tool-selection turn remains part of end-to-end cost and latency. The initial adapter is tool-first; a standard MCP Apps routing/savings panel can be layered on later without changing routing logic.
Validation
API examples
Python:
TypeScript: