workspace out of cache; welcome.md
This commit is contained in:
@@ -42,13 +42,14 @@ export class AnthropicCachingMiddleware implements ModelMiddleware {
|
||||
addCacheControl(systemMsg);
|
||||
}
|
||||
|
||||
// 2. Tag the last cacheable message that isn't the current user input.
|
||||
// The current user message is always the last element; we want the one before it.
|
||||
// We look backwards for the last AIMessage or HumanMessage (excluding the final message).
|
||||
// 2. Tag the last AIMessage (assistant turn) before the current user input.
|
||||
// Workspace state is injected as a HumanMessage just before the current user input;
|
||||
// by matching only 'ai' we ensure the cache boundary is the last assistant response,
|
||||
// leaving workspace context and the new user input uncached (always fresh).
|
||||
const candidates = result.slice(0, -1);
|
||||
for (let i = candidates.length - 1; i >= 0; i--) {
|
||||
const t = candidates[i]._getType();
|
||||
if (t === 'ai' || t === 'human') {
|
||||
if (t === 'ai') {
|
||||
addCacheControl(candidates[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user