In the evolving realm of open‑source AI frameworks, the ideal platform blends modularity, transparency, and developer‑centric design—empowering creators to shape intelligent agents that are both expressive and dependable. Imagine a framework that not only supports flexible integration of external tools and structured workflows, but also subtly embeds mechanisms for behavioral self‑validation, contextual consistency checks, and guided reasoning paths. Such a design fosters agents that feel both polished and predictable—not through rigid prompt engineering, but via an architecture that prioritizes explainability and fine‑grained control. This vision ensures that as applications scale and evolve, the logic behind their outputs remains clear, adaptable, and firmly aligned with stakeholders’ expectations—ultimately defining what responsible and maintainable AI should aspire to be.
Parlant is the open-source framework that makes AI agents smarter, safer, and easier to control. With its unique Agentic Behavior Modeling, you can teach your agent principles—not fragile prompts—so it adapts to real conversations while staying consistent and trustworthy. Build, refine, and scale agents with confidence—from prototype to production.
1. Agentic Behavior Modeling (ABM)
Parlant introduces Agentic Behavior Modeling, a robust paradigm that lets you define an AI agent’s behavior through structured principles rather than rigid flows or brittle prompt engineering. You create granular guidelines—each with a condition and an action—so the agent adapts dynamically to user context while still conforming to business rules. Parlant intelligently selects and enforces relevant guidelines per turn to ensure reliable, consistent behavior.
2. Adaptive, Iterative, Explainable Development
- Adaptive: No need for flowcharts—teach your agent principles, not paths.
- Iterative: You can continuously refine your agent by incrementally adding or modifying guidelines based on real conversational feedback.
- Explainable: Parlant provides clear feedback on which guidelines were activated and how decisions were made—making it easy to debug and trust agent behavior.
3. Production-Ready Capabilities & Compliance Focus
Parlant includes a comprehensive set of enterprise-grade features suited for real-world deployment:
- Journeys: Manage multi-step conversational paths (e.g., onboarding workflows or customer support flows).
- Canned Responses: Use templated replies to minimize hallucinations and maintain style consistency.
- Tool Integration: Seamlessly attach external tools or APIs—like weather fetchers, order systems, etc.—and ensure they execute under guideline control.
- Glossary & Retrievers: Define domain-specific terminology and build semantic retrieval systems for consistent responses.
- API Hardening: Support for fine-grained authorization and rate limiting ensures secure, production-grade access management.
- Moderation & Guardrails: Integrates content filtering and intelligent handovers to human agents when needed—crucial for sensitive domains such as healthcare or legal.
- Open Source with Reasoned Licensing: Fully Apache-2.0 licensed—no hidden open-core traps. Parlant is backed by a team of researchers and engineers from renowned institutions and companies, and the community is encouraged to grow together.
4. Explainability & Coherence Assurance
Parlant doesn’t just apply guidelines—it verifies that the agent’s output actually respects them. Through mechanisms like coherence checks and self-critique processes, it ensures that responses don’t violate rules and remain consistent. This level of internal validation is rare and marks a high reliability standard in LLM agent frameworks.
5. Developer-Friendly & Version-Controlled
Everything in Parlant—including guidelines, glossaries, journeys, templates, and integrations—is code-native. Changes are version-controllable via Git, making collaboration, auditing, rollbacks, and deployments straightforward.
6. Refreshing Alternative to Traditional Approaches
Parlant occupies a sweet spot between two failing extremes:
- Too rigid: Traditional flow-based or intent models are inflexible and hard to maintain.
- Too loose: Pure prompt engineering yields unpredictable, often inconsistent agent behavior.
Instead, Parlant offers a hybrid: natural language–driven behavior modeling with the reliability of rule-based systems.
Summary of Strengths
Strength | Description |
---|---|
Granular Behavior Modeling | Define “when X, then Y” guidelines for precise, adaptive responses. |
Adaptive & Iterative | Update behavior on the fly based on feedback; no costly retraining. |
Explainability | Visibility into decisions and why a guideline triggered. |
Production-Ready | Includes journeys, canned replies, tool integrations, security, moderation. |
Developer Workflow | Everything is codified and version-controlled via Git. |
Compliance Focused | Ideal for regulated industries like finance, healthcare, legal, and government. |
Secure & Scalable | Authorization policies, rate limits, and handoff controls ensure safety. |
Diving into Code: Building a Travel Concierge Agent with Parlant
A self-contained demo that:
- Spins up a Parlant server backed by either Anthropic or OpenAI.
- Registers one agent, “Danh Hoàng Hiếu Nghị”, whose behavior is defined by a set of guidelines (natural-language rules).
- Prints a local URL so you can open the Parlant UI and start a session with the agent.
Imports & setup (top of file)
import asyncio, os
from typing import Optional
try:
from dotenv import load_dotenv
except ImportError:
load_dotenv = None # optional
import parlant.sdk as p
- Uses
asyncio
because the Parlant SDK is async. -
dotenv
is optional: if installed, it loads API keys from a.env
file; if not, the code still runs (you can use real environment variables). -
parlant.sdk as p
is the main SDK entrypoint (Server, Agent, services, etc.).
The agent factory: create_travel_concierge_agent(server)
agent = await server.create_agent(
name="Danh Hoàng Hiếu Nghị",
description=( "...Travel Agent..." ),
)
- Creates one Agent on the provided Server.
-
description
acts like a high-level system prompt: tone, scope, and general behavior (“friendly, detail-oriented”, “ask targeted follow-ups”, etc.).
Guidelines (behavior rules)
Each call to agent.create_guideline(...)
adds a condition → action rule. Think of it as:
When the conversation meets this natural-language condition, then apply this action instruction.
Parlant will pick relevant guidelines at each turn to keep responses consistent and explainable.
Greeting / rapport
- Condition: customer greets you
- Action: warm greeting; say you can handle end-to-end planning; ask for destination, dates, budget, preferences.
Destination collection
- Condition: user mentions a destination or asks for ideas
- Action: confirm destination or propose 2–3 curated options with pros/cons; ask for dates, trip length, budget.
Dates clarification
- Condition: user provides dates or asks best time to travel
- Action: acknowledge; if flexible, suggest 1–2 alternative windows with trade-offs (price, weather, crowds).
Budget handling
- Condition: budget is provided
- Action: confirm range/currency; propose a budget split (flights/hotel/food & activities); ask preference for savings vs convenience.
Flight suggestions (no external calls in demo)
- Condition: asks for flight suggestions
- Action: list 2–3 options across price/convenience; explain rationale (layovers, departure windows); ask about airport flexibility and baggage.
Hotel suggestions
- Condition: asks for hotels
- Action: suggest 2–3 hotels in different neighborhoods with one-line vibe/access; ask priorities (walkability, quiet, amenities).
Weather check (no API call here)
- Condition: asks about weather
- Action: give seasonal expectations and packing tips; offer to adjust plans closer to departure.
Itinerary crafting
- Condition: asks for an itinerary
- Action: draft day-by-day with morning/afternoon/evening anchors, balanced pacing, nearby clusters, plus 1–2 backups.
Dietary & accessibility
- Condition: mentions dietary/accessibility needs
- Action: acknowledge and incorporate constraints; proactively suggest suitable restaurants/venues and booking notes.
Confirmation & next steps
* **Condition:** user ready to finalize
* **Action:** summarize choices (flights/hotel/itinerary), confirm details, outline **next steps** (tickets/reservations), and **ask approval** before bookings.
Gratitude / closing (canned style)
* **Condition:** user thanks you
* **Action:** brief, warm reply; offer **one concrete next step** or check for anything else.
Apology format (canned style)
* **Condition:** you need to apologize/correct
* **Action:** short pattern: **acknowledge → correct → propose next step** (avoid over-apologizing).
Glossary support
* **Condition:** asked to define a travel term
* **Action:** one-sentence plain definition + one example; offer to adapt plans based on that concept.
Fallback
* **Condition:** otherwise
* **Action:** ask a **brief, targeted clarifying question**; keep replies concise.
Why this matters: Instead of hard-coding rigid flows, you express behavior as human-readable rules. Parlant can explain which guidelines fired, making debugging and compliance easier.
The entrypoint: main()
if load_dotenv is not None:
load_dotenv()
- Loads
.env
ifpython-dotenv
is installed, so keys likeANTHROPIC_API_KEY
(and typically anOPENAI_API_KEY
if you rely on OpenAI) become available.
anthropic_key: Optional[str] = os.getenv("ANTHROPIC_API_KEY")
nlp_service = p.NLPServices.anthropic if anthropic_key else p.NLPServices.openai
-
Service selection: If
ANTHROPIC_API_KEY
exists, use Anthropic; otherwise default to OpenAI. - Make sure you have the relevant provider’s API key set in your environment.
async with p.Server(nlp_service=nlp_service) as server:
agent = await create_travel_concierge_agent(server)
- Starts the Parlant server using the chosen NLP provider.
- Registers the agent with all its guidelines.
print("Parlant Travel Concierge running at http://localhost:8800")
print(f"Agent: {agent.name} — id={agent.id}")
print("Open the URL above and start a new session with this agent.")
- Convenience prints for local dev: open the URL, create a session, and chat.
Finally:
if __name__ == "__main__":
asyncio.run(main())
- Standard async entrypoint.
What happens at runtime (turn-by-turn)
- You open the printed URL and start a session with Danh Hoàng Hiếu Nghị.
- For each user message, Parlant:
- Evaluates the message + context.
- Determines which guideline conditions match.
- Synthesizes a response that follows the matching actions.
- Because multiple guidelines can be relevant, the response tends to feel adaptive while remaining consistent with your business rules (greetings → destination → dates → budget → flights/hotels → itinerary → finalize).
Example mini-flow:
- User: “Hi! I want to go to Tokyo this fall.” → Greeting + Destination guidelines (warm greet, confirm destination, ask dates/budget).
- User: “About 6 days, budget \$1,200.” → Dates + Budget guidelines (ack, propose date windows, budget split, savings vs convenience).
- User: “Show me flights.” → Flight guideline (2–3 options, rationale, ask baggage/airport flexibility).
- User: “Thanks!” → Gratitude guideline (brief, warm, offer next step).
How to run locally (quick checklist)
- Python version: Use a modern Python (e.g., 3.10+).
- Install deps:
pip install parlant python-dotenv
(If you don’t want .env
, skip python-dotenv
.)
- Set keys:
- For Anthropic: set
ANTHROPIC_API_KEY=...
- For OpenAI: ensure your OpenAI key is available (commonly
OPENAI_API_KEY=...
)- Save the script and run:
python your_script.py
- Open the printed http://localhost:8800 URL and start a session with Danh Hoàng Hiếu Nghị.
If you see auth errors, recheck your API keys and provider selection.
Extending this agent (quick ideas)
- Add tools/API calls: e.g., plug in a real weather API and create a tool-using guideline (“when user asks weather for X dates → call tool → summarize with packing tips”).
- Canned responses library: centralize reusable snippets for confirmations, disclaimers, or handoffs.
- Journeys: if you need multi-step flows (e.g., “quote → hold → book”), define a journey and attach guidelines per step.
- Policy/Compliance rules: add guardrail guidelines (e.g., refund policy wording, prohibited destinations, age restrictions).
Common pitfalls & tips
-
Missing keys: If
ANTHROPIC_API_KEY
is set but invalid, Anthropic calls will fail; if it’s absent and OpenAI is used, make sure your OpenAI key is configured. - Catch-all ordering: Keep an “otherwise” fallback, but ensure your specific guidelines are present so the agent doesn’t over-ask generic clarifiers.
- Overlong actions: Keep actions crisp. Short, specific instructions produce more consistent outputs.
_Full-source code here: Parlant Example
_
_References: _
Top comments (0)