Skip to main content
Glama

Personal Travel Agent (V4)

Python 3.10+ FastAPI FastMCP PostgreSQL Google Cloud Run License: MIT

🎓 学術・教育目的
このプロジェクトは、カーネギーメロン大学(CMU)コンピュータサイエンス学部が提供するエージェンティックAIプログラム:実世界アプリケーションのための自律システム構築のために構築されました。
著者:Anthony Wang | 厳密に教育および研究目的で開発されました。


🌟 エグゼクティブサマリー

Personal Travel Agent は、厳格な空間的・金銭的・時間的・ペーシング制約の下で、複数日にわたる組み合わせ最適化旅行行程を生成する自律型マルチモーダル旅行計画システムです。

標準的な単一ターンLLM生成と線形ReActループは、先読み・バックトラッキング・厳密な制約検証が欠如しているため、複数日旅行の構築において高いリグレット率(25%~40%)に悩まされています。このシステムは、2層認知アーキテクチャを導入することでこれらの限界を解決します:

  1. 第1層:外部ReActループ(対話とグラウンディング):会話対話、意図ルーティング、ユーザー嗜好抽出、pgvectorによる意味記憶検索、およびベースラインツールのグラウンディング(フライト、宿泊、残予算計算)を処理します。

  2. 第2層:内部Tree of Thought(ToT)検索エンジンビームサーチ($b=4, k=3, N \le 7$) と決定論的ハード制約ゲートキーパー、5次元キャリブレーション済みルーブリック批評家、1つの保護リザーブスロット、および計算ガードレールを使用して、組み合わせ複数日行程最適化問題を解決します。

  3. Open MCPフィードによるライブグラウンディングツールOpen-Meteo API(ライブ気象およびジオコーディングフィード)やFrankfurter API(欧州中央銀行公式外国為替レート、33以上の世界通貨)など、リアルタイムでモックなしの外部APIに接続します。

  4. グローバル目的地RAGカタログ156の世界の目的地(国と世界都市) をカバーする事前インデックス化されたベクターリポジトリで、厳選された地元の近隣地域、文化的ランドマーク、交通ベースライン、料理の特産品、価格ヒューリスティックを備えています。

  5. Cloud Run上のインタラクティブUI:リアルタイムチャット、動的SVG Tree of Thought検索ツリー可視化、レーダーチャート、ライブ天気/FXグラウンディングウィジェット、レスポンシブなダーク/ライトテーマ切り替えを備えたグラスモーフィズムWebインターフェース。


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$):アクティブなビームノードごとに生成されるアンカー多様な候補思考は$4$。

  • ビーム幅($k$):各日深度$d \in [1, N]$($N \le 7$)で保持されるアクティブブランチは$3$。

  • 剪定フロア:$\text{Composite Score} < 0.45 \implies \text{PRUNED}$。

  • 受理閾値:$\text{Composite Score} \ge 0.75$。

  • リザーブスロット:評価不確実性に直面する高潜在候補のためにビームに予約された$1$保護スロット($\text{Confidence} < 0.60$ または $\Delta \text{score} \le 0.10$)。

  • 計算ガードレール:検索セッションごとにLLM呼び出し40回壁時計時間45.0秒の厳格な制限。

2. 5次元キャリブレーション済みルーブリック

$$\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}}$)

0.20

残予算と日次交通上限($\le 120$分)に対するバッファを評価するヒューリスティック安全マージン。

地理的整合性($S_{\text{geo}}$)

0.20

非隣接の市街区/地区間のジグザグ移動をペナルティする空間クラスタリングメトリック。

嗜好整合性($S_{\text{pref}}$)

0.25

ユーザーの興味(例:料理、現代アート、歴史的寺院)とアクティビティテーマ間の意味的コサイン類似度。

体験品質($S_{\text{quality}}$)

0.20

日次ペーシング(リラックスペースでは主要アクティビティ$\le 2$)、食事タイミング、近隣の多様性を評価。

前方実現可能性($S_{\text{forward}}$)

0.15

残予算が将来の日を維持できるかどうかを予測する先読みヒューリスティック($0.10$批評家予測$+ 0.05$予算マージン)。


📊 ベンチマークとアブレーション研究

厳格な予算と交通制約を持つ100件の複数日旅行リクエスト(Priya Tokyoの実例を含む)に対して、2層Tree of Thoughtアーキテクチャを従来の線形ReActベースラインと評価しました:

メトリック

線形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回

28–38回

40コール予算内


🚀 クイックスタートとローカルセットアップ

1. 前提条件

  • Python 3.10+

  • (オプション)ローカルPostgreSQL + pgvector用のDocker & Docker Compose

  • (オプション)GCPにデプロイする場合はGoogle Cloud SDK(gcloud

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 .env

Google 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. Webアプリケーションを実行

uvicorn travel_agent.web.app:app --host 0.0.0.0 --port 8080 --reload

http://localhost:8080 に移動して、インタラクティブなWebインターフェースにアクセスします。


💻 CLIツールと評価ハーネス

このシステムは、TyperRich を搭載した豊富なコマンドラインスイートを提供します:

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 Shinjuku

2. オフラインリグレットとアブレーション評価の実行

travel-agent evaluate --trials 5

3. プレフライトオープンソースシークレット&衛生スキャナーの実行

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用の自動プロビジョニングスクリプトが含まれています:

  • コンピュート / フロントエンド:Google Cloud Run(コンテナ化されたWeb UI)

  • エージェントオーケストレーション: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ファイルを参照してください。

Anthony Wang によって、カーネギーメロン大学コンピュータサイエンス学部エージェンティックAIプログラム:実世界アプリケーションのための自律システム構築の一環として開発されました。

A
license - permissive license
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • -
    license
    Not graded
    quality
    Not graded
    maintenance
    Enables 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.
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to persist and retrieve structured thinking graphs using SQLite-backed memory with support for CRUD operations, graph search, and path finding.
    1
  • A
    license
    Not graded
    quality
    F
    maintenance
    Persistent semantic memory for AI agents using PostgreSQL and vector embeddings, enabling cross-session continuity and semantic search.
    AGPL 3.0

View all related MCP servers

Related MCP Connectors

  • Persistent memory for AI agents — verbatim conversations, searchable by meaning.

  • Persistent memory for AI agents. Search, store, and recall across sessions.

  • Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/anthonywang-sg/Personal-Travel-Agent'

If you have feedback or need assistance with the MCP directory API, please join our Discord server