Spaces:
Running
Running
"Docs: Add Architecture, Agents & Troubleshooting guides; Update README (Demo links coming soon)"
Browse files- README.md +78 -15
- doc/AGENTS.md +83 -0
- doc/ARCHITECTURE.md +132 -0
- doc/TROUBLESHOOTING.md +58 -0
README.md
CHANGED
|
@@ -8,7 +8,7 @@ sdk_version: 5.49.1
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
-
short_description:
|
| 12 |
tags:
|
| 13 |
- mcp-in-action-track-enterprise
|
| 14 |
- mcp-in-action-track-consumer
|
|
@@ -17,10 +17,16 @@ tags:
|
|
| 17 |
|
| 18 |
# β¨ LifeFlow AI: Intelligent Trip Planning System
|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
|
|
|
| 23 |
|
|
|
|
| 24 |
## π₯ Team
|
| 25 |
|
| 26 |
### Team Information:
|
|
@@ -29,9 +35,9 @@ tags:
|
|
| 29 |
|
| 30 |
|
| 31 |
## πΊ Demo & Submission
|
| 32 |
-
- Demo Video
|
| 33 |
-
- Social Media Post
|
| 34 |
-
- Submission Date
|
| 35 |
|
| 36 |
|
| 37 |
## π Overview
|
|
@@ -91,25 +97,82 @@ LifeFlow AI allows deep customization via the **Settings** panel:
|
|
| 91 |
* **Groq:** Llama 3.3 70B, GPT-OSS 120B, Kimi K2.
|
| 92 |
|
| 93 |
### Fast Mode (Hybrid)
|
| 94 |
-
Enable **Fast Mode** in settings to offload search and routing tasks to Groq.
|
|
|
|
| 95 |
|
| 96 |
---
|
| 97 |
|
| 98 |
-
##
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
---
|
| 106 |
|
| 107 |
## π» Local Installation
|
| 108 |
|
| 109 |
-
To run LifeFlow AI locally:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
|
|
|
| 111 |
```bash
|
| 112 |
-
|
| 113 |
```
|
| 114 |
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
+
short_description: Don't just plan the trip. Design the flow.
|
| 12 |
tags:
|
| 13 |
- mcp-in-action-track-enterprise
|
| 14 |
- mcp-in-action-track-consumer
|
|
|
|
| 17 |
|
| 18 |
# β¨ LifeFlow AI: Intelligent Trip Planning System
|
| 19 |
|
| 20 |
+
[](https://gradio.app/)
|
| 21 |
+
[](https://github.com/agno-agi/agno)
|
| 22 |
+
[](https://www.python.org/)
|
| 23 |
+
[](https://www.docker.com/)
|
| 24 |
+
[](LICENSE)
|
| 25 |
|
| 26 |
+
> **Your journey, in perfect rhythm.**
|
| 27 |
+
> An enterprise-grade, multi-agent system that orchestrates your daily schedule using real-world data, hybrid AI architecture, and mathematical optimization.
|
| 28 |
|
| 29 |
+
---
|
| 30 |
## π₯ Team
|
| 31 |
|
| 32 |
### Team Information:
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
## πΊ Demo & Submission
|
| 38 |
+
- **Demo Video:** [Coming Soon]
|
| 39 |
+
- **Social Media Post:** [Coming Soon]
|
| 40 |
+
- **Submission Date:** November 2025
|
| 41 |
|
| 42 |
|
| 43 |
## π Overview
|
|
|
|
| 97 |
* **Groq:** Llama 3.3 70B, GPT-OSS 120B, Kimi K2.
|
| 98 |
|
| 99 |
### Fast Mode (Hybrid)
|
| 100 |
+
Enable **Fast Mode** in settings to offload search and routing tasks to Groq.
|
| 101 |
+
This significantly reduces latency and API costs while maintaining high-quality reasoning for the final output.
|
| 102 |
|
| 103 |
---
|
| 104 |
|
| 105 |
+
## π οΈ Tech Stack & Components
|
| 106 |
|
| 107 |
+
| Component | Technology | Description |
|
| 108 |
+
| :--- |:--------------------------------------------------------------| :--- |
|
| 109 |
+
| **Frontend** | [Gradio](https://www.gradio.app/) | Reactive UI with custom CSS, Stepper, and Map integration. |
|
| 110 |
+
| **Orchestration** | [Agno](https://github.com/agno-agi/agno) | Manages Agent state, memory, and team coordination. |
|
| 111 |
+
| **Tool Protocol** | [FastMCP](https://github.com/jlowin/fastmcp) | Exposes Python functions as standardized AI tools. |
|
| 112 |
+
| **Models** | [Google Gemini](https://ai.google.dev/) | **Flash** for Leader/Planner (Reasoning), **Flash-Lite** for Workers (Speed). |
|
| 113 |
+
| **Optimization** | [Google OR-Tools](https://developers.google.com/optimization) | Solves TSPTW (Traveling Salesperson Problem with Time Windows). |
|
| 114 |
+
| **Data Layer** | [SQLite](https://www.sqlite.org/index.html) | Local file-based repository for high-speed context offloading. |
|
| 115 |
|
| 116 |
---
|
| 117 |
|
| 118 |
## π» Local Installation
|
| 119 |
|
| 120 |
+
To run LifeFlow AI locally, follow these steps:
|
| 121 |
+
|
| 122 |
+
### Prerequisites
|
| 123 |
+
- Python 3.11+
|
| 124 |
+
- Virtualenv (recommended)
|
| 125 |
+
|
| 126 |
+
### Installation Steps
|
| 127 |
+
|
| 128 |
+
1. **Clone the repository**
|
| 129 |
+
```bash
|
| 130 |
+
git clone [https://huggingface.co/spaces/Marco310/LifeFlow-AI](https://huggingface.co/spaces/Marco310/LifeFlow-AI)
|
| 131 |
+
cd LifeFlow-AI
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
2. Create and activate a virtual environment
|
| 135 |
+
```bash
|
| 136 |
+
# Linux/MacOS
|
| 137 |
+
python -m venv venv
|
| 138 |
+
source venv/bin/activate
|
| 139 |
+
|
| 140 |
+
# Windows
|
| 141 |
+
python -m venv venv
|
| 142 |
+
venv\Scripts\activate
|
| 143 |
+
```
|
| 144 |
|
| 145 |
+
3. Install dependencies
|
| 146 |
```bash
|
| 147 |
+
pip install -r requirements.txt
|
| 148 |
```
|
| 149 |
|
| 150 |
+
4. Set up Environment Variables Create a .env file in the root directory (optional if using UI for keys):
|
| 151 |
+
```env
|
| 152 |
+
# Search API
|
| 153 |
+
GOOGLE_MAPS_API_KEY=your_key_here
|
| 154 |
+
OPENWEATHER_API_KEY=your_key_here
|
| 155 |
+
|
| 156 |
+
# MODEL API
|
| 157 |
+
GOOGLE_API_KEY=your_key_here
|
| 158 |
+
OPENAI_API_KEY=your_key_here
|
| 159 |
+
GROQ_API_KEY=your_key_here
|
| 160 |
+
```
|
| 161 |
+
|
| 162 |
+
5. Run the application
|
| 163 |
+
```bash
|
| 164 |
+
python app.py
|
| 165 |
+
```
|
| 166 |
+
|
| 167 |
+
## π Documentation
|
| 168 |
+
|
| 169 |
+
Explore the technical details behind LifeFlow AI:
|
| 170 |
+
|
| 171 |
+
- [**ποΈ Architecture Design**](doc/ARCHITECTURE.md)
|
| 172 |
+
> Deep dive into the **"Dual-Brain" system**, **Context Offloading**, and **Exclusive MCP Channels**.
|
| 173 |
+
|
| 174 |
+
- [**π€ The Agent Team**](doc/AGENTS.md)
|
| 175 |
+
> Detailed roster of our 6 specialized agents, their models, tools, and prompt strategies.
|
| 176 |
+
|
| 177 |
+
- [**π§ Troubleshooting Guide**](doc/TROUBLESHOOTING.md)
|
| 178 |
+
> Solutions for common API errors (Google/OpenWeather), JSON parsing issues, and Docker setup.
|
doc/AGENTS.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π€ The Agent Team
|
| 2 |
+
|
| 3 |
+
LifeFlow AI is not a single bot, but a coordinated **Multi-Agent System (MAS)**. Each agent is a specialized "worker" with restricted permissions, specific tools, and a distinct model configuration to optimize for cost and performance.
|
| 4 |
+
|
| 5 |
+
## π₯ The Roster
|
| 6 |
+
|
| 7 |
+
### 1. π Planner (The Architect)
|
| 8 |
+
* **Model:** `Gemini 2.5 Flash` (High Reasoning)
|
| 9 |
+
* **Role:** The entry point. It never executes tasks but "understands" them.
|
| 10 |
+
* **Responsibility:**
|
| 11 |
+
* Parses vague natural language into structured JSON.
|
| 12 |
+
* Assigns categories (MEAL, SIGHTSEEING) and priorities.
|
| 13 |
+
* Estimates durations based on context (e.g., "coffee" = 30m, "museum" = 2h).
|
| 14 |
+
|
| 15 |
+
### 2. π¨ββοΈ Team Leader (The Orchestrator)
|
| 16 |
+
* **Model:** `Gemini 2.5 Flash`
|
| 17 |
+
* **Role:** The State Machine. It manages the `core_team`.
|
| 18 |
+
* **Responsibility:**
|
| 19 |
+
* Receives the Task List from the Planner.
|
| 20 |
+
* Enforces the strict pipeline sequence: `Scout -> Optimizer -> Navigator`.
|
| 21 |
+
* Handles error recovery (e.g., if Scout fails, it asks to retry).
|
| 22 |
+
* **Crucial:** It does *not* see the raw data, only the **Reference IDs**.
|
| 23 |
+
|
| 24 |
+
### 3. πΊοΈ Scout (The Explorer)
|
| 25 |
+
* **Model:** `Gemini 2.5 Flash-Lite` (Speed Optimized)
|
| 26 |
+
* **Tools:** `ScoutToolkit` (Google Places API)
|
| 27 |
+
* **Key Feature:** **Robust JSON Parsing**. The Scout includes a custom parser to handle malformed JSON often output by LLMs, ensuring high reliability even with smaller models.
|
| 28 |
+
* **Task:** Performs "Adaptive Search" (allocating more API budget to harder queries).
|
| 29 |
+
|
| 30 |
+
### 4. β‘ Optimizer (The Mathematician)
|
| 31 |
+
* **Model:** `Gemini 2.5 Flash-Lite`
|
| 32 |
+
* **Tools:** `OptimizationToolkit` (Google OR-Tools)
|
| 33 |
+
* **Algorithm:** TSPTW (Traveling Salesperson Problem with Time Windows).
|
| 34 |
+
* **Logic:**
|
| 35 |
+
* Loads POIs from the DB.
|
| 36 |
+
* Calculates a Distance Matrix (Manhattan/Haversine approximation).
|
| 37 |
+
* Reorders stops to minimize travel time while respecting opening hours.
|
| 38 |
+
* Marks tasks as "Dropped" if they don't fit the schedule.
|
| 39 |
+
|
| 40 |
+
### 5. π§ Navigator (The Driver)
|
| 41 |
+
* **Model:** `Gemini 2.5 Flash-Lite`
|
| 42 |
+
* **Tools:** `NavigationToolkit` (Google Routes API)
|
| 43 |
+
* **Task:**
|
| 44 |
+
* Takes the logical sequence from the Optimizer.
|
| 45 |
+
* Queries **Google Routes API** for precise "Traffic-Aware" travel times.
|
| 46 |
+
* Generates the polyline geometry for the map UI.
|
| 47 |
+
|
| 48 |
+
### 6. π€οΈ Weatherman (The Meteorologist)
|
| 49 |
+
* **Model:** `Gemini 2.5 Flash-Lite`
|
| 50 |
+
* **Tools:** `WeatherToolkit` (OpenWeatherMap)
|
| 51 |
+
* **Innovation:** **Dynamic Timezone Handling**.
|
| 52 |
+
* Calculates the exact arrival time at each stop.
|
| 53 |
+
* Fetches the specific forecast for that *hour* and *location*.
|
| 54 |
+
* Retrieves Air Quality Index (AQI).
|
| 55 |
+
|
| 56 |
+
---
|
| 57 |
+
|
| 58 |
+
## π§ Model Configuration Strategy
|
| 59 |
+
|
| 60 |
+
We use a tiered model strategy to balance intelligence and latency:
|
| 61 |
+
|
| 62 |
+
| Agent Tier | Model | Rationale |
|
| 63 |
+
| :--- | :--- | :--- |
|
| 64 |
+
| **Brain Tier**<br>(Planner, Leader) | `gemini-2.5-flash` | Requires complex instruction following and context management. Needs higher context window. |
|
| 65 |
+
| **Muscle Tier**<br>(Scout, Optimizer, etc.) | `gemini-2.5-flash-lite` | Performs single-shot tool execution. Speed is prioritized over nuance. |
|
| 66 |
+
|
| 67 |
+
## π‘οΈ Tool Isolation (Exclusive Mode)
|
| 68 |
+
|
| 69 |
+
In `app.py`, we implement a unique **Exclusive MCP Connection**:
|
| 70 |
+
|
| 71 |
+
```python
|
| 72 |
+
# Pseudo-code logic from app.py
|
| 73 |
+
AGENT_TOOL_MAP = {
|
| 74 |
+
"scout": "search_and_offload",
|
| 75 |
+
"optimizer": "optimize_from_ref",
|
| 76 |
+
# ...
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
# Each agent gets its own private server instance
|
| 80 |
+
for agent, tool in AGENT_TOOL_MAP.items():
|
| 81 |
+
connect_mcp(agent, include_tools=[tool])
|
| 82 |
+
This prevents the "Navigator" from accidentally trying to search for places, or the "Scout" from trying to calculate routes, significantly reducing loop errors.
|
| 83 |
+
```
|
doc/ARCHITECTURE.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ποΈ System Architecture
|
| 2 |
+
|
| 3 |
+
LifeFlow AI implements a novel **"Dual-Brain"** architecture combined with a **Context-Offloading Protocol** to solve the scalability issues of traditional Agentic workflows. This document details the system design, data flow, and infrastructure.
|
| 4 |
+
|
| 5 |
+
## π High-Level Design
|
| 6 |
+
|
| 7 |
+
The system is built on a modular microservices-like architecture using **Agno (Phidata)** for orchestration and **FastMCP** for tool isolation.
|
| 8 |
+
|
| 9 |
+
```mermaid
|
| 10 |
+
graph TD
|
| 11 |
+
User[User Interface] -->|Gradio Websocket| App[Application Core]
|
| 12 |
+
App -->|Input Analysis| Planner[π Planner Agent]
|
| 13 |
+
|
| 14 |
+
subgraph "Core Team (State Machine)"
|
| 15 |
+
Leader[π¨ββοΈ Team Leader]
|
| 16 |
+
Leader -->|Delegates| Scout[πΊοΈ Scout]
|
| 17 |
+
Leader -->|Delegates| Optimizer[β‘ Optimizer]
|
| 18 |
+
Leader -->|Delegates| Navigator[π§ Navigator]
|
| 19 |
+
Leader -->|Delegates| Weatherman[π€οΈ Weatherman]
|
| 20 |
+
Leader -->|Delegates| Presenter[π Presenter]
|
| 21 |
+
end
|
| 22 |
+
|
| 23 |
+
Planner -->|Task List JSON| Leader
|
| 24 |
+
|
| 25 |
+
subgraph "The 'Hot Potato' Data Pipeline"
|
| 26 |
+
direction LR
|
| 27 |
+
DB[(POI Repository / SQLite)]
|
| 28 |
+
Scout -.->|Write Raw POIs| DB
|
| 29 |
+
DB -.->|Read Ref ID| Optimizer
|
| 30 |
+
Optimizer -.->|Write Ordered List| DB
|
| 31 |
+
DB -.->|Read Opt ID| Navigator
|
| 32 |
+
Navigator -.->|Write Routes| DB
|
| 33 |
+
DB -.->|Read Nav ID| Weatherman
|
| 34 |
+
Weatherman -.->|Write Final Timeline| DB
|
| 35 |
+
end
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
## π Key Architectural Patterns
|
| 39 |
+
1. Context Offloading Protocol ("Hot Potato")
|
| 40 |
+
Traditional agents pass massive JSON blobs (search results, reviews, coordinates) back and forth in the chat context, quickly hitting token limits and causing hallucinations.
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
### LifeFlow's Solution:
|
| 44 |
+
- Data Isolation: Agents NEVER see the full data payload.
|
| 45 |
+
- Reference Passing: Agents only exchange Reference IDs (e.g., scout_result_123).
|
| 46 |
+
- Mechanism:
|
| 47 |
+
1. Scout finds 50+ locations, saves them to poi_repo, and returns {"scout_ref": "uuid"} to the Leader.
|
| 48 |
+
2. Leader passes this UUID to the Optimizer.
|
| 49 |
+
3. Optimizer loads data from the repo, solves the TSPTW problem, and saves the result.
|
| 50 |
+
* Result: Reduces token consumption by ~90% for complex trips.
|
| 51 |
+
|
| 52 |
+
2. Exclusive MCP Channels (Tool Isolation)
|
| 53 |
+
In standard multi-agent setups, all tools are often dumped into a shared context, confusing the LLM (e.g., the "Optimizer" trying to use "Weather" tools).
|
| 54 |
+
|
| 55 |
+
### LifeFlow's Solution (in app.py):
|
| 56 |
+
We implement a custom Lifecycle Manager that spins up isolated FastMCP connections for each agent.
|
| 57 |
+
- Scout Agent $\leftrightarrow$ Channel A (Only search_and_offload)
|
| 58 |
+
- Optimizer Agent $\leftrightarrow$ Channel B (Only optimize_from_ref)
|
| 59 |
+
- Navigator Agent $\leftrightarrow$ Channel C (Only calculate_traffic_and_timing)
|
| 60 |
+
This guarantees 100% Tool Usage Accuracy and prevents agents from hallucinating tool calls.
|
| 61 |
+
|
| 62 |
+
### π The Unifying Link: Shared State via Reference IDs
|
| 63 |
+
|
| 64 |
+
While the **Execution Channels** (A, B, C) are strictly isolated to prevent tool hallucinations, they share a **Unified State Layer**.
|
| 65 |
+
|
| 66 |
+
The "Glue" connecting these isolated environments is the **Database Reference ID** (e.g., `scout_ref_uuid`).
|
| 67 |
+
|
| 68 |
+
* **Mechanism:**
|
| 69 |
+
* **Channel A (Scout)** executes a search, writes the heavy JSON payload to the shared **POI Repository (DB)**, and returns *only* the ID `ref_123`.
|
| 70 |
+
* The **Leader Agent** passes `ref_123` to **Channel B (Optimizer)**.
|
| 71 |
+
* **Channel B** uses its tool (`optimize_from_ref`) to "hydrate" the data by reading `ref_123` from the same shared DB, processes it, and saves a new `ref_456`.
|
| 72 |
+
|
| 73 |
+
This architecture ensures that while **Tools are Private** (security & accuracy), **Data is Global** (accessibility).
|
| 74 |
+
|
| 75 |
+
```mermaid
|
| 76 |
+
graph LR
|
| 77 |
+
subgraph Execution ["β‘ Isolated Execution Channels"]
|
| 78 |
+
A[Channel A: Scout]
|
| 79 |
+
B[Channel B: Optimizer]
|
| 80 |
+
C[Channel C: Navigator]
|
| 81 |
+
end
|
| 82 |
+
|
| 83 |
+
subgraph Storage ["πΎ Unified Storage Layer"]
|
| 84 |
+
DB[(POI Repository)]
|
| 85 |
+
end
|
| 86 |
+
|
| 87 |
+
%% Data Flow
|
| 88 |
+
A -->|Write Data| DB
|
| 89 |
+
B <-->|Read/Write Data| DB
|
| 90 |
+
C <-->|Read/Write Data| DB
|
| 91 |
+
|
| 92 |
+
%% ID Passing
|
| 93 |
+
A -.->|Pass Ref ID| B
|
| 94 |
+
B -.->|Pass Ref ID| C
|
| 95 |
+
|
| 96 |
+
%% Styling
|
| 97 |
+
style DB fill:#f9f,stroke:#333,stroke-width:2px
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
## π οΈ Tech Stack & Compon**ents**
|
| 101 |
+
|
| 102 |
+
| Component | Technology | Description |
|
| 103 |
+
| :--- |:------------------| :--- |
|
| 104 |
+
| **Frontend** | Gradio 5.49.1 | Reactive UI with custom CSS, Stepper, and Map integration. |
|
| 105 |
+
| **Orchestration** | Agno (Phidata) | Manages Agent state, memory, and team coordination. |
|
| 106 |
+
| **Tool Protocol** | FastMCP | Exposes Python functions as standardized AI tools. |
|
| 107 |
+
| **Models** | Google Gemini 2.5 | **Flash** for Leader/Planner (Reasoning), **Flash-Lite** for Workers (Speed). |
|
| 108 |
+
| **Optimization** | Google OR-Tools | Solves TSPTW (Traveling Salesperson Problem with Time Windows). |
|
| 109 |
+
| **Data Layer** | SQLite / JSON | Local file-based repository for high-speed context offloading. |
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
## π Data Flow Example
|
| 113 |
+
1. User Input: "Plan a day in SF, visit Pier 39 and get crab."
|
| 114 |
+
|
| 115 |
+
2. Planner: Converts to structured JSON Tasks.
|
| 116 |
+
|
| 117 |
+
3. Leader: Receives Tasks β Delegates to Scout.
|
| 118 |
+
> Scout: Calls Google Places API β Saves 20 candidates β Returns ref_scout.
|
| 119 |
+
|
| 120 |
+
4. Leader: Delegates to Optimizer.
|
| 121 |
+
> Optimizer: Loads ref_scout β Runs OR-Tools β Returns ref_opt (Sorted).
|
| 122 |
+
|
| 123 |
+
5. Leader: Delegates to Navigator.
|
| 124 |
+
> Navigator: Loads ref_opt β Calls Google Routes (Traffic) β Returns ref_nav.
|
| 125 |
+
|
| 126 |
+
6. Leader: Delegates to Weatherman.
|
| 127 |
+
> Weatherman: Loads ref_nav β Checks OpenWeather β Returns ref_final.
|
| 128 |
+
|
| 129 |
+
7. Leader: Delegates to Presenter.
|
| 130 |
+
> Presenter: Reads ref_final β Generates UI Report.
|
| 131 |
+
|
| 132 |
+
8. User sees a complete, optimized itinerary with maps and weather.
|
doc/TROUBLESHOOTING.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# π§ Troubleshooting Guide
|
| 2 |
+
|
| 3 |
+
This guide addresses common issues when running LifeFlow AI locally, particularly regarding API integrations and Docker environments.
|
| 4 |
+
|
| 5 |
+
## π΄ Common Errors & Solutions
|
| 6 |
+
|
| 7 |
+
### 1. JSON Parsing Errors (Scout Agent)
|
| 8 |
+
**Symptom:** `β Error: Invalid JSON format.`
|
| 9 |
+
**Cause:** The LLM (especially smaller models like Flash-Lite) may output markdown backticks or Python-style booleans (`True` instead of `true`) in the JSON.
|
| 10 |
+
**Solution:**
|
| 11 |
+
* LifeFlow includes a `_robust_parse_json` method in `scout_toolkit.py` that attempts to auto-repair malformed JSON.
|
| 12 |
+
* If this persists, verify that your prompt explicitly requests "Raw JSON, no markdown".
|
| 13 |
+
|
| 14 |
+
### 2. Google Maps API: `REQUEST_DENIED` or `OVER_QUERY_LIMIT`
|
| 15 |
+
**Symptom:** Agent loop fails, or Map is empty.
|
| 16 |
+
**Check:**
|
| 17 |
+
* Ensure the following APIs are enabled in your Google Cloud Console:
|
| 18 |
+
* **Places API (New)**
|
| 19 |
+
* **Routes API**
|
| 20 |
+
* **Maps JavaScript API** (for UI)
|
| 21 |
+
* **Billing:** You must have a billing account linked, even for the free tier.
|
| 22 |
+
|
| 23 |
+
### 3. MCP Connection Failed / Port Conflicts
|
| 24 |
+
**Symptom:** `β [System] MCP Connection Failed` in the console log.
|
| 25 |
+
**Cause:** The application attempts to spawn multiple subprocesses for `mcp_server_lifeflow.py`. If a previous run didn't close properly, ports/files might be locked.
|
| 26 |
+
**Solution:**
|
| 27 |
+
* Manually kill python processes: `pkill -f mcp_server_lifeflow.py`
|
| 28 |
+
* Restart the application.
|
| 29 |
+
|
| 30 |
+
### 4. "Ref ID Not Found" Loop
|
| 31 |
+
**Symptom:** The Leader Agent keeps asking the Scout to search again because it "cannot find the data".
|
| 32 |
+
**Cause:** The `poi_repo` (SQLite/File) might be persisting data from an old session, or the `session_id` mismatch.
|
| 33 |
+
**Solution:**
|
| 34 |
+
* Delete the `tmp/` directory or the database file to clear the cache.
|
| 35 |
+
* The system includes an auto-correction mechanism (visible in `weather_toolkit.py`) that tries to fetch the *latest* ID if the specific one is missing. Check the logs for `π Auto-Correcting`.
|
| 36 |
+
|
| 37 |
+
## βοΈ Environment Variables (`.env`)
|
| 38 |
+
|
| 39 |
+
Make sure your `.env` file matches this structure exactly:
|
| 40 |
+
|
| 41 |
+
```ini
|
| 42 |
+
# Core LLM
|
| 43 |
+
GOOGLE_API_KEY=AIzaSy...
|
| 44 |
+
|
| 45 |
+
# Tools
|
| 46 |
+
GOOGLE_MAPS_API_KEY=AIzaSy... # Must have Places & Routes enabled
|
| 47 |
+
OPENWEATHER_API_KEY=abc123...
|
| 48 |
+
|
| 49 |
+
# Optional (for Fast Mode)
|
| 50 |
+
GROQ_API_KEY=gsk_...
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
## π Debugging Mode
|
| 54 |
+
To see the raw "Hot Potato" data flow:
|
| 55 |
+
1. Open core_team.py.
|
| 56 |
+
- Set debug_mode=True in creat_team.
|
| 57 |
+
2. Open config.py
|
| 58 |
+
- Set LOG_LEVEL="DEBUG".
|