Skip to main content

CI PyPI version Python versions License

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.1 migration
  • 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:

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-protocol defines the protocol semantics, schema, examples, and reference tooling.
  • langchain-pop demonstrates 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.

Metadata

Release files for langchain-pop 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-pop 0.1.2
File Size Uploaded Provenance Actions
langchain_pop-0.1.2.tar.gz 13.0 kB With provenance Details for langchain_pop-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-pop 0.1.2
File Interpreter ABI Platform Actions
langchain_pop-0.1.2-py3-none-any.whl Python 3 none any Details for langchain_pop-0.1.2-py3-none-any.whl

Total release size: 21.1 kB

Release files / langchain_pop-0.1.2.tar.gz

Download URL langchain_pop-0.1.2.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b0b843e4050398f16e93526b47c4edbea603b84432131976cb6335ce60a0ce6c
BLAKE2b-256 checksum
How to use checksums
ab077df5589b0402532c7ea08bd83bc178ef919f9ce4cdfb3708747bf358afb9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 8, 2026.

Transparency log

Release files / langchain_pop-0.1.2-py3-none-any.whl

Download URL langchain_pop-0.1.2-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a52646798016e9de84d5718548d32765627de36e2e517e77081fd45c7019d338
BLAKE2b-256 checksum
How to use checksums
989d01f371525ddf4c793615f9da2cfed8bf5525672959a3a92afd575dcb0b2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 8, 2026.

Transparency log

Security for langchain-pop 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_pop-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 8, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page