0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ACPで連携するマルチAIエージェントアプリの構築方法

Last updated at Posted at 2025-09-02

はじめに

今年8月にIBM CloudのサーバレスソリューションであるCode Engine上で動かすマルチエージェントAIのデモが公開されました。

簡単な手順でデモ環境を構築することができたので、本稿ではデモの構築方法とテストとしてマルチエージェントアプリを動かした結果を記載しています。

デモのシナリオについて

本稿で紹介するデモはマルチAIエージェントを使用した旅行代理店ツールです。

image.png

CodeEngine上には8つのアプリケーションを配置します。

1つはユーザーとやり取りをするためのフロントエンドアプリで、1つが専門的なエージェントを取りまとめるためのオーケストレートエージェントアプリ、残りの6つが専門的な回答を返すエージェントとなっています。

これらのエージェントを動かすLLMとして本シナリオではwatsonx.aiを使用しています。
使用するLLMは環境変数を変更することでOpenAI等別のLLMを使用することも可能です。

ACPとは

ACP(Agent Communication Protocol)はIBM ResearchやBeeAI、Linux Fuudation等のコミュニティが中心となり開発されているAIエージェント間通信のオープンな標準規格です。
ACPを利用することによって、エージェント作成時に複数のフレームワークを簡単に採用できます。

ACPの特徴として以下の要素が挙げられます。

  • HTTP/RESTベース
  • ステートレス設計
  • 非同期・イベント駆動に対応
  • モジュール化と相互運用性

従来のMCP(Model Context Protocol)と比較し、ベンダーにロックの回避やマルチエージェントへの対応などが優れいている点となります。

実装手順

  1. ローカルPCへソースコードのclone
  2. 環境変数の変更
  3. Code Engineへのデプロイ
  4. アプリのテスト

事前準備

以下の環境は事前に作成しているものとします。

  • watsonx.aiインスタンス
    • watsonx.aiプロジェクト(acp-demo)
  • IBM CloudのAPIKey

watsonx.aiインスタンスはCode Engineを動かすアカウントと別でも問題ないですが、watonx.aiのアカウントでAPI Keyを作成してください。

作成したwatsonx.aiのプロジェクトのProject IDとAPI Keyはのちに使用するため確認してください。

スクリーンショット_2025-09-01_9_53_26.png

また、作成したプロジェクトでサービスおよび統合でwatsonx.ai Runtimeが表示されていない場合はサービスの関連付けからwatsonx.ai Runtimeを紐づけてください。

image.png

1. ローカルPCへソースコードのclone

まずはじめにIBMのGitHubで提供されているacp-agentsをローカルPCへクローンします。

ソースのクローン
$ git clone https://github.com/IBM/CodeEngine
$ cd acp-agents

2. 環境変数の変更

watsonx.aiと結びつけるため、envファイルを作成します。
envファイルには事前準備で用意したAPIKEYPROJECT_IDを環境変数として記載します。
INFERENCE_BASE_URLはwatsonx.aiのあるリージョンと同じURLを選択してください。

環境変数の作成
$ vi .env
INFERENCE_BASE_URL=https://us-south.ml.cloud.ibm.com
INFERENCE_API_KEY=APIKEY
INFERENCE_MODEL_NAME=watsonx/meta-llama/llama-3-3-70b-instruct
INFERENCE_PROJECT_ID=PROJECT_ID

3. Code Engineへのデプロイ

ソースコードを元にCode Engineへアプリをデプロイします。

アプリのデプロイ
$ make dpeloy-codeengine

Code Engineのプロジェクト・アプリの設定はscripts/deploy.shファイルで制御されています。
プロジェクトやアプリの構成を変更したい場合はdeploy.shファイルを編集してください。

2025年8月現在ではdeploy.shにHotel_Plannerが含まれていないため、以下のコードを43行目に追加してください。

$ ibmcloud ce app create --name hotel-planner-agent --env-from-secret agent-secret --build-source ./agents/hotel_planner_agent --build-strategy dockerfile  --cpu 1 --memory 4G -p 8080  --wait-timeout 600 --min-scale 1 --visibility project --no-wait

アプリをデプロイする際、タイムアウトによって全てのアプリが正しくデプロイされない場合があります。
その場合はデプロイが失敗したアプリを削除し、再度makeコマンドを実施してください。

4. アプリのテスト

