tot-state
Personal Travel Agent (V4)
🎓 학술·교육적 맥락
이 프로젝트는 **카네기 멜론 대학교(Carnegie Mellon University, CMU) 컴퓨터 과학부(School of Computer Science)**에서 제공하는 Agentic AI Program: Building Autonomous Systems for Real-World Applications 프로그램 과정을 위해 제작되었습니다.
저자: Anthony Wang | 교육 및 연구 목적으로만 개발되었습니다.
🌟 핵심 요약
Personal Travel Agent는 엄격한 공간적·재정적·시간적·페이싱 제약 조건 속에서 복잡한 기간별 여행 일정 생성 문제를 해결하는 자율적 멀티모달 여행 계획 시스템입니다.
일반적인 단일 턴(single-turn) LLM 생성 방식과 선형(linear) ReAct 루프는 전방 검색(lookahead), 백트래킹(backtracking), 그리고 엄격한 제약 검증이 부족하여 멀티데이 일정을 만들 때 높은 회기율(25%~40%)을 보입니다. 본 시스템은 **이중 계층 인지 아키텍처(Two-Tier Cognitive Architecture)**를 도입하여 이러한 한계를 해결합니다:
Tier 1: 외부 ReAct 루프 (대화 및 기반 확보) – 대화 처리, 의도 라우팅, 사용자 선호 추출, pgvector 기반 의미 기억 회상, 그리고 기초 도구 기반(항공편, 숙박, 잔여 예산 계산)을 담당합니다.
Tier 2: 내부 Tree of Thought (ToT) 검색 엔진 – 결정론적 하드-제약 게이트키퍼, 5차원 보정 루버릭 비평 평가자, 보호된 복구 슬롯 1개, 컴퓨팅 가드레일을 갖춘 **빔 검색($b=4, k=3, N \le 7$)**을 통해 조합 최적화 방식의 멀티데이 여행 일정 문제를 해결합니다.
오픈 MCP 피드를 통한 실시간 기반 도구 – Open-Meteo API(실시간 기상 및 지오코딩 피드)와 Frankfurter API(유럽 중앙은행 ECB)의 33개 이상 글로벌 통화 공식 환율)을 포함한 실제·제로-목업 외부 API에 연결합니다.
글로벌 여행 목적지 RAG 카탈로그 – **전 세계 156개 주요 목적지(국가 및 도시)**를 대상으로 큐레이션된 현지 지역, 문화적 명소, 이동 베이스라인, 음식 특색, 가격 추정치를 담은 사전 인덱스 벡터 저장소.
Cloud Run에서 제공하는 인터랙티브 UI – 실시간 채팅, 동적 SVG Tree of Thought 검색 트리 시각화, 레이더 차트, 실시간 날씨/FX 기반 위젯, 반응형 다크/라이트 테마 토글을 갖춘 글래스모피즘 웹 인터페이스.
Related MCP server: MCP Memory Server
🏛️ 시스템 아키텍처
flowchart TD
User(["👤 User Request / Prompt"]) --> UI["🌐 Glassmorphism Web UI / CLI / ADK Web"]
subgraph Tier1 ["Tier 1: Outer ReAct Grounding & Intent Loop"]
UI --> Router{"Intent Classifier"}
Router -- "Weather / FX" --> LiveTools["Live Grounding MCP Services"]
Router -- "Destination RAG" --> VectorStore[("PostgreSQL + pgvector\n(156 Destinations & User Memory)")]
Router -- "Plan Trip" --> ReActAgent["TravelAgentRunner (ReAct Agent)"]
ReActAgent --> G1["search_flights()"]
ReActAgent --> G2["search_lodging()"]
ReActAgent --> G3["compute_residual_budget()"]
ReActAgent <--> VectorStore
G1 & G2 & G3 --> Frame["PlanningFrame\n(Immutable Contract: Dates, Lodging, Residual Daily Budget)"]
end
subgraph Tier2 ["Tier 2: Inner Tree of Thought (ToT) Combinatorial Engine"]
Frame --> BeamController["BeamSearchEngine (k=3, b=4, N<=7)"]
BeamController --> Gen["DayPlanGenerator\n(Proposes 4 anchor-diverse candidates per node)"]
Gen --> Stage1{"Stage 1: Hard Constraint Gatekeeper\n- Budget ceiling\n- Daily transit <= 120m\n- Operating hours"}
Stage1 -- Fail --> Pruned["Mark PRUNED\n(Pruning floor < 0.45)"]
Stage1 -- Pass --> Stage2["Stage 2: 5D Calibrated Rubric Critic\n(Headroom, Geo, Prefs, Variety, Feasibility)"]
Stage2 --> RescueLogic{"Rescue Slot Activation\n(Confidence < 0.60 or Δscore <= 0.10)"}
RescueLogic -- Reserve 1 slot --> BeamNodes["Active Beam Set (k=3 nodes / depth)"]
RescueLogic -- Top-ranked --> BeamNodes
BeamNodes <--> FastMCP["FastMCP tot-state Server\n(State persistence in PostgreSQL)"]
BeamNodes --> Termination{"d == N or Budget Exhausted?"}
Termination -- No --> Gen
Termination -- Yes --> BestPlan["Select Highest Scoring Complete Path"]
end
subgraph LiveMCP ["Live Open MCP Grounding Feeds"]
LiveTools --> OpenMeteo["🌤️ Open-Meteo API\n(Real-time Weather & Geocoding)"]
LiveTools --> Frankfurter["💱 Frankfurter API\n(Live ECB Exchange Rates for 33+ Currencies)"]
end
BestPlan --> Formatter["Response Formatter & Graph Generator"]
Formatter --> UI📐 Tree of Thought (ToT) 수학적 정식화
1. 검색 매개변수
분기 계수($b$) – 활성 빔 노드당 생성되는 앵커-다양성(anchor-diverse) 후보 thought는 $4$개입니다.
빔 너비($k$) – 일별 깊이 $d \in [1, N]$ ($N \le 7$)에서 유지되는 활성 분기는 $3$개입니다.
제거 기준(Pruning Floor) – $\text{Composite Score} < 0.45 \implies \text{PRUNED}$.
수용 임계값 – $\text{Composite Score} \ge 0.75$.
복구 슬롯(Rescue Slot) – 평가 불확실성($\text{Confidence} < 0.60$ 또는 $\Delta \text{score} \le 0.10$)에 맞닥뜨린 고잠재치 후보를 위해 빨간 그릇에 예약된 $1$개 보호 슬롯.
컴퓨팅 가드레일 – 검색 세션당 LLM 호출 40회 및 45.0초 월시계(wall-clock) 수의 엄격한 제한.
2. 5차원 보정 루브릭(Calibrated Rubric)
$$\text{Composite Score} = 0.20 \cdot S_{\text{headroom}} + 0.20 \cdot S_{\text{geo}} + 0.25 \cdot S_{\text{pref}} + 0.20 \cdot S_{\text{quality}} + 0.15 \cdot S_{\text{forward}}$$
차원 | 가중치 | 설명 |
제약 여유 공간 ($S_{\text{headroom}}$) |
| 잔여 예산 및 일일 통근 상한($\le 120$분) 대비 여유를 평가하는 휴리스틱 안전 마진. |
공간적 일관성 ($S_{\text{geo}}$) |
| 인접하지 않은 도시 구역/지역 간에 지그재그를 보이며 움직이는 것을 페널티하는 공간 클러스터링 지표. |
선호 정합성 ($S_{\text{pref}}$) |
| 사용자 관심사(예: 요리, 현대 미술, 역사적 사원)와 활동 테마 간의 의미론적 코사인 유사성. |
경험 품질 ($S_{\text{quality}}$) |
| 일일 속도(여유 루즈로 $\le 2$개 주요 활동), 식사 시간, 주변 지역 다양성을 평가합니다. |
전향 가능 가능성 ($S_{\text{forward}}$) |
| 잔여 예산이 향후 일정을 유지할 수 있는지 예측하는 전방 탐색 휴리스틱($0.10$ 비평 예측 $+ 0.05$ 예산 여유마진). |
📊 벤치마크 및 제거(ablation) 연구
우리는 엄격한 예산 및 이동 제한(프라야 도쿄 문제 실제 작업 포함)이 있는 100개의 다중 일자 여행 요청에 대해 전통적인 Linear ReAct baseline과 Two-Tier Tree of Thought 아키텍처를 비교 평가했습니다:
지표 | Linear ReAct 기준 | Tree of Thought (V4) | 순수 개선 |
하드 제약 충족률 | 68.0% | 100.0% | +32.0% |
검색 회자율 / 빔 붕괴율 | 32.0% | 0.0% | -100.0% |
평균 복합 품질 점수 | 0.742 | 0.945 | +27.4% |
예산 준수 정확도 | 71.0% | 100.0% | +29.0% |
요금당 평균 LLM 호출 | 3.6 calls | 28–38 calls | 40회 호출 예산 내 |
🚀 빠른 시작 및 로컬 설정
1. 사전 요구 사항
Python 3.10+
(선택) 로컬 PostgreSQL + pgvector용 Docker 및 Docker Compose
(선택) Google Cloud SDK (
gcloud) – GCP에 배포하는 경우
2. 저장소 복제 및 가상 환경 구성
git clone https://github.com/anthonywang-sg/Personal-Travel-Agent.git
cd Personal-Travel-Agent
# Create and activate virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies in editable mode
pip install -e ".[dev]"3. 환경 설정
템플릿 설정 파일을 복사합니다:
cp .env.example .envGoogle Cloud에서 Gemini Enterprise를 사용하는 경우를 위한 .env 편집하거나 GEMINI_API_KEY를 제공하세요:
# .env
APP_NAME="Personal Travel Agent V4"
ENVIRONMENT="development"
# Gemini Enterprise Agent Platform (or leave blank for standard API Key)
GOOGLE_GENAI_USE_ENTERPRISE=true
GOOGLE_CLOUD_PROJECT=your-gcp-project-id
GOOGLE_CLOUD_LOCATION=global
# Database (Optional local Docker default)
DATABASE_URL="postgresql+psycopg://postgres:postgres@localhost:5432/travel_agent"4. 웹 애플리케이션 실행
uvicorn travel_agent.web.app:app --host 0.0.0.0 --port 8080 --reload인터랙티브 웹 인터페이스에 접속하려면 **http://localhost:8080**로 이동하세요.
💻 CLI 도구 및 평가 하네스
이 시스템은 Typer와 Rich를 기반으로 한 풍부한 명령줄 도구 묶음을 제공합니다:
1. 다중 일일 여행 계획 실행
# Plan a 3-Day Tokyo culinary trip
travel-agent plan --destination Tokyo --days 3 --budget 2200
# Plan a 4-Day Cairo historic trip
travel-agent plan --destination Cairo --days 4 --budget 1800
# Plan a personalized trip for Priya (User Persona benchmark)
travel-agent plan --user-id priya_01 --destination Tokyo --days 4 --budget 2500 --lodging Shinjuku2. 오프라인 회귀 및 절제 평가 실행
travel-agent evaluate --trials 53. 사전 배포(pre-flight) 오픈 소스 시크릿 및 위생 검사 실행
travel-agent scan-secrets🧪 자동화 테스트 스위트
테스트 세트는 단위 모델, 휴리스틱 기반 도구, FastMCP 클라이언트/서버 생명주기, Tree of Thought 검색 엔진, ReAct 에이전트 클라이언트 통합, 그리고 저장소 보안을 다룹니다:
# Run all 21 automated tests
pytest tests/ -v============================== test session starts ==============================
tests/test_beam_search_engine.py::test_beam_search_4_day_itinerary PASSED [ 4%]
tests/test_beam_search_engine.py::test_beam_search_guardrails_and_best_effort PASSED [ 9%]
tests/test_beam_search_engine.py::test_beam_search_rescue_slot_activation PASSED [ 14%]
tests/test_cli_eval.py::test_cli_plan_command PASSED [ 19%]
tests/test_cli_eval.py::test_ablation_harness_metrics PASSED [ 23%]
tests/test_domain_models.py::test_day_plan_serialization PASSED [ 28%]
tests/test_domain_models.py::test_planning_frame_immutability PASSED [ 33%]
tests/test_generator_critic.py::test_thought_generator_diversity PASSED [ 38%]
tests/test_generator_critic.py::test_thought_critic_evaluation_rubric PASSED [ 42%]
tests/test_global_rag_and_mcp.py::test_global_destinations_catalog_loading_and_rag_search PASSED [ 47%]
tests/test_global_rag_and_mcp.py::test_external_mcp_services_and_client PASSED [ 52%]
tests/test_global_rag_and_mcp.py::test_end_to_end_multi_destination_planning PASSED [ 57%]
tests/test_grounding_heuristics.py::test_grounding_tools PASSED [ 61%]
tests/test_grounding_heuristics.py::test_hard_constraint_evaluation PASSED [ 66%]
tests/test_grounding_heuristics.py::test_heuristic_calculation PASSED [ 71%]
tests/test_mcp_tot_state.py::test_mcp_client_tree_lifecycle PASSED [ 76%]
tests/test_priya_worked_example.py::test_priya_worked_example_full_verification PASSED [ 80%]
tests/test_priya_worked_example.py::test_priya_ablation_superiority PASSED [ 85%]
tests/test_react_agent_integration.py::test_travel_agent_end_to_end_planning_flow PASSED [ 90%]
tests/test_storage_repositories.py::test_tot_branch_repository_crud PASSED [ 95%]
tests/test_storage_repositories.py::test_semantic_memory_chunk_filter_and_search PASSED [100%]
============================== 21 passed in 16.06s ==============================☁️ Google Cloud 배포
저장소에는 Google Cloud의 자동 프로비저닝 스크립트가 포함되어 있습니다:
Compute / Frontend: Google Cloud Run (컨테이너 Web UI)
Agent Orchestration: Gemini Enterprise Agent Platform (
reasoningEngines)추리 모델:
gemini-3.7-flash(위치:global)영속성 및 벡티 검색: Cloud SQL PostgreSQL 16 +
pgvector아티팩트 스토리지: Google Cloud Storage (
gs://personal-travel-agent-artifacts-*)
# 1. Provision Cloud Infrastructure
export GOOGLE_CLOUD_PROJECT=your-gcp-project-id
./deploy/provision_gcp.sh
# 2. Deploy Web UI to Cloud Run
./deploy/cloudrun_ui.sh
# 3. Deploy to Agent Engine
./deploy/agent_engine_deploy.sh🔒 보안 및 오픈소스 위생
하드코딩 시크릿 없음: 커스텀 레포지토리 산재 스캔 을 위해 사용자 스킬(
.agents/skills/sanitizing-repo-for-open-source/)을 통해 검증됨.유출된 PII 없음: 모든 벤치마크 및 사용자 페로소(них)는 100% 합성 데이터입니다.
환경 격리: 민감한 구성은 모두
.env파일 또는 클라우드 시크릿 관리자로만 로드됩니다.
📄 라이선스 및 학술 표시
이 프로젝트는 MIT 라이선스로 배포됩니다. 자세한 내용은 LICENSE 파일을 참조하세요.
카네기 멜론 대학교 컴퓨터 과학부의 Agentic AI Program: Building Autonomous Systems for Real-World Applications 프로그램의 일환으로 Anthony Wang이 개발되었습니다.
This server cannot be deployed
Maintenance
Related MCP Connectors
Versioned agent memory in your own Postgres: portable context, permissioned, audit trail.
Shared memory for AI agents, as a graph in your own Postgres. Writes never call an LLM.
PostgreSQL, MySQL, OpenAPI/Swagger, and shared Agent Memory with scoped access.
- mem0OAuthio.github.mem0ai
Persistent memory for AI agents: add, search, update, and delete long-term memories.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceImplements long-term memory capabilities for AI assistants using PostgreSQL with pgvector for efficient vector similarity search, enabling semantic retrieval of stored information.10 npm64MIT
- -licenseNot gradedqualityNot gradedmaintenanceEnables AI assistants to store and retrieve long-term memories using PostgreSQL with vector similarity search. Supports semantic memory operations, tagging, and real-time updates for persistent learning across conversations.-
- FlicenseNot gradedqualityDmaintenanceEnables AI agents to persist and retrieve structured thinking graphs using SQLite-backed memory with support for CRUD operations, graph search, and path finding.1-
- AlicenseNot gradedqualityBmaintenancePersistent semantic memory for AI agents using PostgreSQL and vector embeddings, enabling cross-session continuity and semantic search.AGPL 3.0