Skip to main content

Expose LangChain and LangGraph agents through ACP Kit.

Project description

langchain-acp

langchain-acp exposes LangChain, LangGraph, and DeepAgents graphs through ACP Kit.

It keeps ACP Kit's adapter architecture intact while staying graph-centric on the LangChain side:

  • graph=...
  • graph_factory=...
  • graph_source=...

Install

uv add langchain-acp
pip install langchain-acp

With optional DeepAgents compatibility:

uv add "langchain-acp[deepagents]"
pip install "langchain-acp[deepagents]"

Contributor setup from the monorepo root:

uv sync --extra dev --extra langchain

Quickstart

from langchain.agents import create_agent
from langchain_acp import run_acp

graph = create_agent(model="openai:gpt-5", tools=[])

run_acp(graph=graph)

If you are using Codex-backed LangChain models through codex-auth-helper, you must pass the LangChain system behavior through the helper's instructions= argument. The same repo policy now applies on the Pydantic path too: Codex-backed model factories take explicit instructions instead of inventing an implicit default.

from codex_auth_helper import create_codex_chat_openai
from langchain.agents import create_agent

model = create_codex_chat_openai(
    "gpt-5.4",
    instructions="You are a careful assistant that explains concrete workspace observations.",
)
graph = create_agent(model=model, tools=[], name="codex-graph")

That instructions string is required and is forwarded to the OpenAI Responses request behind ChatOpenAI. See the maintained example at https://github.com/vcoderun/acpkit/blob/main/examples/langchain/codex_graph.py.

Use the same pattern inside graph_factory= paths too. If the graph is rebuilt per session, keep the Codex system behavior explicit in the factory instead of relying on an implicit default:

from codex_auth_helper import create_codex_chat_openai
from langchain.agents import create_agent
from langchain_acp import AcpSessionContext


def graph_from_session(session: AcpSessionContext):
    mode_name = session.session_mode_id or "ask"
    model_name = session.session_model_id or "gpt-5.4-mini"
    model = create_codex_chat_openai(
        model_name,
        instructions=f"Operate in {mode_name} mode and explain concrete workspace observations.",
    )
    return create_agent(model=model, tools=[], name=f"codex-{mode_name}")

If ACP session state should affect graph construction, use graph_factory=:

from langchain.agents import create_agent
from langchain_acp import AcpSessionContext, create_acp_agent


def graph_from_session(session: AcpSessionContext):
    mode_name = session.session_mode_id or "default"
    return create_agent(model="openai:gpt-5", tools=[], name=f"graph-{mode_name}")


acp_agent = create_acp_agent(graph_factory=graph_from_session)

What The Adapter Covers

langchain-acp carries the same ACP Kit seams that matter elsewhere in the repo, but mapped onto graph ownership instead of agent ownership:

  • session stores and transcript replay
  • model, mode, and config-option providers
  • prompt capability advertisement through prompt_capabilities
  • native plan state through TaskPlan
  • approval bridging from HumanInTheLoopMiddleware
  • remembered approval policies and permission card rendering on NativeApprovalBridge
  • capability bridges and graph-build contributions
  • built-in and host-defined slash commands
  • tool projection maps and event projection maps
  • external hook/event projection through ExternalHookEventBridge
  • graph, graph_factory, and graph_source
  • DeepAgents compatibility helpers where they add truthful ACP behavior

That means the adapter can expose:

  • plain LangChain create_agent(...) graphs
  • compiled LangGraph graphs
  • DeepAgents graphs

without collapsing everything into a bespoke ACP runtime.

Runtime Controls

The adapter now owns a small ACP-native slash-command layer instead of leaving that surface entirely to the graph:

  • mode commands such as /ask or /review when the session publishes modes
  • /model for ACP-owned model selection
  • /tools for the active graph tool node
  • /mcp-servers for attached session MCP servers
  • custom host commands through slash_command_provider

Example:

from acp.schema import AvailableCommand
from langchain_acp import (
    AdapterConfig,
    SlashCommandResult,
    StaticSlashCommand,
    StaticSlashCommandProvider,
)

config = AdapterConfig(
    slash_command_provider=StaticSlashCommandProvider(
        commands=[
            StaticSlashCommand(
                command=AvailableCommand(name="ping", description="Return pong."),
                handler=lambda _request: SlashCommandResult(text="pong"),
            )
        ]
    )
)

Prompt capability advertisement is also explicit now:

from langchain_acp import AdapterConfig, AdapterPromptCapabilities

config = AdapterConfig(
    prompt_capabilities=AdapterPromptCapabilities(
        audio=False,
        image=False,
        embedded_context=True,
    )
)

If the graph uses approval middleware, remembered choices and ACP permission presentation stay on NativeApprovalBridge, not on AdapterConfig:

from langchain_acp import NativeApprovalBridge

config = AdapterConfig(
    approval_bridge=NativeApprovalBridge(enable_persistent_choices=True),
)

Session-owned Graph Rebuilds

If ACP session state should decide which graph gets built, graph_factory= is the intended seam:

from langchain.agents import create_agent
from langchain_acp import AcpSessionContext, AdapterConfig, MemorySessionStore, run_acp


def graph_from_session(session: AcpSessionContext):
    mode_name = session.session_mode_id or "default"
    model_name = session.session_model_id or "openai:gpt-5-mini"
    return create_agent(
        model=model_name,
        tools=[],
        name=f"graph-{mode_name}",
        system_prompt=f"Operate in {mode_name} mode.",
    )


run_acp(
    graph_factory=graph_from_session,
    config=AdapterConfig(session_store=MemorySessionStore()),
)

Use this when workspace path, mode, model, or session metadata should rebuild the graph dynamically.

The maintained examples under examples/langchain/ also expose ACP-visible model and mode choices through available_models, available_modes, default_model_id, and default_mode_id, then consume session.session_model_id and session.session_mode_id inside graph_factory=....

DeepAgents Compatibility

DeepAgents graphs are supported as compiled LangGraph targets.

Use the compatibility helpers only when they add real value:

  • DeepAgentsCompatibilityBridge
  • DeepAgentsProjectionMap

Maintained examples:

Docs:

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_acp-0.9.3.tar.gz (39.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_acp-0.9.3-py3-none-any.whl (53.7 kB view details)

Uploaded Python 3

File details

Details for the file langchain_acp-0.9.3.tar.gz.

File metadata

  • Download URL: langchain_acp-0.9.3.tar.gz
  • Upload date:
  • Size: 39.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for langchain_acp-0.9.3.tar.gz
Algorithm Hash digest
SHA256 255dc95052130fa92c6abadae895ca46efa34a4723b4e07441bd9b566e2c947b
MD5 9543ca550071bc3d405352babc0b0062
BLAKE2b-256 f7aa7bd3445b3d9d95b6c22b77be19de4fd96072da6eb01322cde02a905e7c3b

See more details on using hashes here.

File details

Details for the file langchain_acp-0.9.3-py3-none-any.whl.

File metadata

  • Download URL: langchain_acp-0.9.3-py3-none-any.whl
  • Upload date:
  • Size: 53.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for langchain_acp-0.9.3-py3-none-any.whl
Algorithm Hash digest
SHA256 dd4df5a8984bc623238010f2dfef580947eaaf0341ec89a158f0951d7c05fb78
MD5 07ecf0680e3d5576811fa965101662f5
BLAKE2b-256 3544a59f6c44248da1f5adce33a29ac6a08bd10b6b3e368a7216bb8dcdd7becf

See more details on using hashes here.

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