最後に正しくアプリケーションがデプロイできているか確認します。
クラウドポータルから作成したプロジェクトのtravel-concierge-projectを開きます。

左側のアプリケーションタブからフロントエンドアプリのtravel-concierge-chatの右側にあるURLを開くボタンを押すと旅行代理店ツールのアプリが開けます。

スクリーンショット_2025-09-01_13_47_52.png

画面下にある入力欄にチュートリアルシナリオと同様に文章を入力します。

image.png

旅行の要望
Plan a trip from Stuttgart to either Paris or Rome from October 10 for 6 days. I'm interested in sightseeing, coffee, family hotel, restaurants, activities with kids and technology trends. My budget is Mid-range (€1000-€1800) and I prefer historical sites, local cuisine, and avoiding crowded tourist traps

要望を入力後、以下の順でAgentが呼び出されます。

1. travel-concierge-agent

入力した要望をまとめ、それぞれのエージェントを呼び出しています。

🚀 I'm going to plan an itinerary based on the following information:

🏠 Travel origin: Stuttgart (Germany)
🌆 Travel destination(s): Paris (France), Rome (Italy)
📅 Travel period: 2025-10-10 - 2025-10-16 (5 nights)
🚣 Travel interests: sightseeing, coffee, restaurants, activities with kids, technology trends, historical sites
🎊 Travel preferences: family hotel, local cuisine, avoiding crowded tourist traps, activities with kids
💰 Travel budget: 1000 - 1800 (EUR)
🤖 My team of agents is now planning your trip ...

🤖 We see that you have given us multiple travel destinations, we will pick the ideal destination for you.

🤖 I'm handing off the planning to my colleague, the 🤖 City Selection agent.

2. city-selection-agent

要望を元に旅行の計画を作成します。

City Chosen: Paris
Paris, the City of Light, is renowned for its stunning architecture, art museums, and historical sites. For a traveler interested in sightseeing, coffee, restaurants, activities with kids, technology trends, and historical sites, Paris offers a plethora of attractions.

Overview
Paris is a city that seamlessly blends tradition and modernity, offering something for every interest and age group. From the iconic Eiffel Tower to the Louvre Museum, and from charming cafes to vibrant neighborhoods like Montmartre, Paris is a destination that promises an unforgettable experience.

Weather Forecast
Given the time of year and general climate, Paris typically experiences mild temperatures during the spring and autumn, with cooler winters and warm summers. However, it's essential to check the current weather forecast before traveling to ensure the best experience.

Cultural & Seasonal Events
Paris hosts various cultural and seasonal events throughout the year, including Bastille Day on July 14th, which features military parades, fireworks, and street parties, and the Rock en Seine music festival in late August. The Nuit Blanche, an all-night art festival, takes place on the first Saturday of October, offering exhibitions, performances, and installations across the city.

Attractions
Some top recommendations for attractions in Paris include:

The Eiffel Tower: An iconic symbol of Paris, offering breathtaking views of the city.
The Louvre Museum: Home to the Mona Lisa and an extensive collection of art and artifacts.
Notre-Dame Cathedral: A beautiful and historic cathedral that showcases Gothic architecture.
Disneyland Paris: Perfect for families with kids, offering various themed lands and attractions.
Musée des Égouts de Paris: A unique museum showcasing the history of Paris' sewer system, which might appeal to those interested in technology and infrastructure.
Café de Flore and Les Deux Magots: Famous cafes where one can enjoy coffee and people-watch.
Montmartre: A historic and artistic neighborhood with stunning views of the city, perfect for sightseeing and exploring local cuisine and coffee culture.
Local Culture & Customs
The French value politeness and courtesy. Greeting shopkeepers with a "bonjour" and saying "merci" when leaving is appreciated. Dining etiquette includes keeping hands visible on the table and not starting to eat until everyone has been served. Be mindful of pickpocketing in crowded areas and tourist hotspots, and avoid carrying large amounts of cash.

Food & Drink
Paris is a culinary paradise, offering a wide range of local cuisine, from traditional French dishes to modern fusion restaurants. Some highlights include:

