I am trying contextEditingMiddleware for one our use case. I don’t see the middleware being invoked at all. Tried with lot of configuration but did n’t see the log. code snippet
const supervisor = createAgent({
model: llm,
tools: workerTools,
checkpointer, /
middleware: [
loggingMiddleware2,
contextEditingMiddleware({
edits: [
new ClearToolUsesEdit({
triggerTokens: 2000, // Lower threshold for demo (default is 100K)
keep: { messages: 3 }, // Keep 3 most recent tool results
clearToolInputs: false, // Keep tool call arguments for context
excludeTools: [], // No tools excluded from clearing
placeholder: "[cleared]", // Placeholder for cleared results
}),
],
tokenCountMethod: "approx", // Use approximate counting for speed
}),
],
systemPrompt: `system prompt`,
});
even if i don’t see the function trace in langsmith (waterfall). See the pic attached. Any other configuration that I am missing here?
thank you for the update. Let me recheck the app. if I am not wrong, the token size was also not reduced after the threshold was reached. However, I will reverify and the update here.
Looks like your assessment is correct. I did verify again. I could see the token size (count) is being reset. See the screenshot attached. All these are part of a single thread_id.