A Python-based implementation of the Open Floor Protocol 1.1 specification for multi-agent conversation management and floor control.
This project implements the Floor Manager per Open Floor Protocol (OFP) 1.1 specification, providing:
- Floor Manager: Core OFP component managing floor control and envelope routing
- Floor Control Logic: Minimal floor management behaviors (requestFloor β grantFloor, yieldFloor, etc.)
- Envelope Processing: OFP 1.1 compliant JSON envelope handling
- Agent Support: Base classes and example agents for testing
Per OFP 1.1: No central agent registry (agents identified only by speakerUri). Dynamic discovery via getManifests/publishManifests events.
src/
βββ floor_manager/ # Floor Manager (core OFP component)
β βββ manager.py # Main Floor Manager (includes envelope routing)
β βββ floor_control.py # Floor control logic (minimal behaviors)
β βββ envelope.py # OFP 1.1 envelope models
βββ agents/ # Agent implementations (BaseAgent, ExampleAgent, LLMAgent)
βββ orchestration/ # Optional orchestration patterns (Convener Agent, etc.)
βββ api/ # FastAPI REST endpoints
β βββ floor.py # Floor control API
β βββ envelope.py # Envelope processing API
βββ main.py # FastAPI application entry point
The Floor Manager is the central component per OFP Specification Section 0.4.3:
βββββββββββββββββββββββββββββββββββββββββββββββ
β FLOOR MANAGER β
β (Implements OFP 1.1 Spec Section 2.2) β
β β
β β’ Envelope Processing & Routing (built-in) β
β β’ Floor Control Logic (minimal behaviors) β
β β’ Priority Queue Management β
β β’ Conversation State Management β
βββββββββββββββββββββββββββββββββββββββββββββββ
β
OFP 1.1 Envelopes
β
ββββββββββββ ββββββββββββ ββββββββββββ
β Agent A β β Agent B β β Agent C β
ββββββββββββ ββββββββββββ ββββββββββββ
Key Features:
- Envelope Routing (built-in): Routes OFP envelopes between agents (no separate router component)
- Floor Control: Implements minimal floor management behaviors (Spec Section 2.2)
- Priority Queue: Manages floor requests by priority
- State Machine: Floor as autonomous state machine
Important Terminology (per OFP 1.1 Spec):
- Floor Manager = Our system component (what this project implements)
- Convener Agent = Optional AGENT that mediates conversations (like a meeting chair)
- The Floor Manager can work standalone OR delegate to a Convener Agent if present
π Visual Architecture Diagrams: See OFP 1.1 Spec Analysis for detailed architecture based on official specification.
- Convener Agent Pattern: Optional agent that mediates conversations (per OFP Spec Section 0.4.3)
- Collaborative: Autonomous floor negotiation with minimal arbitration
- Hybrid Delegation: Master agent delegates to specialists while maintaining control
Note: These are optional patterns. The Floor Manager works without them.
- Python: 3.11+
- Web Framework: FastAPI
- Database: PostgreSQL 15
- Cache/Queue: Redis 7
- Testing: pytest, pytest-asyncio
- Python 3.11 or higher
- Docker and Docker Compose
- PostgreSQL 15 (or use Docker)
- Redis 7 (or use Docker)
# Clone the repository (if not already cloned)
git clone https://github.com/diegogosmar/floor.git
cd floor
# Start services (PostgreSQL, Redis, API)
docker-compose up -d
# Wait a few seconds
sleep 5# Health check
curl http://localhost:8000/health
# Response: {"status":"healthy"}Option A: Complete OFP Flow Demo β RECOMMENDED
# Demonstrates COMPLETE Open Floor Protocol 1.0.1 flow:
# β’ Agent registration with manifests
# β’ getManifests (capability discovery)
# β’ requestFloor with priority queue
# β’ grantFloor by autonomous Convener
# β’ Floor yield and handoff between agents
python examples/agents/complete_ofp_demo.pyThis shows the real OFP protocol in action with the Floor Manager API. See Complete OFP Demo Guide for details.
Option B: Interactive GUI Demo π¨ NEW!
# Install Streamlit (if not already installed)
pip install streamlit
# Launch interactive web GUI
streamlit run streamlit_app.pyOpens in browser at http://localhost:8501. Features:
- π¬ Real-time chat with AI agents
- π€ Visual floor status display
- π₯ Multiple agents (Budget Analyst, Travel Agent, Coordinator)
- π€ AI-powered responses (GPT-4o-mini)
- π― Priority queue visualization
π See: GUI Demo Guide for detailed instructions.
Option C: Basic Floor Control Demo
# Install dependency if needed
pip install httpx
# Test basic multi-agent conversation
python examples/agents/demo_agents.py
# Test floor control priority
python examples/agents/demo_agents.py priorityOption C: Bash Script
# Complete workflow test
./examples/test_workflow.shOption D: Swagger UI (Interactive)
# Open in browser
open http://localhost:8000/docs
# Or visit: http://localhost:8000/docsNote: Demo agents use hardcoded responses. For real AI-powered agents, use LLM agents:
# First, install project dependencies (required)
pip install -r requirements.txt
# Then install LLM provider libraries
pip install openai # For OpenAI
# pip install anthropic # For Anthropic
# pip install ollama # For local LLM (optional)
# Set API key (if using OpenAI)
export OPENAI_API_KEY="sk-..."
# Quick test to verify API key works
python examples/agents/quick_llm_test.py
# Full LLM agent examples (OpenAI, Anthropic, Ollama)
python examples/agents/llm_agent_example.pySupported Providers:
- OpenAI: GPT-4, GPT-4o, GPT-4o-mini, GPT-3.5-turbo
- Anthropic: Claude 3 (Haiku, Sonnet, Opus)
- Ollama: Local LLM models (requires
ollama serve)
π See: LLM Integration Guide for detailed instructions.
# 1. Register an agent
curl -X POST http://localhost:8000/api/v1/agents/register \
-H "Content-Type: application/json" \
-d '{
"speakerUri": "tag:test.com,2025:agent_1",
"agent_name": "Test Agent",
"capabilities": ["text_generation"]
}'
# 2. Request floor
curl -X POST http://localhost:8000/api/v1/floor/request \
-H "Content-Type: application/json" \
-d '{
"conversation_id": "conv_test",
"speakerUri": "tag:test.com,2025:agent_1",
"priority": 5
}'
# 3. Check floor holder
curl http://localhost:8000/api/v1/floor/holder/conv_test- π How to Launch and Test: docs/GETTING_STARTED.md β START HERE
- π OFP 1.1 Spec Analysis: docs/OFP_1.0.1_OFFICIAL_SPEC_ANALYSIS.md - Official specification analysis and compliance
- π Refactoring Status: REFACTORING_STATUS.md - Current refactoring progress per OFP 1.1
- π Simple OFP Demo: examples/agents/complete_ofp_demo_simple.py - Floor control without agent registration
- βοΈ Detailed Setup: docs/SETUP.md
- ποΈ Architecture: docs/ARCHITECTURE_DETAILED.md
- π§ LLM Integration: docs/LLM_INTEGRATION.md - How to use real LLM providers (OpenAI, Anthropic, Ollama)
- π§ͺ Testing: docs/TESTING.md - How to run tests
- π Quick Reference: docs/QUICKSTART.md
Important: Make sure pytest-asyncio is installed in your virtual environment:
# Install test dependencies (if not already installed)
pip install -r requirements.txt
# Verify pytest-asyncio is installed
pip list | grep pytest-asyncio
# If missing, install it explicitly
pip install pytest-asyncio>=0.23.0Then run tests:
# Run all tests
pytest
# Run with coverage
pytest --cov=src --cov-report=html
# Run specific test file
pytest tests/test_floor_manager.pyTroubleshooting: If you see "async def functions are not natively supported", see Testing Guide for detailed troubleshooting steps.
# Format code
black src tests
# Sort imports
isort src tests
# Lint
flake8 src tests
# Type checking
mypy srcFLOOR/
βββ src/
β βββ floor_manager/ # Floor control primitives
β β βββ __init__.py
β β βββ floor_control.py
β β βββ floor_queue.py
β βββ envelope_router/ # Envelope routing
β β βββ __init__.py
β β βββ router.py
β β βββ envelope.py
β βββ agent_registry/ # Agent registry
β β βββ __init__.py
β β βββ registry.py
β β βββ capabilities.py
β βββ agents/ # Agent implementations
β β βββ __init__.py
β β βββ base_agent.py
β β βββ example_agent.py
β βββ models/ # Data models
β β βββ __init__.py
β β βββ schemas.py
β βββ database/ # Database configuration
β β βββ __init__.py
β β βββ connection.py
β βββ main.py # FastAPI app
βββ tests/ # Test suite
β βββ __init__.py
β βββ test_floor_manager.py
β βββ test_envelope_router.py
β βββ test_agent_registry.py
β βββ test_agents.py
βββ docker/ # Docker files
β βββ Dockerfile
β βββ docker-compose.yml
βββ docs/ # Documentation
β βββ architecture.md
β βββ api.md
βββ requirements.txt # Python dependencies
βββ .env.example # Environment template
βββ docker-compose.yml # Docker Compose config
βββ README.md # This file
Once the server is running, access the interactive API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
This implementation follows the Open Floor Protocol 1.1 specification for:
- Floor control primitives (autonomous state machine with convener)
- Conversation envelope format (with assignedFloorRoles and floorGranted)
- Agent capability discovery
- Message routing and delivery
- Privacy flag handling (only for utterance events)
Key OFP 1.1 Features:
- Floor Manager acts as autonomous Convener
assignedFloorRolesandfloorGrantedin conversation objectacceptInviteevent support- Privacy flag only respected for utterance events
We welcome contributions! Here's how to get started:
- Fork the repository on GitHub
- Clone your fork and create a feature branch
- Make your changes following our coding standards
- Add tests for new functionality
- Ensure all tests pass:
pytest - Update documentation if needed
- Submit a Pull Request - We'll review and merge it!
π For detailed guidelines, see CONTRIBUTING.md - It includes:
- Complete development setup instructions
- Pull Request process and best practices
- Coding standards and style guide
- Testing requirements
- Commit message conventions
- OFP 1.1 compliance guidelines
Quick PR Process:
- Fork β Branch β Code β Test β PR β Review β Merge β
This implementation is part of the Open Floor Protocol implementations collection:
- floor-implementations: https://github.com/open-voice-interoperability/floor-implementations
- Collection of different Floor Manager implementations
- This Python implementation is included in the collection
- See docs/ADD_TO_FLOOR_IMPLEMENTATIONS.md for details
For issues and questions, please open an issue in the repository.