Croissants and Baguettes: Freshly baked pastries and bread are a staple of French cuisine.
Cheese and Wine: France is famous for its variety of cheeses and wines. Consider a wine and cheese tasting experience.
Cafes: Parisian cafes are iconic, offering a place to enjoy coffee, people-watch, and relax.
Restaurants: From Michelin-starred establishments to cozy bistros, Paris has something for every taste and budget.
Travel Costs
Estimated flight costs from Stuttgart, Germany, to Paris, France, can range from approximately €120 to €180 for a round-trip, depending on the airline and time of booking. Hotel prices vary, with budget options starting from around €60 per night, mid-range hotels from €120 per night, and luxury hotels from €450 per night.

Travel Requirements
Check the latest travel advisories before your trip. Paris is generally safe, but as with any major city, there are areas that are safer than others, especially at night. No specific visas are required for short-term stays for most nationalities, but it's always best to check with the French embassy or consulate in your home country for the most current information.

Justification
Paris is chosen over Rome due to its unparalleled blend of historical, cultural, and entertainment options, making it a more versatile and appealing destination for a wide range of interests. While Rome offers a rich history and architectural wonders, Paris's unique charm, from its iconic landmarks to its quaint neighborhoods and culinary delights, makes it the best choice for an unforgettable travel experience.

🤖 I'm handing off the planning to my colleague, the Budget planner agent.

3. budget-planner-agent

要望の予算を元に旅行費の内訳を作成します。

Travel budget breakdown suggestions
Budget: 1000 EUR
Flights: 200 EUR
Accommodation: 500 EUR
Activities: 150 EUR
Food And Drinks: 75 EUR
Local Transport: 25 EUR
Miscellaneous: 50 EUR
🤖 I'm handing off the planning to my colleague, the City Expert agent to plan your trip to Paris, France.

4. city-expert-agent

旅行先の都市での旅行ガイドを作成します。

🤖 The City Expert agent has created the following travel guide for Paris, France.

Paris, France Travel Guide
Introduction
Paris, the capital of France, is a city known for its stunning architecture, art museums, and romantic atmosphere. It's a must-visit destination for anyone interested in history, culture, and entertainment.

Key Attractions
The Eiffel Tower: The iconic symbol of Paris, offering breathtaking views of the city. The ticket price for the Eiffel Tower is around €17 for adults and €8 for children.
The Louvre Museum: One of the world's largest and most famous museums, housing an impressive collection of art and artifacts, including the Mona Lisa. The ticket price for the Louvre Museum is around €18 for adults and free for children under 18.
Notre-Dame Cathedral: A beautiful and historic cathedral that was built in the 12th century. The ticket price for Notre-Dame Cathedral is around €15 for adults and free for children under 18.
Arc de Triomphe: A monumental arch that honors the soldiers who fought and died for France. The ticket price for the Arc de Triomphe is around €12 for adults and free for children under 18.
Local Customs
Greeting: The French typically greet each other with a kiss on each cheek, known as "la bise."
Dining: Mealtimes are sacred in France, and it's customary to enjoy a leisurely lunch or dinner at a café or restaurant.
Tipping: It's customary to leave a small tip, around 5-10%, at cafes and restaurants.
Special Events
Bastille Day: A national holiday celebrated on July 14th, commemorating the French Revolution.
Paris Fashion Week: A bi-annual event that showcases the latest fashion trends.
Rock en Seine: A music festival that takes place in August, featuring international and French artists.
Daily Activity Recommendations
Take a Seine River cruise to see the city's landmarks and bridges. The ticket price for a Seine River cruise is around €15 for adults and €7 for children.
Explore the Montmartre neighborhood, known for its bohemian vibe, street artists, and stunning views.
Visit the Galeries Lafayette or Le Bon Marché for a luxurious shopping experience.
Weather Forecast
Paris has a temperate climate, with warm summers and cool winters. The best time to visit is in the spring (April-May) or autumn (September-October), when the weather is mild and pleasant.

High-Level Costs
Accommodation: Hostel dorms start from €20-€30 per night, while budget hotels start from €60-€80 per night.
Food: A meal at a café or restaurant can cost between €15-€30 per person.
Transportation: A single ticket for the metro or bus costs €1.90, while a carnet of 10 tickets costs €14.50.
Hidden Gems
Musée de Montmartre: A small museum that showcases the history and art of the Montmartre neighborhood. The ticket price for the Musée de Montmartre is around €10 for adults and free for children under 18.
Le Jardin des Plantes: A beautiful botanical garden that's home to over 10,000 plant species. The ticket price for the Le Jardin des Plantes is around €13 for adults and free for children under 18.
Canal Saint-Martin: A charming canal that's perfect for a leisurely walk or picnic.
Cultural Hotspots
Le Marais: A trendy neighborhood known for its fashionable boutiques, art galleries, and restaurants.
Belleville: A vibrant neighborhood that's home to a diverse community of artists, musicians, and immigrants.
Saint-Germain-des-Prés: A historic neighborhood that's known for its upscale boutiques, cafes, and restaurants.
Practical Tips
Learn some basic French phrases, such as "bonjour" (hello), "merci" (thank you), and "excusez-moi" (excuse me).

