Skip to main content

POPMiddleware for LangChain agents.

Project description

CI

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 -e .

With OpenAI provider support

pip install -e ".[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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_pop-0.1.0a0.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_pop-0.1.0a0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file langchain_pop-0.1.0a0.tar.gz.

File metadata

  • Download URL: langchain_pop-0.1.0a0.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langchain_pop-0.1.0a0.tar.gz
Algorithm Hash digest
SHA256 35a0a6762e9f588bed3db95f185cdd2893292159434b4e9836ac6c73c4592e9d
MD5 1e221df06cff8d358e77707862dd8c9e
BLAKE2b-256 3736c5556cebb39826ef477b8f346a523597ce188f25b3a704edc15f6195ece3

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_pop-0.1.0a0.tar.gz:

Publisher: publish.yml on joy7758/langchain-pop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_pop-0.1.0a0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_pop-0.1.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe3dd0f7ef3445528016e9e0e6a2dc5f45a42e02b2af20bdf211b4abaddefd82
MD5 b8a1b6ebf2fe15cabbba19c7b6746912
BLAKE2b-256 3a4df69fa4c650f8220d6a8b41b7082e75eae24454df58aae815118426e0bdeb

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_pop-0.1.0a0-py3-none-any.whl:

Publisher: publish.yml on joy7758/langchain-pop

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page