Skip to main content

Parlant Integration

Deploy Parlant guideline-driven conversational agents with RunAgent

Prerequisites


Overview

Parlant is a framework for building guideline-driven conversational AI agents with structured behavior management. RunAgent makes it easy to deploy Parlant agents and access them from any programming language.

Installation & Setup

1. Install Parlant

2. Set Environment Variables

Parlant requires API keys for LLM providers:

3. Start Parlant Server

The Parlant server must be running before deploying RunAgent agents:
The server will start on http://localhost:8800. Keep this terminal window open. Note: If you need to use a different port:

4. Quick Start with RunAgent


Quick Start

1. Project Structure

After initialization:

2. Configuration

The generated runagent.config.json:

3. Create .env File


Basic Parlant Agent

Here’s a complete Parlant agent with tools and guidelines:

Advanced Patterns

1. Custom Guidelines System

2. Multi-Domain Agent

3. Contextual Conversation Agent


Testing Your Parlant Agent

Python Client

JavaScript Client

Rust Client


Best Practices

1. Guideline Design

  • Write clear, specific conditions
  • Define concrete actions for agents to take
  • Associate appropriate tools with guidelines
  • Test guidelines with various inputs

2. Tool Implementation

  • Keep tools focused and single-purpose
  • Handle errors gracefully within tool code
  • Use type-safe parameters
  • Provide clear descriptions for LLM understanding

3. Session Management

  • Create sessions per user for context
  • Clean up old sessions periodically
  • Handle session timeouts appropriately
  • Store session metadata when needed

4. Error Handling

  • Always wrap async operations in try-catch
  • Return structured error responses
  • Log errors for debugging
  • Provide helpful error messages to users

5. Performance

  • Reuse client connections
  • Cache agent IDs
  • Implement connection pooling for high traffic
  • Monitor API usage and latency

Common Patterns

Guideline-Driven Routing

Route user requests based on guidelines:

Tool Composition

Combine multiple tools for complex tasks:

Context Preservation

Maintain conversation history:

Escalation Pattern

Handle complex requests:

Troubleshooting

Common Issues

1. Server Connection Failed
  • Solution: Ensure Parlant server is running with parlant-server run
  • Check server URL (default: http://localhost:8800)
  • Verify no firewall blocking port 8800
2. Agent Not Found
  • Solution: Agent is created on first run
  • Check agent creation logs
  • Verify client connection is successful
3. Tool Execution Fails
  • Solution: Check tool implementation code
  • Verify parameter types match specification
  • Test tools independently before integration
4. Guidelines Not Triggering
  • Solution: Make conditions more specific
  • Test with various phrasings
  • Review guideline condition matching
5. Session Timeout
  • Solution: Increase wait_for_data timeout
  • Check server responsiveness
  • Monitor server logs for errors

Debug Tips

Enable debug logging:
Test Parlant server connection:

Performance Optimization

1. Client Reuse

Reuse client connections:

2. Agent Caching

Cache agent IDs:

3. Session Pooling

Manage session lifecycle:

Next Steps


Additional Resources


🎉 Great work! You’ve learned how to deploy Parlant guideline-driven agents with RunAgent. Parlant’s structured behavior system combined with RunAgent’s multi-language access creates powerful, controllable conversational AI systems!