POPMiddleware for LangChain agents.
Project description
langchain-pop
langchain-pop is a preview middleware package that brings portable persona objects into LangChain agent runtimes.
It allows POP persona objects to be loaded into LangChain, injected as runtime persona framing, and enforced through boundary-aware tool filtering. The package is designed as a middleware and toolkit-style ecosystem integration for the Persona Object Protocol (POP), not as a replacement for LangChain's own agent abstractions.
Status
langchain-pop is an early integration preview.
Current capabilities include:
- POP v1 canonical object loading
- legacy
pop-0.1migration - persona-aware system prompt construction
- boundary-based tool filtering
- LangChain agent construction via
create_pop_agent(...)
This package currently demonstrates runtime integration and middleware behavior. It does not yet provide a full interoperability benchmark or production-grade governance system.
Installation
Minimal install
pip install langchain-pop
With OpenAI provider support
pip install "langchain-pop[openai]"
Quick Start
from langchain_openai import ChatOpenAI
from langchain_pop.agent import create_pop_agent
def knowledge_lookup(topic: str) -> str:
"""Look up a topic in a mock knowledge base."""
return f"Knowledge lookup result for: {topic}"
agent = create_pop_agent(
pop_source="tests/fixtures/mentor.v1.json",
model=ChatOpenAI(model="gpt-4o", temperature=0.0),
tools=[knowledge_lookup],
name="mentor_agent",
)
print(agent)
To inspect the generated runtime configuration without invoking a live model:
python examples/langchain_middleware_demo.py --print-config
What langchain-pop does
langchain-pop maps a POP persona object into LangChain runtime components:
- persona role and traits -> system-level runtime framing
- persona boundaries -> runtime tool filtering
- POP identity fields -> runtime persona state
This makes persona handling more structured than ad hoc prompt-only role injection and aligns the integration with a toolkit-style runtime workflow instead of a thin adapter layer.
Example: Middleware Preview
from langchain_pop.middleware import POPMiddleware
middleware = POPMiddleware("tests/fixtures/mentor.v1.json")
print(middleware.persona_state())
print(middleware.system_prompt)
Example: Legacy Migration
Legacy pop-0.1 objects are supported through automatic migration:
from langchain_pop.agent import create_pop_agent
from langchain_openai import ChatOpenAI
agent = create_pop_agent(
pop_source="tests/fixtures/mentor.pop01.json",
model=ChatOpenAI(model="gpt-4o", temperature=0.0),
tools=[],
)
Design Scope
langchain-pop is designed as a LangChain ecosystem integration for portable persona objects.
It is not:
- a full agent framework
- a replacement for LangChain middleware
- a production governance framework
- a complete interoperability standard
Its purpose is to demonstrate that POP persona objects can function as runtime-integrated persona middleware in a real agent stack.
Docs PR Draft
The repository includes a docs-PR-oriented draft page in two forms:
docs/langchain_pop.mdx: toolkit-oriented draft matching the LangChain docs naming styledocs/langchain-docs-pr-draft.md: local draft copy for iterative editing
Repository Structure
langchain-pop/
├── src/langchain_pop/
│ ├── __init__.py
│ ├── _pop_compat.py
│ ├── middleware.py
│ └── agent.py
├── tests/
├── examples/
├── docs/
└── README.md
Development
Run tests:
python -m unittest discover -s tests -v
Build distributions:
python -m build
Run demo:
python examples/langchain_middleware_demo.py --print-config
For local editable development:
pip install -e .
Relationship to POP
langchain-pop is an ecosystem integration layer for portable persona objects.
persona-object-protocoldefines the protocol semantics, schema, examples, and reference tooling.langchain-popdemonstrates how POP persona objects can be consumed inside a real agent runtime.
In other words:
- POP = protocol layer
langchain-pop= runtime integration layer
Maturity
This package should currently be understood as:
- an early middleware preview
- a runtime integration proof point
- a bridge between POP and LangChain agents
It should not yet be interpreted as a final or official LangChain standard component.
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_pop-0.1.2.tar.gz.
File metadata
- Download URL: langchain_pop-0.1.2.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b0b843e4050398f16e93526b47c4edbea603b84432131976cb6335ce60a0ce6c
|
|
| MD5 |
f71a71ed7b155261a8cb202647f04ae5
|
|
| BLAKE2b-256 |
ab077df5589b0402532c7ea08bd83bc178ef919f9ce4cdfb3708747bf358afb9
|
Provenance
The following attestation bundles were made for langchain_pop-0.1.2.tar.gz:
Publisher:
publish.yml on joy7758/langchain-pop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_pop-0.1.2.tar.gz -
Subject digest:
b0b843e4050398f16e93526b47c4edbea603b84432131976cb6335ce60a0ce6c - Sigstore transparency entry: 1059695193
- Sigstore integration time:
-
Permalink:
joy7758/langchain-pop@bb201b09e084b0de5fe0fffb673d8abaa06f9621 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/joy7758
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bb201b09e084b0de5fe0fffb673d8abaa06f9621 -
Trigger Event:
push
-
Statement type:
File details
Details for the file langchain_pop-0.1.2-py3-none-any.whl.
File metadata
- Download URL: langchain_pop-0.1.2-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a52646798016e9de84d5718548d32765627de36e2e517e77081fd45c7019d338
|
|
| MD5 |
be6e8bea9e2e442049b594ff2716a20a
|
|
| BLAKE2b-256 |
989d01f371525ddf4c793615f9da2cfed8bf5525672959a3a92afd575dcb0b2a
|
Provenance
The following attestation bundles were made for langchain_pop-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on joy7758/langchain-pop
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_pop-0.1.2-py3-none-any.whl -
Subject digest:
a52646798016e9de84d5718548d32765627de36e2e517e77081fd45c7019d338 - Sigstore transparency entry: 1059695197
- Sigstore integration time:
-
Permalink:
joy7758/langchain-pop@bb201b09e084b0de5fe0fffb673d8abaa06f9621 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/joy7758
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bb201b09e084b0de5fe0fffb673d8abaa06f9621 -
Trigger Event:
push
-
Statement type: