A collaborative canvas interface where multiple AI agents can work together on drawing tasks, with layer-based collaboration and real-time communication.
- Python 3.11+
uvpackage manager- Ollama (for AI agents)
# Clone the repository
git clone <repository-url>
cd CompanionAgent
# Install dependencies
uv syncImportant: The agents need to be run separately from the main application.
Open three separate terminal windows and run:
Terminal 1 - Host Agent:
uv run python ollama_host_agent_server.pyTerminal 2 - Search Agent:
uv run python ollama_simple_search_agent_server.pyTerminal 3 - Main Application:
uv run python app.pyOpen your browser and go to: http://localhost:8000
The application will automatically discover and connect to the running agent servers.
You can also use the provided startup script which will start all services:
./start.shTo stop all services:
./stop.sh- Interactive canvas with Fabric.js
- Layer-based collaboration (agents can't delete each other's work)
- Brush controls (color, size)
- Undo/Redo functionality
- Agent drawing modes
- Add agents dynamically
- Configure tools per agent
- Color coding for each agent
- Status toggle (active/inactive)
- Layer information display
- Modification requests between agents
- Layer protection system
- Real-time WebSocket communication
- Conversation history with export
- Agent coordination
- Add Mermaid charts to canvas
- Position diagrams anywhere
- Agent attribution tracking
- Connect to your existing A2A agent servers
- Task distribution across agents
- Response aggregation
- Error handling
The key innovation is that agents cannot delete each other's work:
- Agent Isolation: Each agent works on their own layer
- No Cross-Deletion: Agents cannot modify each other's drawings
- Modification Requests: Formal system for requesting changes
- Visual Feedback: Target agent highlighting for requests
- Layer Statistics: Real-time object counts and status
- Frontend: HTML5 Canvas with Fabric.js, WebSocket communication
- Backend: FastAPI with WebSocket support
- Agents: A2A-compatible agent servers
- Communication: Real-time WebSocket messaging
CompanionAgent/
βββ app.py # Main FastAPI application
βββ ollama_host_agent_server.py # Host agent server
βββ ollama_simple_search_agent_server.py # Search agent server
βββ templates/ # HTML templates
βββ static/ # Static assets (CSS, JS)
βββ start.sh # Startup script
βββ stop.sh # Stop script
βββ README.md # This file
- Create a new agent server file (e.g.,
my_agent_server.py) - Follow the pattern of existing agent servers
- Add the agent to
KNOWN_AGENT_SERVERSinapp.py - Start the new agent server in a separate terminal
Each agent server can be customized by modifying:
- Response logic in the
handle_taskfunction - Agent capabilities in the agent card
- Integration with external services (Ollama, APIs, etc.)
- Open the interface at http://localhost:8000
- Use the brush tools to draw on the canvas
- Add agents using the "Add Agent" button
- Send queries to agents to have them draw
- Add multiple agents with different capabilities
- Send a complex query that requires coordination
- Watch agents collaborate and draw on their respective layers
- Use modification requests to ask agents to change their work
- Use the "Add Mermaid" button to add diagrams
- Position diagrams on the canvas
- Have agents reference and work around the diagrams
Agents not discovered:
- Ensure agent servers are running on the correct ports
- Check that the main application can reach the agent servers
- Verify the agent card endpoints are accessible
WebSocket connection issues:
- Check that the main application is running on port 8000
- Ensure no firewall is blocking the connection
- Check browser console for WebSocket errors
Agent communication failures:
- Verify A2A client initialization
- Check agent server logs for errors
- Ensure proper message format
Check the terminal outputs for:
- Agent server startup messages
- WebSocket connection status
- Agent discovery logs
- Error messages
This project is licensed under the MIT License.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
For issues and questions:
- Check the troubleshooting section
- Review the logs
- Open an issue with detailed information