Issue: Model download fails or 401 errors
# Solution: Set your HuggingFace token
export HUGGINGFACE_TOKEN=hf_xxxxxGet your token from: https://huggingface.co/settings/tokens
Issue: 404 Not Found for url: https://router.huggingface.co/hf-inference/...
Cause: Invalid provider name hf-inference
Solution: Leave AGENT_INFERENCE_PROVIDER empty for auto-routing:
AGENT_INFERENCE_PROVIDER= # Empty, NOT 'hf-inference'Valid provider names: nebius, together, fireworks, hyperbolic, cerebras
Issue: Model returns 404 or "model not found"
Cause: Not all models are hosted on HF Inference API
Solution: Use a supported model:
# These work on free tier:
TEXT2SQL_MODEL=Qwen/Qwen2.5-Coder-7B-Instruct
TEXT2SQL_MODEL=meta-llama/Llama-3.2-3B-Instruct
TEXT2SQL_MODEL=Qwen/Qwen2.5-Coder-32B-InstructCheck model availability:
from huggingface_hub import model_info
info = model_info("model-name")
print(info.inference) # Should be 'warm' or 'hot'Issue: CUDA out of memory or process killed
Solution: Enable quantization:
ENABLE_8BIT_QUANTIZATION=true # Reduces memory ~50%
# OR
ENABLE_4BIT_QUANTIZATION=true # Maximum compressionOr use HF Inference API instead of local:
AGENT_MODEL_BACKEND=hf_inferenceIssue: Responses take >10 seconds
Solutions:
-
Reduce reasoning steps:
AGENT_MAX_STEPS=3
-
Use a faster model:
TEXT2SQL_MODEL=meta-llama/Llama-3.2-3B-Instruct
-
Enable caching (repeated queries are instant)
Issue: Agent keeps retrying without progress
Solutions:
-
Lower confidence threshold:
AGENT_MIN_CONFIDENCE=0.6
-
Check logs for validation errors:
docker logs text2sql-agent 2>&1 | grep -i error
-
Verify database schema is accessible
Issue: Can't connect to database
Solutions:
-
Verify connection string format:
# PostgreSQL DATABASE_URL=postgresql://user:pass@host:5432/db # With SSL DATABASE_URL=postgresql://user:pass@host:5432/db?sslmode=require
-
Check network/firewall access
-
Verify credentials
Issue: resolution-too-deep or dependency conflicts
Solution: Install with constraints:
pip install -r requirements.txt -c constraints.txt
# OR
bash scripts/install_with_constraints.shIssue: Generated SQL doesn't match your schema
Solutions:
-
Add few-shot examples via API:
curl -X POST http://localhost:8000/api/v1/examples \ -H "Content-Type: application/json" \ -d '{"query": "...", "sql": "...", "database_id": "..."}'
-
Ensure schema introspection is working:
curl http://localhost:8000/api/v1/schema/your_database_id
Issue: Build runs out of space or takes too long
Solutions:
-
Use CPU-only build (smaller):
docker build --build-arg TORCH_CPU=true -t text2sql-agent . -
Clean Docker cache:
docker system prune -a
-
Use BuildKit caching:
DOCKER_BUILDKIT=1 docker build -t text2sql-agent .
-
Check the logs:
docker logs text2sql-agent # Or for local: uvicorn app.main:app --reload 2>&1 | tee app.log
-
Enable debug mode:
API_DEBUG=true
-
Open an issue: https://github.com/Sakeeb91/text2sql-agent/issues