Troubleshooting
Common issues and solutions for LayerCode agent development.
Installation Issues
uv not found
Problem: command not found: uv
Solution:
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Add to PATH
export PATH="$HOME/.local/bin:$PATH"
# Verify installation
uv --version
Python version mismatch
Problem: Python 3.12 or higher required
Solution:
# Check Python version
python3 --version
# Install Python 3.12
# Ubuntu/Debian
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.12
# macOS
brew install python@3.12
Dependency conflicts
Problem: Package dependency resolution fails
Solution:
# Clear cache and reinstall
uv clean
uv sync --group dev
# If still failing, try with verbose output
uv sync --group dev --verbose
Configuration Issues
Missing environment variables
Problem: LAYERCODE_API_KEY not found
Solution:
# Check .env file exists
ls -la .env
# Copy from example if missing
cp .env.example .env
# Edit with your credentials
nano .env
# Verify environment is loaded
uv run layercode-create-app run --verbose
Invalid API keys
Problem: 401 Unauthorized or Invalid API key
Solution:
1. Verify keys in LayerCode dashboard
2. Check for extra spaces or quotes in .env
3. Ensure you're using the correct environment (test vs live)
# Correct format (no quotes)
LAYERCODE_API_KEY=lk_live_abc123
OPENAI_API_KEY=sk-abc123
# Incorrect format
LAYERCODE_API_KEY="lk_live_abc123" # Remove quotes
Wrong model specified
Problem: Model not found: openai:gpt-3.5
Solution:
# Use correct model format
uv run layercode-create-app run --agent starter --model openai:gpt-5-nano
# Check supported models
# OpenAI: openai:gpt-4, openai:gpt-5-nano
# Google: google:gemini-1.5-pro
Webhook Issues
Webhooks not received
Problem: No webhooks arriving at your endpoint
Solution:
-
Verify tunnel is running:
-
Check webhook URL in dashboard:
- Copy full URL including
/api/agent -
Example:
https://abc-def.trycloudflare.com/api/agent -
Test endpoint manually:
-
Check firewall/network:
- Ensure port 8000 is not blocked
- Verify no VPN interfering with tunnel
Signature verification fails
Problem: 401 Unauthorized - Invalid signature
Solution:
-
Verify webhook secret:
-
Check for middleware issues:
-
Disable verification for testing:
Tunnel disconnects
Problem: Cloudflare tunnel keeps disconnecting
Solution:
-
Restart tunnel:
-
Use ngrok as alternative:
Agent Issues
Agent not responding
Problem: Agent receives webhook but doesn't respond
Solution:
-
Check logs:
-
Verify AI provider credentials:
-
Test with echo agent:
Slow responses
Problem: Agent takes too long to respond
Solution:
-
Use faster model:
-
Check network latency:
-
Enable streaming:
Tool calls failing
Problem: Agent's tools are not working correctly
Solution:
-
Check tool signatures:
-
Test tool independently:
-
Check tool permissions:
Server Issues
Port already in use
Problem: Address already in use: 0.0.0.0:8000
Solution:
-
Use different port:
-
Kill existing process:
Server crashes on start
Problem: Server exits immediately after starting
Solution:
-
Check for Python errors:
-
Verify all files:
-
Check dependencies:
Development Issues
Type checking errors
Problem: mypy reports type errors
Solution:
-
Add type hints:
-
Use type ignore sparingly:
Linting errors
Problem: ruff reports formatting issues
Solution:
Tests failing
Problem: pytest tests fail
Solution:
-
Run tests with verbose output:
-
Run specific test:
-
Check test isolation:
Performance Issues
High memory usage
Problem: Agent consuming too much memory
Solution:
-
Clear conversation history:
-
Use memory profiling:
High latency
Problem: Response times are too slow
Solution:
-
Profile your code:
-
Use async properly:
-
Cache expensive operations:
Getting Help
If you're still stuck:
-
Check the logs:
-
Search GitHub issues:
-
Create a new issue:
- Include logs, error messages, and steps to reproduce
-
Mention your OS, Python version, and configuration
-
Join the community:
- LayerCode Discord
- Community forums
Common Error Messages
Agent not found: my-agent
Register your agent with @agent decorator.
Event type not supported: unknown_type
Handle all event types in your process method.
Failed to load prompt: prompts/missing.txt
Ensure prompt file exists in src/src/layercode_create_app/agents/prompts/.
Connection refused
Server not running or firewall blocking connection.
Too many requests
Hitting rate limits - implement backoff/retry logic.
Next Steps
- Deployment Guide - Production deployment
- Observability Guide - Monitoring and debugging