Skip to content

Plural Agentic Backends

Teams already build agents with other frameworks: LangChain chains, LangChain AgentExecutors, LangGraph graphs, or plain Python. Plural backends let those agents run on AgentGr.id without being rewritten. The framework does the reasoning inside the task, and the platform provides everything around it:

The framework provides AgentGr.id provides
Prompting, chains, graphs, tool-calling loops Registration, deployment and scaling
Its own memory or state (optional) Admission, rate limits and guardrail policies
Delegation, P2P messaging and task exchanges
Live streaming of tokens and tool calls
Result routing, observability and evaluation

The adapters are in the agents_adapters package (libs/agents-adapters). Add it, and the framework packages your agent uses, to the agent image:

pip install ./libs/agents-adapters langchain-core langchain-openai

LangChain and LangGraph

agent_from_langchain(build) turns a function that builds any LangChain Runnable into an agent class. That includes LCEL chains (prompt | model | parser), AgentExecutor and compiled LangGraph graphs.

# agent.py
from core.main import main
from agents_adapters import agent_from_langchain


def build(subject, context):
    from langchain_core.prompts import ChatPromptTemplate
    from langchain_openai import ChatOpenAI

    prompt = ChatPromptTemplate.from_messages([
        ("system", subject.persona.default_system_message or "You are a helpful analyst."),
        ("human", "{question}"),
    ])
    return prompt | ChatOpenAI(model="gpt-4o-mini")


if __name__ == "__main__":
    main(agent_from_langchain(build, stream=True))

A task with job_data = {"question": "..."} is passed to the runnable. The result becomes job_output: a message becomes {"text": ..., "tool_calls": [...]}, a dict is used as it is, and anything else becomes {"text": str(result)}.

Option Default Description
input_key None Pass job_data[input_key] instead of the whole job_data. Tasks without that key are dropped in on_preprocess
output_key None Take this key from a dict result (e.g. "output" for AgentExecutor, "messages" for LangGraph)
stream False Run with runnable.stream(...) and forward tokens and tool calls to context.stream(task)
use_thread_id True Pass config={"configurable": {"thread_id": ...}}, using task_metadata.session_id or the task ID, so LangGraph checkpointers keep conversation state per session

build runs once per instance at start-up and receives the agent's specification (subject) and context. Use them to configure models from the specification, or to wrap platform capabilities as LangChain tools:

def build(subject, context):
    from langchain_core.tools import tool
    from langgraph.prebuilt import create_react_agent
    from langchain_openai import ChatOpenAI
    import uuid

    @tool
    def ask_legal_reviewer(clause: str) -> str:
        """Send a contract clause to the legal-reviewer agent and return its review."""
        return str(context.delegator.submit_and_wait(
            subject_id="legal-reviewer", session_id=str(uuid.uuid4()),
            task_id=str(uuid.uuid4()), task_data={"clause": clause}))

    return create_react_agent(ChatOpenAI(model="gpt-4o-mini"), tools=[ask_legal_reviewer])

main(agent_from_langchain(build, output_key="messages", stream=True))

To customise further, subclass LangChainAgent and override select_input(task), config_for(task) or invoke(inputs, task).


Any Other Framework

agent_from_callable(fn) wraps any function fn(inputs, task, context) -> result, so any framework that can be called from Python can run on the platform:

from core.main import main
from agents_adapters import agent_from_callable
from my_framework import build_crew          # any library

crew = build_crew()

def run(inputs, task, context):
    stream = context.stream(task)
    stream.progress(0, "crew started")
    result = crew.kickoff(inputs=inputs)
    stream.close()
    return {"report": str(result)}

main(agent_from_callable(run))

For a framework you use often, subclass FrameworkAgent. Build the framework object in setup() and call it in invoke(inputs, task). Errors raised by the framework are returned as AgentResult(is_error=True, error_data={"stage": "on_data", "framework": ..., "message": ...}), and job_output_trace_data.framework records which adapter produced the result.


Deploying

A framework agent is deployed like any other agent: build an image with the SDK core package, agents_adapters and the framework, then register and deploy it. Provider keys such as OPENAI_API_KEY go in runtime.resources.env or your cluster's secrets, as described in API Keys and Credentials.