Buy a Paris Museum Pass to skip the lines at popular attractions.

Be mindful of pickpocketing in crowded areas and tourist hotspots.

5. hotel-planner-agent

予算と日程を元に利用可能なホテルを提示します。

🤖 We are now looking for hotels ...

🤖 The Hotel agent has found the following hotel information for you ...

Unfortunately, no hotels are available within the given budget of 500 EUR for 5 nights in Paris, France.

6. flight-planner-agent

予算と日程を元に利用可能な飛行機の便を提示します。

🤖 We are now looking for flights ...

🤖 The Flight agent has found the following flight information for you ...

Segment	From	To	Departure	Arrival	Flight Number	Duration	Direct
Outbound	Stuttgart	Paris	2025-10-10 06:30	2025-10-10 08:05	AF 1351	1h 35m	Yes
Return	Paris	Stuttgart	2025-10-16 19:30	2025-10-16 21:05	AF 1354	1h 35m	Yes
Air France — Total Price: 180 EUR

Segment	From	To	Departure	Arrival	Flight Number	Duration	Direct
Outbound	Stuttgart	Paris	2025-10-10 08:30	2025-10-10 10:05	LH 2253	1h 35m	Yes
Return	Paris	Stuttgart	2025-10-16 21:30	2025-10-16 23:05	LH 2256	1h 35m	Yes
Lufthansa — Total Price: 190 EUR

Segment	From	To	Departure	Arrival	Flight Number	Duration	Direct
Outbound	Stuttgart	Paris	2025-10-10 10:30	2025-10-10 12:05	KL 2001	1h 35m	Yes
Return	Paris	Stuttgart	2025-10-16 18:30	2025-10-16 20:05	KL 2004	1h 35m	Yes
KLM — Total Price: 195 EUR

Segment	From	To	Departure	Arrival	Flight Number	Duration	Direct
Outbound	Stuttgart	Paris	2025-10-10 12:30	2025-10-10 14:05	A5 2011	1h 35m	Yes
Return	Paris	Stuttgart	2025-10-16 20:30	2025-10-16 22:05	A5 2014	1h 35m	Yes
HOP! — Total Price: 198 EUR

Segment	From	To	Departure	Arrival	Flight Number	Duration	Direct
Outbound	Stuttgart	Paris	2025-10-10 14:30	2025-10-10 16:05	UX 1011	1h 35m	Yes
Return	Paris	Stuttgart	2025-10-16 22:30	2025-10-16 00:05	UX 1014	1h 35m	Yes
Air Europa — Total Price: 199 EUR

7. itinerary-planner-agent

最後に作成した旅行計画をまとめます。

🤖 We are creating an itinerary for you now ...

🤖 Here is your itinerary:

The final answer is a detailed multi-day Markdown-formatted travel itinerary for Paris, France, including daily schedules, weather forecasts, clothing and packing suggestions, estimated budget breakdowns, and recommendations for flights, hotels, attractions, and restaurants.

🤖 Let me know if you want me to plan another trip.

アプリケーションを実行後、watsonx.aiの画面でリソース使用量を確認すると、100000~150000トークンを使用していることが確認できます。(アプリ使用前は100000トークン→使用後250000トークン)
image.png

watsonx.aiのライトプランは1ヶ月あたり300000トークンまで無償で利用できるため、無償枠では2回ほどこちらのアプリを動かすことができます。

まとめ

本稿ではIBMで提供されているACPで連携するマルチAIエージェントアプリの構築方法について記載しました。

デフォルトでは1vCPUx4GB, 1node常時稼働で構成されていますが、構成をゼロスケールさせるように変更することで課金を抑えて試すことができます。

watsonx.aiも無償枠の範囲内で試すことができますので、AIエージェントのアプリ作成に興味のある方はぜひお試しください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?