A LangChain agent middleware that provides a plain-text scratchpad/notepad.
Project description
LangChain Notepad Middleware
A production-grade LangChain middleware that provides a plain-text persistent "scratchpad" (notepad) for agents to store intermediate state across multi-hop tasks.
Installation
pip install langchain-notepad-middleware
Usage
from langchain.agents import create_agent
from langchain_middleware_notepad import NotePadMiddleware
# Create an agent with the middleware
agent = create_agent(
model="openai:gpt-4o",
tools=[...], # Your other tools
middleware=[NotePadMiddleware()],
)
How it Works
The middleware injects a system prompt instructing the model to use the notepad for scratchpad memory. It also registers 5 tools for manipulating the notepad state:
notepad_append(text): Append text to the note.notepad_replace(text): Overwrite the entire note.notepad_read(): Read the current note content.notepad_is_exist(): Check if a non-empty note exists.notepad_clear(): Clear the note.
The state is stored in a simple string field notepad within the agent state.
Best Practices
- Use
appendfor logging cumulative steps. - Use
replacewhen summarizing or changing topics. - The middleware automatically injects prompt guidance, so you don't typically need to manually prompt the agent to use it, although specific task instructions help.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_notepad_middleware-0.1.0.tar.gz.
File metadata
- Download URL: langchain_notepad_middleware-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c7c170dc922640b58ceef27beef7510327267793df6c62e276e2cd9b0ac6272
|
|
| MD5 |
5453e87028dd600cf0a343b0fa803f88
|
|
| BLAKE2b-256 |
c6267518c7f914a15bc081ca8754459536a2bea98ccfc277c9acce85ef442461
|
File details
Details for the file langchain_notepad_middleware-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_notepad_middleware-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ef2effcb7646ea587208fe5cac2b8dcd700981ad00a87b1d8b198be99cc3461
|
|
| MD5 |
7220712a01d9c0045990049640ace73d
|
|
| BLAKE2b-256 |
2f283ba9795c0098b8766fe49c4b1302b184259451af4127c15511e2dc87ae5d
|