Originally created by: Thanatos9404
Builds on [#67] (
llmslim wrap claude); merge that first. It shares the shortening core moved intollmslim/_tool_output.py.
LLMSlimToolOutputMiddleware is middleware for LangChain 1.x create_agent. It needs pip install "llmslim[langchain-agents]" (Python 3.10+).
agent = create_agent(
"anthropic:claude-haiku-5-5",
tools=[run_tests, search_logs, read_file],
middleware=[LLMSlimToolOutputMiddleware(never={"read_file"})],
)
before_model it takes tool results the model hasn't seen yet (those after the last AIMessage) that are longer than min_tokens.LangChain's built-in ContextEditingMiddleware replaces old tool results with [cleared]. That throws the content away, and it changes the prompt prefix each time it clears, so provider prompt caches miss. Here nothing the model has already seen ever changes:
create_agent, with a scripted chat model that records what it is sent:only/never filters;langchain-anthropic 1.7.6, Claude Haiku 5.5 and adaptive thinking:The module is in the coverage omit list like the other framework adapters. The framework-free shortening in _tool_output.py is measured everywhere.
Originally posted by: vercel[bot]
The latest updates on your projects. Learn more about Vercel for GitHub.
Ticket changed by: Thanatos9404