Parlant Adapter
Build controlled, guideline-driven agents with the official Parlant SDK
This tutorial shows you how to create an agent using the ParlantAdapter. This adapter integrates the official Parlant SDK with the Band platform, enabling guideline-based agent behavior for consistent, predictable responses.
Prerequisites
Before starting, make sure you’ve completed the Setup tutorial:
- SDK installed with Parlant support
- Agent created on the platform
.envandagent_config.yamlconfigured- Verified your setup works
Install the Parlant extra:
Why Parlant?
Parlant is designed for building agents with controlled, consistent behavior:
- Behavioral Guidelines: Define condition/action rules that are actually enforced by the Parlant SDK
- Predictable Behavior: Guidelines are reliably followed, not just “suggested” like system prompts
- Built-in Guardrails: Guidelines are processed through Parlant’s engine as structured rules, not just prompt text
- Session Management: Proper conversation context through the SDK
- Customer-Facing Use Cases: Designed for deployments where response consistency matters
Architecture
The adapter owns the Parlant server. It reserves two free ports, boots p.Server in-process when the Band agent starts, creates the Parlant agent, applies the guidelines you declared, and tears the whole thing down when the agent stops:
You can still bring your own running server, see Bring Your Own Server.
Create Your Agent
Create a file called agent.py:
name and description default to the Band agent’s own name and description, so both are optional. nlp_service defaults to Parlant’s own default; pass p.NLPServices.openai to be explicit about which provider key the server needs.
Run the Agent
Start your agent:
The Parlant server runs in-process, and it is chatty. It prints a version banner, its home directory, and its own structured INFO lines to stderr, independently of configure_logging. The first run is also slow: every guideline you declared is indexed through the NLP service while the agent starts, so expect a long quiet pause after the banner. Nothing is wrong. You are done when you see:
Importing parlant.sdk also creates a parlant-data/ directory in the working directory, and logs the absolute path it picked. It holds parlant.log, cache_embeddings.json (an embedding cache that grows as you iterate on guidelines), and JSON stores for the agents and guidelines you create. It is local runtime state, not source, so add it to .gitignore:
Set PARLANT_HOME to put it somewhere else.
p.Server() binds two local TCP listeners inside your process, a tool service and the Parlant API, and its defaults are the fixed ports 8818 and 8800. A taken port is silent: Parlant exits with code 3 after its four startup lines and never names the conflict. The adapter avoids that entirely by reserving a free pair before booting the server, so two Band agents run side by side on one host with no configuration. Override them through server_options if you need fixed numbers:
Test Your Agent
Add Agent to a Chat Room
Go to Band and either create a new chat room or open an existing one. Add your agent as a participant, under the Remote section.
How It Works
When your agent runs:
- Server boot -
on_startedreserves a free port pair, constructsp.Serverwith yournlp_serviceandserver_options, and enters it. - Agent creation - The adapter creates the Parlant agent from
nameanddescription, unless you suppliedparlant_agent=. - Tools and guidelines - Band’s platform tools are built as Parlant tool entries, then every guideline declared with
add_guidelineis created on the live agent with those tools attached. - Configure hook - Your
configure=callback runs, if you passed one, with the live(server, parlant_agent). - Serving - The server finishes its setup phase and starts serving. The Band SDK connects to the platform over WebSocket.
- Message processing - Each mention becomes a Parlant customer message on that room’s session, routed through Parlant’s guideline-matching engine.
- Tool execution - Parlant tools wrapping Band tools execute in your process, resolved against the calling room.
- Shutdown - Stopping the Band agent releases the sessions and tears the server down. A server you supplied yourself is left running.
All of steps 1 to 4 happen inside Parlant’s configuration phase, which is why guidelines have to be declared before agent.run(). Calling add_guideline after startup raises RuntimeError; use configure= or adapter.parlant_agent.create_guideline() for a running agent.
The adapter attaches Band’s platform tools to your guidelines automatically:
All 12 are built, but the five contact tools are dropped unless you pass capabilities={Capability.CONTACTS}. adapter.tools returns the resolved list once the agent has started. To build the same list yourself, for a guideline you register through configure=, call create_parlant_tools(adapter.features) from band.integrations.parlant.tools. There are no memory tools on this surface, see Features.
Behavioral Guidelines
The key feature of Parlant is its guideline system. Guidelines are condition/action pairs that actually enforce behavior rather than suggesting it. Declare them on the adapter with add_guideline, which mirrors parlant.sdk.Agent.create_guideline and forwards any extra keyword arguments to it:
add_guideline is synchronous, because nothing is sent to Parlant until the server boots. Every declared guideline gets the platform tools; pass tools= explicitly, including tools=[], to override that for one guideline.
Configuration Options
Every ParlantAdapter parameter, with its real default:
Every parameter is keyword-only. Four combinations raise ValueError at construction:
parlant_agentwithoutserver, since the agent has to live on a server the adapter can reachnlp_serviceorserver_optionstogether withserver, since both only configure the adapter-owned serversystem_promptorcustom_sectiontogether withparlant_agent, since both shape a description the adapter would otherwise writeresponse_timeoutorresponse_pollat or below zero
A cold start, Parlant server warmup plus the first guideline-matching round trips, can run long, so response_timeout defaults to five minutes. response_poll only controls how often that wait wakes up; the turn returns as soon as the response arrives.
Features
ParlantAdapter declares no supported event kinds, so it never narrates into the room timeline itself and takes no emit argument. Passing one raises BandConfigError. Anything the agent reports comes from a guideline calling band_send_event.
It does support capabilities. Capability.CONTACTS is what adds the five band_*_contact* tools to the set attached to your guidelines:
Capability.MEMORY is accepted, but the Parlant tool surface has no memory tools, so it changes nothing about what the agent can call. The tool filters include_tools, exclude_tools, and include_categories are accepted too, and are likewise ignored here: CONTACTS is the only feature that changes the Parlant tool list. Use tools= on a guideline to control tools per guideline.
Bring Your Own Server
Pass server= when something else in your process already runs Parlant, or when you need the server outside the Band agent’s lifetime. A server you supply is borrowed: the adapter configures the agent on it but never tears it down. Pass parlant_agent= as well to bridge an agent you created yourself, in which case system_prompt and custom_section are rejected, because that agent’s description is yours to write.
Note the fixed ports: a server you construct yourself gets Parlant’s 8818 and 8800 defaults unless you pass your own, so two agents on one host collide. The adapter-owned path reserves free ports for you.
For anything the declarative surface does not cover, journeys, guideline dependencies, canned responses, use configure= instead of taking over the server. It runs at startup with the live objects, still inside Parlant’s configuration phase:
Customer Support Agent Example
Here’s a realistic example of a customer support agent with comprehensive guidelines:
Passing tools=[] on a guideline that never calls a tool keeps Parlant from putting 12 tool schemas in front of the model for a purely conversational rule.
Multi-Agent Collaboration Example
Guidelines work well for agents that coordinate with other agents on the platform:
Debug Mode
If your agent isn’t responding as expected, replace the configure_logging call in agent.py with:
root_level="INFO" keeps your own logger.info lines visible; without it every non-Band logger drops back to WARNING.
With debug logging enabled, you’ll see detailed output including:
- WebSocket connection events
- Room subscriptions
- Session creation for each room
- Message processing lifecycle
- Tool calls (
band_send_message,band_send_event, etc.) - Parlant guideline matching
- Errors and exceptions
Look for [Parlant Tool] log entries to see tool execution details.
Best Practices
Write Clear Conditions
Conditions should be specific and unambiguous:
Write Actionable Actions
Actions should describe specific behaviors:
Drop Tools From Guidelines That Do Not Need Them
Every declared guideline gets Band’s platform tools by default. A purely conversational rule does not need them, and 12 unused tool schemas is a real cost per guideline match:
Keep Guidelines Focused
Each guideline should address one scenario:
Troubleshooting
Import Errors
Install the Parlant extra:
“OPENAI_API_KEY not set” Error
Parlant checks the API key during module import. Load your .env before importing parlant.sdk:
Guidelines Not Being Followed
- Check the Parlant logs for guideline registration
- Verify the condition matches your test messages
- Check you did not pass
tools=[]on a guideline whose action calls a platform tool - Try more specific conditions
RuntimeError: add_guideline must be called before the agent starts
add_guideline only queues a declaration; the guidelines are created during the server’s configuration phase at startup. Move the call above Agent.create(), or use configure= for a guideline that has to be added to a running agent.
Agent Not Responding
- Check that the agent is connected (look for WebSocket logs)
- Verify the agent is a participant in the chat room
- Make sure you’re @mentioning the agent
- Check for errors in the logs