Created
January 10, 2026 15:02
-
-
Save larkintuckerllc/c0e4a005d2cbecaaa829b8d43585dd8c to your computer and use it in GitHub Desktop.
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
| diff --git a/app.py b/app.py | |
| index e101a85..a7d3334 100644 | |
| --- a/app.py | |
| +++ b/app.py | |
| @@ -2,6 +2,7 @@ import os | |
| import threading | |
| from langchain.agents import create_agent | |
| +from langchain.agents.middleware import SummarizationMiddleware | |
| from langgraph.checkpoint.memory import InMemorySaver | |
| from langchain.messages import HumanMessage | |
| from langchain.tools import tool | |
| @@ -29,6 +30,13 @@ def square_root(x: float) -> float: | |
| agent = create_agent( | |
| checkpointer=InMemorySaver(), | |
| + middleware=[ | |
| + SummarizationMiddleware( | |
| + model="gpt-5-nano", | |
| + trigger=("tokens", 10000), | |
| + keep=("messages", 4) | |
| + ) | |
| + ], | |
| model="gpt-5-nano", | |
| tools=[square_root], | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment