tools, the name agent loops use for them. This SDK integration is optional: agents created in Xpander Chat or through the API run on Claude Code, Codex or OpenCode by default.
The steps below run a native LangGraph ReAct loop whose skills, model and instructions come from the xpander agent definition.
What doesn’t come built in
Unlike the Agno path, LangChain doesn’t have a one-call shortcut for pulling everything in at once, so we grab the agent definition from xpander and pass the pieces intocreate_react_agent ourselves. It’s only a few extra lines, but a few capabilities aren’t auto-wired and you wire them in your graph:
Prerequisites
- Complete the Quickstart. You should already have the CLI installed,
xpander logincompleted, and a scaffolded agent project. - Python 3.12+ for local development.
- An LLM provider key in your shell that matches your LangChain provider package. For example:
OPENAI_API_KEYforlangchain-openai,ANTHROPIC_API_KEYforlangchain-anthropic.
1. Install
All packages below are required for the default OpenAI example.2. Set up scaffolding
xpander_config.json reference
xpander_config.json
3. Create task handler
The full pattern, wrapped in@on_task so xpander routes tasks to it:
xpander_handler.py
Agents(...).aget(agent_id=task.agent_id)returns a fully loaded agent object.xpander_agent.model_nameis used as the LLM model id in your LangChain client.xpander_agent.tools.functionsreturns one callable per skill, with apayloadschema signature and generated docstrings LangChain/LangGraph can use.xpander_agent.instructionscontainsgeneral,role, andgoalfields so you can build the system prompt format your graph expects.task.result = ...hands the output back to xpander for storage and UI/API visibility.
4. Edit the agent system prompt
agent_instructions.json contains the agent’s system prompt and maps directly to agent.instructions in code:
agent_instructions.json
xpander agent dev syncs it to the control plane.
5. Stream chunks from LangGraph (optional)
For streaming output, use an async generator handler that yieldsTaskUpdateEvent values:
xpander_handler.py (streaming variant)
POST /invoke as SSE output.
6. Filter skill outputs with schema enforcement (optional)
When a skill returns large payloads, open the skill in Xpander Chat and set a filter on its Output schema tab. Only the fields you keep reach your LangChain loop, which cuts token usage. The steps are on Output response filtering.7. Test local development
Run the handler with the dev server. Tasks created from any channel (REST, Slack, Xpander Chat) route to your laptop:--output_format and --output_schema are useful for testing structured output without changing the agent’s settings in the control plane.
Next steps
Pre-built skills
What goes into
agent.tools.functions, and how catalog skills authenticate.Custom skills
Wrap a private API as a skill with
@register_tool.Full LangChain example
A standalone runnable script you can copy.
SDK integrations overview
What is auto-wired vs. manual for each supported agent loop.

