১. আপনি যা শিখবেন
স্বাগতম! আজ আমরা একটি দারুণ যাত্রা শুরু করতে চলেছি। চলুন, একটি জনপ্রিয় সামাজিক অনুষ্ঠান প্ল্যাটফর্ম ইন্সটাভাইব (InstaVibe)-এর কথা দিয়ে শুরু করা যাক। যদিও এটি সফল, আমরা জানি যে কিছু ব্যবহারকারীর জন্য দলবদ্ধ কার্যকলাপের পরিকল্পনা করাটা বেশ ঝামেলার কাজ বলে মনে হতে পারে। ভাবুন তো, আপনার সব বন্ধুরা কীসে আগ্রহী তা খুঁজে বের করার চেষ্টা করছেন, তারপর অনুষ্ঠান বা স্থানের অগণিত বিকল্পের মধ্যে থেকে বেছে নিচ্ছেন, এবং সবশেষে সবকিছু সমন্বয় করছেন। এটা অনেক বড় একটা কাজ! ঠিক এখানেই আমরা কৃত্রিম বুদ্ধিমত্তা (AI), এবং আরও নির্দিষ্টভাবে বললে, ইন্টেলিজেন্ট এজেন্টদের নিয়ে আসতে পারি, যা একটি সত্যিকারের পরিবর্তন আনতে পারে।
মূল উদ্দেশ্য হলো এমন একটি সিস্টেম তৈরি করা, যেখানে এই এজেন্টরা কঠিন কাজগুলো সামলাতে পারবে; যেমন—ব্যবহারকারী ও বন্ধুদের পছন্দ বোঝার জন্য বুদ্ধিমত্তার সাথে 'শুনতে' পারা এবং তারপর সক্রিয়ভাবে চমৎকার ও বিশেষভাবে তৈরি কার্যকলাপের পরামর্শ দেওয়া। আমাদের লক্ষ্য হলো InstaVibe-এর সোশ্যাল প্ল্যানিংকে একটি নির্বিঘ্ন ও আনন্দদায়ক অভিজ্ঞতায় রূপান্তরিত করা। এই স্মার্ট অ্যাসিস্ট্যান্টগুলো তৈরি শুরু করার জন্য, আমাদের সঠিক সরঞ্জাম দিয়ে একটি শক্তিশালী ভিত্তি স্থাপন করতে হবে।
এই হলো সেই ধারণা যা আপনি দেখতে পাবেন:

গুগলের ADK-এর সাথে ভিত্তি স্থাপন: গুগলের এজেন্ট ডেভেলপমেন্ট কিট (ADK) ব্যবহার করে আপনার প্রথম ইন্টেলিজেন্ট এজেন্ট তৈরির মূল বিষয়গুলো আয়ত্ত করুন। এর অপরিহার্য উপাদান, এজেন্টের জীবনচক্র এবং ফ্রেমওয়ার্কের অন্তর্নির্মিত টুলগুলো কীভাবে কার্যকরভাবে ব্যবহার করতে হয় তা বুঝুন।
মডেল কনটেক্সট প্রোটোকল (MCP) ব্যবহার করে এজেন্টের সক্ষমতা বৃদ্ধি: আপনার এজেন্টদের নিজস্ব টুল ও কনটেক্সট দিয়ে সজ্জিত করতে শিখুন, যা তাদের বিশেষায়িত কাজ সম্পাদন করতে এবং নির্দিষ্ট তথ্য অ্যাক্সেস করতে সক্ষম করবে। মডেল কনটেক্সট প্রোটোকল (MCP) ধারণাটির সাথে পরিচিত হন। এই কনটেক্সট সরবরাহ করার জন্য কীভাবে একটি MCP সার্ভার সেট আপ করতে হয়, তা আপনি শিখবেন।
এজেন্ট ইন্টারঅ্যাকশন ও অর্কেস্ট্রেশন ডিজাইন: একক এজেন্টের ধারণা থেকে বেরিয়ে এসে এজেন্ট অর্কেস্ট্রেশন বুঝুন। সাধারণ অনুক্রমিক ওয়ার্কফ্লো থেকে শুরু করে লুপ, শর্তসাপেক্ষ লজিক এবং প্যারালাল প্রসেসিং-এর মতো জটিল সিনারিও পর্যন্ত বিভিন্ন ইন্টারঅ্যাকশন প্যাটার্ন ডিজাইন করুন। মডিউলার টাস্কগুলো পরিচালনা করার জন্য ADK ফ্রেমওয়ার্কের মধ্যে সাব-এজেন্টের ধারণাটি প্রবর্তন করুন।
সহযোগিতামূলক মাল্টি-এজেন্ট সিস্টেম তৈরি: এমন সিস্টেম ডিজাইন করার পদ্ধতি জানুন যেখানে একাধিক এজেন্ট জটিল লক্ষ্য অর্জনের জন্য একসাথে কাজ করে। এজেন্ট-টু-এজেন্ট (A2A) কমিউনিকেশন প্রোটোকল শিখুন এবং প্রয়োগ করুন, যা বিভিন্ন স্থানে থাকা এজেন্টদের (যারা সম্ভবত ভিন্ন ভিন্ন মেশিন বা সার্ভিসে চলে) নির্ভরযোগ্যভাবে যোগাযোগ করার জন্য একটি প্রমিত পদ্ধতি প্রতিষ্ঠা করে।
গুগল ক্লাউডে এজেন্টদের প্রোডাকশন উপযোগী করে তোলা: আপনার এজেন্ট অ্যাপ্লিকেশনগুলোকে ডেভেলপমেন্ট এনভায়রনমেন্ট থেকে ক্লাউডে স্থানান্তর করুন। গুগল ক্লাউড প্ল্যাটফর্মে (GCP) স্কেলেবল ও শক্তিশালী মাল্টি-এজেন্ট সিস্টেম ডিজাইন এবং ডেপ্লয় করার সেরা পদ্ধতিগুলো জানুন। ক্লাউড রানের মতো GCP পরিষেবাগুলো ব্যবহারের কৌশল সম্পর্কে ধারণা লাভ করুন এবং আপনার এজেন্টদের হোস্ট ও পরিচালনা করার জন্য সর্বশেষ গুগল এজেন্ট ইঞ্জিনের সক্ষমতাগুলো অন্বেষণ করুন।
২. স্থাপত্য
ইনস্টাভাইব-এর সাথে এআই-চালিত সামাজিক পরিকল্পনা
সোশ্যাল লিসেনিং কী?
সোশ্যাল লিসেনিং হলো সোশ্যাল মিডিয়া, ফোরাম এবং নিউজ সাইটের মতো বিভিন্ন প্ল্যাটফর্মে ডিজিটাল কথোপকথন পর্যবেক্ষণ করার একটি প্রক্রিয়া, যার মাধ্যমে কোনো বিষয়, ব্র্যান্ড বা শিল্পক্ষেত্র সম্পর্কে মানুষ কী বলছে তা বোঝা যায়। এটি জনমত, প্রবণতা এবং ব্যবহারকারীর চাহিদা সম্পর্কে মূল্যবান অন্তর্দৃষ্টি প্রদান করে। এই কর্মশালায়, আমরা একটি এজেন্ট-ভিত্তিক সিস্টেমের মধ্যে এই ধারণাটিকে কাজে লাগাব।
আপনি InstaVibe-এর টিমে আছেন।
ধরুন, আপনি 'ইনস্টাভাইব'-এ কাজ করেন, যা তরুণ প্রাপ্তবয়স্কদের লক্ষ্য করে তৈরি একটি জনপ্রিয় সামাজিক ইভেন্ট প্ল্যাটফর্মসহ একটি সফল স্টার্টআপ। সবকিছু ভালোই চলছে, কিন্তু অন্যান্য অনেক প্রযুক্তি কোম্পানির মতোই, আপনার দলও কৃত্রিম বুদ্ধিমত্তা (AI) ব্যবহার করে নতুন কিছু করার জন্য বিনিয়োগকারীদের চাপের সম্মুখীন হচ্ছে। অভ্যন্তরীণভাবে, আপনি ব্যবহারকারীদের এমন একটি অংশকেও লক্ষ্য করেছেন যারা অন্যদের মতো ততটা সক্রিয় নয় – হয়তো তারা দলবদ্ধভাবে কোনো কার্যক্রম শুরু করতে কম আগ্রহী অথবা পরিকল্পনা প্রক্রিয়াটিকে কঠিন বলে মনে করে। আপনার কোম্পানির জন্য এর অর্থ হলো, এই গুরুত্বপূর্ণ ব্যবহারকারী গোষ্ঠীর মধ্যে প্ল্যাটফর্মের প্রতি আকর্ষণ কমে যাওয়া।
আপনার দলের গবেষণা থেকে জানা যায় যে, এআই-চালিত সহায়তা এই ব্যবহারকারীদের অভিজ্ঞতাকে উল্লেখযোগ্যভাবে উন্নত করতে পারে। এর মূল উদ্দেশ্য হলো, ব্যবহারকারী ও তার বন্ধুদের আগ্রহের উপর ভিত্তি করে সক্রিয়ভাবে প্রাসঙ্গিক কার্যকলাপের পরামর্শ দিয়ে সামাজিক ভ্রমণের পরিকল্পনা প্রক্রিয়াকে আরও সহজ ও সুগম করা। আপনি এবং আপনার সহকর্মীরা যে প্রশ্নের সম্মুখীন হচ্ছেন তা হলো: এআই এজেন্টরা কীভাবে আগ্রহ খুঁজে বের করা, কার্যকলাপ নিয়ে গবেষণা করা এবং সম্ভাব্য প্রাথমিক সমন্বয়ের মতো প্রায়শই সময়সাপেক্ষ কাজগুলোকে স্বয়ংক্রিয় করতে পারে?
এজেন্ট-ভিত্তিক সমাধান (প্রোটোটাইপ ধারণা)
আপনি একটি মাল্টি-এজেন্ট সিস্টেম দ্বারা চালিত প্রোটোটাইপ ফিচার তৈরির প্রস্তাব করেছেন। এর একটি ধারণাগত বিবরণ নিচে দেওয়া হলো:

- সোশ্যাল প্রোফাইলিং এজেন্ট : এই এজেন্ট ব্যবহারকারীর সংযোগ, মিথস্ক্রিয়া এবং ব্যবহারকারীর পছন্দের সাথে সম্পর্কিত সম্ভাব্য বৃহত্তর জন প্রবণতা বিশ্লেষণ করতে সোশ্যাল লিসেনিং কৌশল ব্যবহার করে। এর উদ্দেশ্য হলো সাধারণ আগ্রহ এবং উপযুক্ত কার্যকলাপের বৈশিষ্ট্য (যেমন, শান্ত পরিবেশে জমায়েতের প্রতি পছন্দ, নির্দিষ্ট শখ) শনাক্ত করা।
- ইভেন্ট প্ল্যানিং এজেন্ট : সোশ্যাল প্রোফাইলিং এজেন্টের দেওয়া তথ্য ব্যবহার করে, এই এজেন্ট চিহ্নিত মানদণ্ডের (যেমন অবস্থান, আগ্রহ) সাথে সামঞ্জস্যপূর্ণ নির্দিষ্ট ইভেন্ট, ভেন্যু বা ধারণার জন্য অনলাইন রিসোর্স অনুসন্ধান করে।
- প্ল্যাটফর্ম ইন্টারঅ্যাকশন এজেন্ট (এমসিপি ব্যবহার করে) : এই এজেন্ট অ্যাক্টিভিটি প্ল্যানিং এজেন্টের কাছ থেকে চূড়ান্ত পরিকল্পনাটি গ্রহণ করে। এর মূল কাজ হলো একটি পূর্ব-নির্ধারিত এমসিপি (মডেল কনটেক্সট প্রোটোকল) টুল ব্যবহার করে সরাসরি ইন্সটাভাইব প্ল্যাটফর্মের সাথে যোগাযোগ করা। এই টুলটি এজেন্টকে একটি ইভেন্টের প্রস্তাবনা তৈরি করার এবং পরিকল্পনাটির রূপরেখা দিয়ে একটি পোস্ট তৈরি করার নির্দিষ্ট ক্ষমতা প্রদান করে।
- অর্কেস্ট্রেটর এজেন্ট : এই এজেন্টটি কেন্দ্রীয় সমন্বয়কারী হিসেবে কাজ করে। এটি ইন্সটাভাইব প্ল্যাটফর্ম থেকে ব্যবহারকারীর প্রাথমিক অনুরোধ গ্রহণ করে, সামগ্রিক লক্ষ্যটি বোঝে (যেমন, "আমার এবং আমার বন্ধুদের জন্য একটি ইভেন্টের পরিকল্পনা করুন"), এবং তারপর একটি যৌক্তিক অনুক্রমে উপযুক্ত বিশেষায়িত এজেন্টদের কাছে নির্দিষ্ট কাজগুলো অর্পণ করে। এটি এজেন্টদের মধ্যে তথ্যের প্রবাহ পরিচালনা করে এবং চূড়ান্ত ফলাফল ব্যবহারকারীর কাছে পৌঁছে দেওয়া নিশ্চিত করে।
মূল স্থাপত্য উপাদান এবং প্রযুক্তি

গুগল ক্লাউড প্ল্যাটফর্ম (GCP):
- ভার্টেক্স এআই :
- জেমিনি মডেল: জেমিনির মতো গুগলের অত্যাধুনিক লার্জ ল্যাঙ্গুয়েজ মডেল (এলএলএম)-এ অ্যাক্সেস প্রদান করে, যা আমাদের এজেন্টদের যুক্তি ও সিদ্ধান্ত গ্রহণের ক্ষমতাকে চালিত করে।
- ভার্টেক্স এআই এজেন্ট ইঞ্জিন: একটি পরিচালিত পরিষেবা যা আমাদের অর্কেস্ট্রেটর এজেন্টকে স্থাপন, হোস্ট এবং স্কেল করতে ব্যবহৃত হয়, যা প্রোডাকশনাইজেশনকে সহজ করে এবং অবকাঠামোগত জটিলতা দূর করে।
- ক্লাউড রান : কন্টেইনারাইজড অ্যাপ্লিকেশন ডেপ্লয় করার জন্য একটি সার্ভারলেস প্ল্যাটফর্ম। আমরা এটি ব্যবহার করি:
- মূল InstaVibe ওয়েব অ্যাপ্লিকেশনটি হোস্ট করুন।
- স্বতন্ত্র A2A-সক্ষম এজেন্টগুলোকে (প্ল্যানার, সোশ্যাল প্রোফাইলিং, প্ল্যাটফর্ম ইন্টারঅ্যাকশন) স্বাধীন মাইক্রোসার্ভিস হিসেবে স্থাপন করুন।
- MCP টুল সার্ভারটি চালু করুন, যার ফলে এজেন্টদের জন্য InstaVibe-এর অভ্যন্তরীণ API-গুলো উপলব্ধ হবে।
- স্প্যানার : একটি সম্পূর্ণভাবে পরিচালিত, বিশ্বব্যাপী বিতরণকৃত, এবং দৃঢ়ভাবে সামঞ্জস্যপূর্ণ রিলেশনাল ডেটাবেস। এই কর্মশালায়, আমরা এর GRAPH DDL এবং কোয়েরি বৈশিষ্ট্য ব্যবহার করে একটি গ্রাফ ডেটাবেস হিসেবে এর সক্ষমতাকে কাজে লাগাবো:
- জটিল সামাজিক সম্পর্ক (ব্যবহারকারী, বন্ধুত্ব, ইভেন্টে উপস্থিতি, পোস্ট) মডেল করুন এবং সংরক্ষণ করুন।
- সোশ্যাল প্রোফাইলিং এজেন্টদের জন্য এই সম্পর্কগুলোর কার্যকর কোয়েরি সক্ষম করুন।
- আর্টিফ্যাক্ট রেজিস্ট্রি : কন্টেইনার ইমেজ সংরক্ষণ, ব্যবস্থাপনা এবং সুরক্ষিত করার জন্য একটি সম্পূর্ণভাবে পরিচালিত পরিষেবা।
- ক্লাউড বিল্ড : একটি পরিষেবা যা গুগল ক্লাউডে আপনার বিল্ডগুলো সম্পাদন করে। আমরা আমাদের এজেন্ট এবং অ্যাপ্লিকেশন সোর্স কোড থেকে স্বয়ংক্রিয়ভাবে ডকার কন্টেইনার ইমেজ তৈরি করতে এটি ব্যবহার করি।
- ক্লাউড স্টোরেজ : ক্লাউড বিল্ডের মতো পরিষেবাগুলো বিল্ড আর্টিফ্যাক্ট সংরক্ষণের জন্য এবং এজেন্ট ইঞ্জিন তার পরিচালনগত প্রয়োজনের জন্য এটি ব্যবহার করে।
- মূল এজেন্ট ফ্রেমওয়ার্ক ও প্রোটোকলসমূহ :
- গুগলের এজেন্ট ডেভেলপমেন্ট কিট (ADK) : এর প্রধান ফ্রেমওয়ার্ক:
- স্বতন্ত্র বুদ্ধিমান এজেন্টদের জন্য মূল যুক্তি, আচরণ এবং নির্দেশাবলী নির্ধারণ করা।
- এজেন্টের জীবনচক্র, অবস্থা এবং স্মৃতি (স্বল্পমেয়াদী সেশন অবস্থা এবং সম্ভাব্য দীর্ঘমেয়াদী জ্ঞান) পরিচালনা করা।
- এমন সব টুল (যেমন গুগল সার্চ বা বিশেষভাবে তৈরি টুল) একীভূত করা, যা ব্যবহার করে এজেন্টরা বিশ্বের সাথে যোগাযোগ করতে পারে।
- একাধিক এজেন্ট সমন্বিত কর্মপ্রবাহ পরিচালনা করা, যার মধ্যে সাব-এজেন্টদের অনুক্রমিক, লুপ এবং সমান্তরাল নির্বাহ অন্তর্ভুক্ত।
- এজেন্ট-টু-এজেন্ট (A2A) যোগাযোগ প্রোটোকল : একটি উন্মুক্ত মান যা সক্ষম করে:
- বিভিন্ন এআই এজেন্টের মধ্যে সরাসরি ও মানসম্মত যোগাযোগ এবং সহযোগিতা, এমনকি যদি তারা আলাদা পরিষেবা হিসেবে বা ভিন্ন ভিন্ন মেশিনে চলে।
- এজেন্টরা (এজেন্ট কার্ডের মাধ্যমে) একে অপরের সক্ষমতা সম্পর্কে জানতে এবং কাজ অর্পণ করতে পারে। আমাদের অর্কেস্ট্রেটর এজেন্টের বিশেষায়িত প্ল্যানার, সোশ্যাল এবং প্ল্যাটফর্ম এজেন্টদের সাথে যোগাযোগ করার জন্য এটি অত্যন্ত গুরুত্বপূর্ণ।
- A2A পাইথন লাইব্রেরি (a2a-python) : এটি আমাদের ADK এজেন্টদের A2A প্রোটোকল ব্যবহারে সক্ষম করার জন্য ব্যবহৃত নির্দিষ্ট লাইব্রেরি। এটি নিম্নলিখিত কাজগুলোর জন্য প্রয়োজনীয় সার্ভার-সাইড উপাদান সরবরাহ করে:
- আমাদের এজেন্টদের A2A-সম্মত সার্ভার হিসেবে চিহ্নিত করুন।
- অনুসন্ধানের জন্য 'এজেন্ট কার্ড' পরিবেশনের বিষয়টি স্বয়ংক্রিয়ভাবে পরিচালনা করুন।
- অন্যান্য এজেন্টদের (যেমন অর্কেস্ট্রেটর) কাছ থেকে আসা টাস্ক অনুরোধগুলি গ্রহণ ও পরিচালনা করুন।
- মডেল কনটেক্সট প্রোটোকল (MCP) : একটি উন্মুক্ত মান যা এজেন্টদের নিম্নলিখিত কাজগুলো করতে দেয়:
- বাহ্যিক সরঞ্জাম, ডেটা উৎস এবং সিস্টেমগুলোকে একটি প্রমিত পদ্ধতিতে সংযুক্ত করুন ও ব্যবহার করুন।
- আমাদের প্ল্যাটফর্ম ইন্টারঅ্যাকশন এজেন্ট একটি MCP ক্লায়েন্টের মাধ্যমে MCP সার্ভারের সাথে যোগাযোগ করে, যা ফলস্বরূপ InstaVibe প্ল্যাটফর্মের বিদ্যমান API-গুলোর সাথে ইন্টারঅ্যাক্ট করার জন্য টুলস সরবরাহ করে।
- গুগলের এজেন্ট ডেভেলপমেন্ট কিট (ADK) : এর প্রধান ফ্রেমওয়ার্ক:
- ডিবাগিং টুলস :
- A2A ইন্সপেক্টর : A2A ইন্সপেক্টর হলো একটি ওয়েব-ভিত্তিক ডিবাগিং টুল, যা এই ওয়ার্কশপ জুড়ে আমাদের A2A-সক্ষম এজেন্টগুলোর সাথে সংযোগ স্থাপন, পরিদর্শন এবং মিথস্ক্রিয়া করার জন্য ব্যবহৃত হয়। যদিও এটি চূড়ান্ত প্রোডাকশন আর্কিটেকচারের অংশ নয়, এটি আমাদের ডেভেলপমেন্ট ওয়ার্কফ্লোর একটি অপরিহার্য অংশ। এটি প্রদান করে:
- এজেন্ট কার্ড ভিউয়ার: কোনো এজেন্টের পাবলিক ক্যাপাবিলিটিগুলো সংগ্রহ ও যাচাই করার জন্য।
- লাইভ চ্যাট ইন্টারফেস: তাৎক্ষণিক পরীক্ষার জন্য সরাসরি ডেপ্লয় করা এজেন্টের কাছে বার্তা পাঠানোর জন্য।
- ডিবাগ কনসোল: ইন্সপেক্টর এবং এজেন্টের মধ্যে আদান-প্রদান হওয়া মূল JSON-RPC বার্তাগুলো দেখার জন্য।
- A2A ইন্সপেক্টর : A2A ইন্সপেক্টর হলো একটি ওয়েব-ভিত্তিক ডিবাগিং টুল, যা এই ওয়ার্কশপ জুড়ে আমাদের A2A-সক্ষম এজেন্টগুলোর সাথে সংযোগ স্থাপন, পরিদর্শন এবং মিথস্ক্রিয়া করার জন্য ব্যবহৃত হয়। যদিও এটি চূড়ান্ত প্রোডাকশন আর্কিটেকচারের অংশ নয়, এটি আমাদের ডেভেলপমেন্ট ওয়ার্কফ্লোর একটি অপরিহার্য অংশ। এটি প্রদান করে:
- ভাষা মডেল (এলএলএম) : সিস্টেমের 'মস্তিষ্ক'
- গুগলের জেমিনি মডেল: বিশেষত, আমরা gemini-2.0-flash- এর মতো সংস্করণগুলো ব্যবহার করি। এই মডেলগুলো নিম্নলিখিত কারণে বেছে নেওয়া হয়:
- উন্নত যুক্তি ও নির্দেশনা অনুসরণ: জটিল সংকেত বোঝা, বিস্তারিত নির্দেশনা অনুসরণ করা এবং কাজ সম্পর্কে যুক্তি দিয়ে বিচার করার ক্ষমতা তাদেরকে এজেন্টের সিদ্ধান্ত গ্রহণের চালিকাশক্তি হিসেবে উপযুক্ত করে তোলে।
- টুলের ব্যবহার (ফাংশন কলিং): জেমিনি মডেলগুলো ADK-এর মাধ্যমে প্রদত্ত টুলগুলো কখন এবং কীভাবে ব্যবহার করতে হবে তা নির্ধারণে অত্যন্ত পারদর্শী, যা এজেন্টদের তথ্য সংগ্রহ করতে বা বিভিন্ন কাজ সম্পাদন করতে সক্ষম করে।
- কার্যকারিতা (ফ্ল্যাশ মডেল): 'ফ্ল্যাশ' সংস্করণগুলো কর্মক্ষমতা এবং ব্যয়-সাশ্রয়ের একটি ভালো ভারসাম্য প্রদান করে, যা দ্রুত প্রতিক্রিয়া প্রয়োজন এমন অনেক ইন্টারেক্টিভ এজেন্ট কাজের জন্য উপযুক্ত।
- গুগলের জেমিনি মডেল: বিশেষত, আমরা gemini-2.0-flash- এর মতো সংস্করণগুলো ব্যবহার করি। এই মডেলগুলো নিম্নলিখিত কারণে বেছে নেওয়া হয়:
৩. শুরু করার আগে
👉Google Cloud কনসোলের উপরে থাকা Activate Cloud Shell-এ ক্লিক করুন (এটি Cloud Shell পেনের উপরে থাকা টার্মিনাল আকৃতির আইকন), 
👉"ওপেন এডিটর " বোতামে (এটি দেখতে পেন্সিলসহ একটি খোলা ফোল্ডারের মতো) ক্লিক করুন। এটি উইন্ডোতে ক্লাউড শেল কোড এডিটর খুলে দেবে। আপনি বাম দিকে একটি ফাইল এক্সপ্লোরার দেখতে পাবেন। 
👉নিচের স্ট্যাটাস বারে দেখানো অনুযায়ী ক্লাউড কোড সাইন-ইন বোতামে ক্লিক করুন। নির্দেশনা অনুযায়ী প্লাগইনটি অনুমোদন করুন। যদি আপনি স্ট্যাটাস বারে 'ক্লাউড কোড - কোনো প্রজেক্ট নেই' দেখতে পান, তাহলে সেটি নির্বাচন করুন, এরপর 'একটি গুগল ক্লাউড প্রজেক্ট নির্বাচন করুন' ড্রপডাউন থেকে আপনার তৈরি করা প্রজেক্টের তালিকা থেকে নির্দিষ্ট গুগল ক্লাউড প্রজেক্টটি নির্বাচন করুন। 
👉 আপনার গুগল ক্লাউড প্রজেক্ট আইডি খুঁজুন :
- গুগল ক্লাউড কনসোল খুলুন: https://console.cloud.google.com
- পৃষ্ঠার শীর্ষে থাকা প্রজেক্ট ড্রপডাউন থেকে এই কর্মশালার জন্য আপনি যে প্রজেক্টটি ব্যবহার করতে চান, সেটি নির্বাচন করুন।
- আপনার প্রজেক্ট আইডি ড্যাশবোর্ডের প্রজেক্ট ইনফো কার্ডে প্রদর্শিত হয়।

👉ক্লাউড IDE-তে টার্মিনালটি খুলুন, 
👉💻 টার্মিনালে, নিম্নলিখিত কমান্ডটি ব্যবহার করে যাচাই করুন যে আপনি ইতিমধ্যেই প্রমাণীকৃত এবং প্রজেক্টটি আপনার প্রজেক্ট আইডিতে সেট করা আছে:
gcloud auth list
👉💻 GitHub থেকে instavibe-bootstrap প্রজেক্টটি ক্লোন করুন:
git clone -b adk-1.2.1-a2a-0.2.7 https://github.com/weimeilin79/instavibe-bootstrap.git
chmod +x ~/instavibe-bootstrap/init.sh
chmod +x ~/instavibe-bootstrap/set_env.sh
প্রকল্পের কাঠামো বোঝা
নির্মাণ শুরু করার আগে, আপনি এইমাত্র যে instavibe-bootstrap প্রজেক্টটি ক্লোন করেছেন তার বিন্যাসটি বুঝে নিতে একটু সময় নিন। এটি আপনাকে ওয়ার্কশপ জুড়ে ফাইলগুলো কোথায় খুঁজে পাবেন এবং সম্পাদনা করবেন তা জানতে সাহায্য করবে।
instavibe-bootstrap/
├── agents/
│ ├── orchestrate/
│ ├── planner/
│ ├── platform_mcp_client/
│ └── social/
├── instavibe/
│ ├── static/
│ └── templates/
├── tools/
│ └── instavibe/
├── utils/
├── init.sh
└── set_env.sh
এখানে প্রধান ডিরেক্টরিগুলোর বিবরণ দেওয়া হলো:
-
agents/: এটি আমাদের এআই সিস্টেমের কেন্দ্রবিন্দু। প্রতিটি সাবডিরেক্টরিতে (planner/, social/, ইত্যাদি) একটি নির্দিষ্ট ইন্টেলিজেন্ট এজেন্টের সোর্স কোড থাকে।-
agent.py: প্রতিটি এজেন্টের ফোল্ডারের ভেতরে থাকা এটিই মূল ফাইল, যেখানে এজেন্টের কার্যপ্রণালীর লজিক বা কার্যপ্রণালীর যুক্তিগুলো থাকে। -
a2a_server.py: এই ফাইলটি ADK এজেন্টকে একটি এজেন্ট-টু-এজেন্ট (A2A) সার্ভার দিয়ে আবৃত করে। -
Dockerfile: ক্লাউড রান বা এজেন্ট ইঞ্জিনে এজেন্ট ডেপ্লয় করার জন্য কন্টেইনার ইমেজ কীভাবে তৈরি করতে হবে, তা এটি নির্ধারণ করে।
-
-
instavibe/: এই ডিরেক্টরিতে InstaVibe ওয়েব অ্যাপ্লিকেশনটির সম্পূর্ণ সোর্স কোড রয়েছে। -
tools/: এই ডিরেক্টরিটি আমাদের এজেন্টদের ব্যবহারযোগ্য বাহ্যিক টুল তৈরির জন্য ব্যবহৃত হয়।-
instavibe/ফোল্ডারে মডেল কনটেক্সট প্রোটোকল (MCP) সার্ভারটি থাকে।
-
এই মডিউলার কাঠামোটি ওয়েব অ্যাপ্লিকেশনকে বিভিন্ন এআই উপাদান থেকে পৃথক করে, যার ফলে পুরো সিস্টেমটি পরিচালনা, পরীক্ষা এবং স্থাপন করা সহজ হয়।
👉💻 প্রারম্ভিক স্ক্রিপ্টটি চালান:
এই স্ক্রিপ্টটি আপনাকে আপনার গুগল ক্লাউড প্রজেক্ট আইডি প্রবেশ করাতে বলবে।
init.sh স্ক্রিপ্ট দ্বারা অনুরোধ করা হলে, গত ধাপে পাওয়া Google Cloud প্রজেক্ট আইডিটি প্রবেশ করান:
cd ~/instavibe-bootstrap
./init.sh
👉💻 প্রয়োজনীয় প্রজেক্ট আইডি সেট করুন:
gcloud config set project $(cat ~/project_id.txt) --quiet
👉💻 প্রয়োজনীয় গুগল ক্লাউড এপিআইগুলো সক্রিয় করতে নিচের কমান্ডটি চালান:
gcloud services enable run.googleapis.com \
cloudfunctions.googleapis.com \
cloudbuild.googleapis.com \
artifactregistry.googleapis.com \
spanner.googleapis.com \
apikeys.googleapis.com \
iam.googleapis.com \
compute.googleapis.com \
aiplatform.googleapis.com \
cloudresourcemanager.googleapis.com \
maps-backend.googleapis.com
👉💻 প্রয়োজনীয় সমস্ত এনভায়রনমেন্ট ভেরিয়েবল সেট করুন:
export PROJECT_ID=$(gcloud config get project)
export PROJECT_NUMBER=$(gcloud projects describe ${PROJECT_ID} --format="value(projectNumber)")
export SERVICE_ACCOUNT_NAME=$(gcloud compute project-info describe --format="value(defaultServiceAccount)")
export SPANNER_INSTANCE_ID="instavibe-graph-instance"
export SPANNER_DATABASE_ID="graphdb"
export GOOGLE_CLOUD_PROJECT=$(gcloud config get project)
export GOOGLE_GENAI_USE_VERTEXAI=TRUE
export GOOGLE_CLOUD_LOCATION="us-central1"
অনুমতি সেট আপ করা
👉💻 অনুমতি দিন। টার্মিনালে এটি চালান:
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/spanner.admin"
# Spanner Database User
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/spanner.databaseUser"
# Artifact Registry Admin
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/artifactregistry.admin"
# Cloud Build Editor
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/cloudbuild.builds.editor"
# Cloud Run Admin
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/run.admin"
# IAM Service Account User
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/iam.serviceAccountUser"
# Vertex AI User
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/aiplatform.user"
# Logging Writer (to allow writing logs)
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/logging.logWriter"
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/logging.viewer"
👉 আপনার IAM কনসোলে ফলাফল যাচাই করুন 
👉💻 একটি আর্টিফ্যাক্ট রেজিস্ট্রি রিপোজিটরি তৈরি করতে টার্মিনালে নিম্নলিখিত কমান্ডগুলো চালান। ক্লাউড রান বা এজেন্ট ইঞ্জিনে ডেপ্লয়মেন্টের আগে আমাদের এজেন্ট, এমসিপি সার্ভার এবং ইন্সটাভাইব অ্যাপ্লিকেশনের সমস্ত ডকার ইমেজ এখানে সংরক্ষণ করা হয়।
export REPO_NAME="introveally-repo"
gcloud artifacts repositories create $REPO_NAME \
--repository-format=docker \
--location=us-central1 \
--description="Docker repository for InstaVibe workshop"
এপিআই কী-এর জন্য ম্যাপ প্ল্যাটফর্ম সেটআপ করুন
আপনার InstaVibe অ্যাপ্লিকেশনে Google Maps পরিষেবা ব্যবহার করতে, আপনাকে একটি API কী তৈরি করতে হবে এবং এটিকে যথাযথভাবে সীমাবদ্ধ করতে হবে।
👉 একটি নতুন ট্যাবে, APIs & Services > Credentials- এ যান। "Credentials" পৃষ্ঠার উপরে থাকা + CREATE CREDENTIALS বোতামে ক্লিক করুন। ড্রপডাউন মেনু থেকে API key নির্বাচন করুন। 
👉 একটি ডায়ালগ বক্স আসবে যেখানে আপনার নতুন তৈরি করা API কী-টি দেখানো হবে। পরবর্তীতে আপনার অ্যাপ্লিকেশন কনফিগারেশনের জন্য এটি প্রয়োজন হবে।
👉 "API key created" ডায়ালগ বক্সে CLOSE ক্লিক করুন।
👉 আপনি আপনার নতুন API কী তালিকাভুক্ত দেখতে পাবেন (যেমন, "API key 1")। ডানদিকে থাকা তিনটি ডটে ক্লিক করে "Edit API key" নির্বাচন করুন, এতে "Restrict and rename API key" পৃষ্ঠাটি খুলবে। 
👉 উপরের Name ফিল্ডে, ডিফল্ট নামটি পরিবর্তন করে লিখুন: Maps Platform API Key (🚨🚨গুরুত্বপূর্ণ🚨🚨 অনুগ্রহ করে এই নামটিই ব্যবহার করুন!)
Maps Platform API Key
👉 "অ্যাপ্লিকেশন সীমাবদ্ধতা" বিভাগে "None" নির্বাচন করা আছে কিনা তা নিশ্চিত করুন।
👉 'API restrictions' সেকশনের অধীনে, Restrict key রেডিও বাটনটি সিলেক্ট করুন।
👉 Select APIs ড্রপডাউন মেনুতে ক্লিক করুন। যে সার্চ বক্সটি আসবে, সেখানে Maps JavaScript API টাইপ করুন এবং তালিকা থেকে এটি নির্বাচন করুন। 
👉 OK ক্লিক করুন।
👉 পেজের নিচে থাকা সেভ (SAVE) বাটনটিতে ক্লিক করুন।

আপনি এখন সফলভাবে 'Maps Platform API Key' নামে একটি এপিআই কী তৈরি করেছেন, এটিকে শুধুমাত্র 'Maps JavaScript API' ব্যবহারের জন্য সীমাবদ্ধ করেছেন এবং আপনার প্রোজেক্টের জন্য এপিআইটি সক্রিয় করা নিশ্চিত করেছেন।
৪. গ্রাফ ডাটাবেস সেটআপ করুন
আমাদের ইন্টেলিজেন্ট এজেন্ট তৈরি করার আগে, আমাদের ইন্সটাভাইব সোশ্যাল নেটওয়ার্কের ভেতরের গভীর সংযোগগুলো সংরক্ষণ ও বোঝার জন্য একটি উপায় প্রয়োজন। এখানেই গ্রাফ ডেটাবেসের ভূমিকা আসে। প্রচলিত রিলেশনাল ডেটাবেসের মতো নয়, যা সারি ও কলামের টেবিলে ডেটা সংরক্ষণ করে, একটি গ্রাফ ডেটাবেস বিশেষভাবে ডিজাইন করা হয়েছে নোড (যেমন ব্যক্তি, ইভেন্ট বা পোস্ট) এবং তাদের সংযোগকারী সম্পর্ক (এজ) (যেমন বন্ধুত্ব, ইভেন্টে উপস্থিতি বা মেনশন)-এর ভিত্তিতে ডেটা উপস্থাপন ও কোয়েরি করার জন্য। এই কাঠামোটি সোশ্যাল মিডিয়া অ্যাপ্লিকেশনের জন্য অত্যন্ত শক্তিশালী, কারণ এটি বাস্তব জগতের সোশ্যাল নেটওয়ার্কের গঠনকে প্রতিফলিত করে, যা বিভিন্ন সত্তা কীভাবে একে অপরের সাথে সংযুক্ত তা অন্বেষণ করাকে সহজবোধ্য করে তোলে।
আমরা গুগল ক্লাউড স্প্যানার ব্যবহার করে এই গ্রাফ ডেটাবেসটি তৈরি করছি। যদিও স্প্যানার প্রধানত একটি বিশ্বব্যাপী বিতরণযোগ্য, দৃঢ়ভাবে সামঞ্জস্যপূর্ণ রিলেশনাল ডেটাবেস হিসেবে পরিচিত, এটি আমাদের রিলেশনাল টেবিলের উপরে সরাসরি গ্রাফ কাঠামো সংজ্ঞায়িত করতে এবং কোয়েরি করার সুযোগও দেয়।
এর ফলে আমরা স্প্যানারের স্কেলেবিলিটি, ট্রানজ্যাকশনাল কনসিসটেন্সি এবং পরিচিত SQL ইন্টারফেসের সম্মিলিত সুবিধা পাই; সেই সাথে আমাদের এআই-চালিত ফিচারগুলোর জন্য অপরিহার্য জটিল সামাজিক গতিপ্রকৃতি বিশ্লেষণের উদ্দেশ্যে গ্রাফ কোয়েরির প্রকাশক্ষমতাও লাভ করি।
👉💻 ক্লাউড শেল IDE টার্মিনালে, গুগল ক্লাউডে প্রয়োজনীয় পরিকাঠামো প্রস্তুত করুন। আমরা একটি স্প্যানার ইনস্ট্যান্স তৈরি করার মাধ্যমে শুরু করব, যা আমাদের ডেটাবেসগুলোর জন্য একটি ডেডিকেটেড কন্টেইনার হিসেবে কাজ করবে। ইনস্ট্যান্সটি প্রস্তুত হয়ে গেলে, আমরা এর ভেতরে আসল স্প্যানার ডেটাবেসটি তৈরি করব, যেখানে আমাদের সমস্ত টেবিল এবং InstaVibe-এর গ্রাফ ডেটা থাকবেঃ
. ~/instavibe-bootstrap/set_env.sh
gcloud spanner instances create $SPANNER_INSTANCE_ID \
--config=regional-us-central1 \
--description="GraphDB Instance InstaVibe" \
--processing-units=100 \
--edition=ENTERPRISE
gcloud spanner databases create $SPANNER_DATABASE_ID \
--instance=$SPANNER_INSTANCE_ID \
--database-dialect=GOOGLE_STANDARD_SQL
👉💻 স্প্যানারকে ডিফল্ট সার্ভিস অ্যাকাউন্টে রিড/রাইট অ্যাক্সেস দিন
echo "Granting Spanner read/write access to ${SERVICE_ACCOUNT_NAME} for database ${SPANNER_DATABASE_ID}..."
gcloud spanner databases add-iam-policy-binding ${SPANNER_DATABASE_ID} \
--instance=${SPANNER_INSTANCE_ID} \
--member="serviceAccount:${SERVICE_ACCOUNT_NAME}" \
--role="roles/spanner.databaseUser" \
--project=${PROJECT_ID}
👉💻 এখন, আমরা একটি পাইথন ভার্চুয়াল এনভায়রনমেন্ট তৈরি করব, প্রয়োজনীয় পাইথন প্যাকেজগুলো ইনস্টল করব, এবং তারপর স্প্যানারের (Spanner) মধ্যে গ্রাফ ডেটাবেস স্কিমা সেট আপ করে তাতে প্রাথমিক ডেটা লোড করব ও setup.py স্ক্রিপ্টটি চালাব।
. ~/instavibe-bootstrap/set_env.sh
cd ~/instavibe-bootstrap
python -m venv env
source env/bin/activate
pip install -r requirements.txt
cd instavibe
python setup.py
👉 একটি নতুন ব্রাউজার ট্যাবে, Google Cloud Console-এ যান, Spanner- এ নেভিগেট করুন, আপনি আপনার Spanner ইনস্ট্যান্সগুলির একটি তালিকা দেখতে পাবেন। instavibe-graph-instance টিতে ক্লিক করুন।
👉 ইনস্ট্যান্স ওভারভিউ পেজে, আপনি সেই ইনস্ট্যান্সের অন্তর্গত ডেটাবেসগুলির একটি তালিকা দেখতে পাবেন। graphdb তে ক্লিক করুন। 
👉 আপনার ডাটাবেসের বাম দিকের নেভিগেশন প্যানে, স্প্যানার স্টুডিও-তে ক্লিক করুন। 
👉 কোয়েরি এডিটরে (আনটাইটেলড কোয়েরি ট্যাব), নিচের গ্রাফ SQL কোয়েরিটি পেস্ট করুন। এই কোয়েরিটি সমস্ত পার্সন নোড এবং অন্যান্য পার্সন নোডের সাথে তাদের সরাসরি ফ্রেন্ডশিপ সম্পর্ক খুঁজে বের করবে। এবং ফলাফল দেখতে রান (RUN) এ ক্লিক করুন।
Graph SocialGraph
MATCH result_paths = ((p:Person)-[f:Friendship]-(friend:Person))
RETURN SAFE_TO_JSON(result_paths) AS result_paths

👉 একই কোয়েরি এডিটরে, আগের DDL-টি পরিবর্তন করে সেইসব ব্যক্তিদের খুঁজুন যারা একই ইভেন্টে অংশগ্রহণ করেছিলেন, যা একটি শেয়ার করা অ্যাক্টিভিটির মাধ্যমে পরোক্ষ সংযোগ বোঝায়।
Graph SocialGraph
MATCH result_paths = (p1:Person)-[:Attended]->(e:Event)<-[:Attended]-(p2:Person)
WHERE p1.person_id < p2.person_id
RETURN SAFE_TO_JSON(result_paths) AS result_paths

👉 এই কোয়েরিটি এক ভিন্ন ধরনের সংযোগ অন্বেষণ করে, যেখানে কোনো নির্দিষ্ট ব্যক্তির বন্ধুদের লেখা পোস্টে উল্লিখিত ব্যক্তিদের খুঁজে বের করা হয়। এর জন্য কোয়েরি এডিটরে নিম্নলিখিত কোয়েরিটি চালান।
Graph SocialGraph
MATCH result_paths = (user:Person {name: "Alice"})-[:Friendship]-(friend:Person)-[:Wrote]->(post:Post)-[:Mentioned]->(mentioned_person:Person)
WHERE user <> mentioned_person AND friend <> mentioned_person -- Avoid self-mentions or friend mentioning themselves in their own post if not intended
RETURN SAFE_TO_JSON(result_paths) AS result_paths

এই কোয়েরিগুলো আমাদের InstaVibe অ্যাপ্লিকেশনের জন্য স্প্যানারকে একটি গ্রাফ ডেটাবেস হিসেবে ব্যবহারের ক্ষমতার একটি ঝলক মাত্র। আমাদের সোশ্যাল ডেটাকে একটি আন্তঃসংযুক্ত গ্রাফ হিসেবে মডেলিং করার মাধ্যমে, আমরা সম্পর্ক ও কার্যকলাপের অত্যাধুনিক বিশ্লেষণ সক্ষম করি, যা আমাদের এআই এজেন্টদের জন্য ব্যবহারকারীর প্রেক্ষাপট বুঝতে, আগ্রহ আবিষ্কার করতে এবং পরিশেষে বুদ্ধিমান সামাজিক পরিকল্পনা সহায়তা প্রদান করতে মৌলিক ভূমিকা পালন করবে।
আমাদের ভিত্তিগত ডেটা কাঠামোটি এখন তৈরি ও পরীক্ষিত হওয়ায়, চলুন বিদ্যমান InstaVibe অ্যাপ্লিকেশনটির দিকে মনোযোগ দেওয়া যাক, যার সাথে আমাদের এজেন্টরা মিথস্ক্রিয়া করবে।
৫. ইন্সটাভাইবের বর্তমান অবস্থা
আমাদের এআই এজেন্টগুলো কোথায় খাপ খাবে তা বোঝার জন্য, প্রথমে আমাদের বিদ্যমান ইন্সটাভাইব ওয়েব অ্যাপ্লিকেশনটি ডেপ্লয় ও রান করতে হবে। এই অ্যাপ্লিকেশনটি ইউজার ইন্টারফেস এবং মৌলিক কার্যকারিতা প্রদান করে, যা আমাদের আগে থেকে সেট আপ করা স্প্যানার গ্রাফ ডেটাবেসের সাথে সংযোগ স্থাপন করে।

InstaVibe অ্যাপ্লিকেশনটি তার ইভেন্টের বিবরণ পেজে ইভেন্টের অবস্থান দৃশ্যমানভাবে দেখানোর জন্য Google Maps ব্যবহার করে। এই কার্যকারিতাটি চালু করার জন্য, অ্যাপ্লিকেশনটির আমাদের পূর্বে তৈরি করা API কী-টি প্রয়োজন। নিম্নলিখিত স্ক্রিপ্টটি আমাদের নির্ধারিত ডিসপ্লে নেম ("Maps Platform API Key") ব্যবহার করে আসল কী স্ট্রিংটি খুঁজে বের করবে।

👉💻 ক্লাউড শেল IDE- তে ফিরে যান। নিচের স্ক্রিপ্টটি চালান। এরপর, আউটপুটটি মনোযোগ সহকারে পরীক্ষা করে নিশ্চিত করুন যে প্রদর্শিত GOOGLE_MAPS_API_KEY, পূর্বে গুগল ক্লাউড কনসোল থেকে আপনার তৈরি ও কপি করা কী-টির সাথে মিলছে।
. ~/instavibe-bootstrap/set_env.sh
export KEY_DISPLAY_NAME="Maps Platform API Key"
GOOGLE_MAPS_KEY_ID=$(gcloud services api-keys list \
--project="${PROJECT_ID}" \
--filter="displayName='${KEY_DISPLAY_NAME}'" \
--format="value(uid)" \
--limit=1)
GOOGLE_MAPS_API_KEY=$(gcloud services api-keys get-key-string "${GOOGLE_MAPS_KEY_ID}" \
--project="${PROJECT_ID}" \
--format="value(keyString)")
echo "${GOOGLE_MAPS_API_KEY}" > ~/mapkey.txt
echo "Retrieved GOOGLE_MAPS_API_KEY: ${GOOGLE_MAPS_API_KEY}"

👉💻 এবার, InstaVibe ওয়েব অ্যাপ্লিকেশনটির জন্য কন্টেইনার ইমেজ তৈরি করে আমাদের আর্টিফ্যাক্ট রেজিস্ট্রি রিপোজিটরিতে পুশ করা যাক।
. ~/instavibe-bootstrap/set_env.sh
cd ~/instavibe-bootstrap/instavibe/
export IMAGE_TAG="latest"
export APP_FOLDER_NAME="instavibe"
export IMAGE_NAME="instavibe-webapp"
export IMAGE_PATH="${REGION}-docker.pkg.dev/${PROJECT_ID}/${REPO_NAME}/${IMAGE_NAME}:${IMAGE_TAG}"
export SERVICE_NAME="instavibe"
gcloud builds submit . \
--tag=${IMAGE_PATH} \
--project=${PROJECT_ID}
👉💻 নতুন বিল্ড করা InstaVibe ওয়েবঅ্যাপ ইমেজটি Cloud Run-এ ডেপ্লয় করুন।
. ~/instavibe-bootstrap/set_env.sh
cd ~/instavibe-bootstrap/instavibe/
export IMAGE_TAG="latest"
export APP_FOLDER_NAME="instavibe"
export IMAGE_NAME="instavibe-webapp"
export IMAGE_PATH="${REGION}-docker.pkg.dev/${PROJECT_ID}/${REPO_NAME}/${IMAGE_NAME}:${IMAGE_TAG}"
export SERVICE_NAME="instavibe"
gcloud run deploy ${SERVICE_NAME} \
--image=${IMAGE_PATH} \
--platform=managed \
--region=${REGION} \
--allow-unauthenticated \
--set-env-vars="SPANNER_INSTANCE_ID=${SPANNER_INSTANCE_ID}" \
--set-env-vars="SPANNER_DATABASE_ID=${SPANNER_DATABASE_ID}" \
--set-env-vars="APP_HOST=0.0.0.0" \
--set-env-vars="APP_PORT=8080" \
--set-env-vars="GOOGLE_CLOUD_LOCATION=${REGION}" \
--set-env-vars="GOOGLE_CLOUD_PROJECT=${PROJECT_ID}" \
--set-env-vars="GOOGLE_MAPS_API_KEY=${GOOGLE_MAPS_API_KEY}" \
--project=${PROJECT_ID} \
--min-instances=1
ডেপ্লয়মেন্ট সফলভাবে সম্পন্ন হলে, ক্লাউড রান লগ-এ আপনার চলমান InstaVibe অ্যাপ্লিকেশনটির পাবলিক URL প্রদর্শিত হবে।

এছাড়াও আপনি গুগল ক্লাউড কনসোলের ক্লাউড রান বিভাগে গিয়ে ইনস্টাভাইব পরিষেবাটি নির্বাচন করে এই ইউআরএলটি খুঁজে পেতে পারেন। 

ইনস্টাভাইব প্ল্যাটফর্মের প্রাথমিক রূপটি ঘুরে দেখতে এখনই আপনার ওয়েব ব্রাউজারে ওই ইউআরএলটি খুলুন। আমাদের তৈরি করা গ্রাফ ডেটাবেস দ্বারা চালিত পোস্ট, ইভেন্ট এবং ব্যবহারকারীদের সংযোগগুলো দেখুন।
এখন যেহেতু আমাদের কাঙ্ক্ষিত অ্যাপ্লিকেশনটি চালু আছে, চলুন এর সক্ষমতা বাড়ানোর জন্য প্রথম ইন্টেলিজেন্ট এজেন্টটি তৈরি করা শুরু করি।
৬. বেসিক এজেন্ট, এডিকে সহ ইভেন্ট প্ল্যানার
ADK ফ্রেমওয়ার্ক
গুগলের ADK ফ্রেমওয়ার্কের পরিচিতি। এখন যেহেতু আমাদের ভিত্তি (InstaVibe অ্যাপ এবং ডেটাবেস) তৈরি হয়ে গেছে, আমরা গুগলের এজেন্ট ডেভেলপমেন্ট কিট (ADK) ব্যবহার করে আমাদের প্রথম ইন্টেলিজেন্ট এজেন্ট তৈরি করা শুরু করতে পারি।
এজেন্ট ডেভেলপমেন্ট কিট (ADK) হলো একটি নমনীয় এবং মডিউলার ফ্রেমওয়ার্ক, যা বিশেষভাবে এআই এজেন্ট তৈরি এবং স্থাপনের জন্য ডিজাইন করা হয়েছে। এর নকশার মূলনীতি হলো এজেন্ট ডেভেলপমেন্টকে প্রচলিত সফটওয়্যার ডেভেলপমেন্টের মতো করে তোলা, যার লক্ষ্য হলো ডেভেলপারদের জন্য এমন এজেন্টিক আর্কিটেকচার তৈরি, স্থাপন এবং পরিচালনা করা উল্লেখযোগ্যভাবে সহজ করে দেওয়া, যা সাধারণ, একক-উদ্দেশ্যমূলক কাজ থেকে শুরু করে জটিল, একাধিক এজেন্টের কর্মপ্রবাহ পর্যন্ত সবকিছু সামলাতে পারে।
মূলতঃ ADK-এর কেন্দ্রবিন্দুতে রয়েছে Agent নামক একটি ধারণা, যার মধ্যে অন্তর্ভুক্ত থাকে নির্দেশাবলী, কনফিগারেশন (যেমন নির্বাচিত ল্যাঙ্গুয়েজ মডেল, উদাহরণস্বরূপ, জেমিনি), এবং এক সেট Tools যা ব্যবহার করে এটি বিভিন্ন কাজ সম্পাদন করতে বা তথ্য সংগ্রহ করতে পারে।

আমাদের প্রাথমিক এজেন্টটি হবে একটি "ইভেন্ট প্ল্যানার"। এর মূল উদ্দেশ্য হলো ব্যবহারকারীর সামাজিক অনুষ্ঠানের অনুরোধ (স্থান, তারিখ এবং আগ্রহ উল্লেখ করে) গ্রহণ করা এবং সৃজনশীল ও বিশেষভাবে তৈরি পরামর্শ দেওয়া। পরামর্শগুলো যেন প্রাসঙ্গিক হয় এবং সাম্প্রতিক তথ্যের (যেমন সেই সপ্তাহান্তে অনুষ্ঠিত হতে চলা নির্দিষ্ট অনুষ্ঠান) উপর ভিত্তি করে তৈরি হয়, তা নিশ্চিত করতে আমরা ADK-এর একটি বিল্ট-ইন টুল, গুগল সার্চ , ব্যবহার করব। এটি এজেন্টকে রিয়েল-টাইম ওয়েব ফলাফলের উপর ভিত্তি করে তার প্রতিক্রিয়া জানাতে সাহায্য করে, যা ব্যবহারকারীর শর্ত পূরণকারী স্থান, অনুষ্ঠান এবং কার্যকলাপ সম্পর্কে সর্বশেষ তথ্য সংগ্রহ করে।
👉📝 ক্লাউড শেল IDE- তে ফিরে এসে, ~/instavibe-bootstrap/agents/planner/agent.py ফাইলে এজেন্ট তৈরি করার জন্য নিম্নলিখিত প্রম্পট এবং নির্দেশনা যোগ করুন।
from google.adk.agents import Agent
from google.adk.tools import google_search
root_agent = Agent(
name="planner_agent",
model="gemini-2.0-flash",
description="Agent tasked with generating creative and fun dating plan suggestions",
instruction="""
You are a specialized AI assistant tasked with generating creative and fun plan suggestions.
Request:
For the upcoming weekend, specifically from **[START_DATE_YYYY-MM-DD]** to **[END_DATE_YYYY-MM-DD]**, in the location specified as **[TARGET_LOCATION_NAME_OR_CITY_STATE]** (if latitude/longitude are provided, use these: Lat: **[TARGET_LATITUDE]**, Lon: **[TARGET_LONGITUDE]**), please generate a distinct dating plan suggestions.
Constraints and Guidelines for Suggestions:
1. Creativity & Fun: Plans should be engaging, memorable, and offer a good experience for a date.
2. Budget: All generated plans should aim for a moderate budget (conceptually "$$"), meaning they should be affordable yet offer good value, without being overly cheap or extravagant. This budget level should be *reflected in the choice of activities and venues*, but **do not** explicitly state "Budget: $$" in the `plan_description`.
3. Interest Alignment:
Consider the following user interests: **[COMMA_SEPARATED_LIST_OF_INTERESTS, e.g., outdoors, arts & culture, foodie, nightlife, unique local events, live music, active/sports]**. Tailor suggestions specifically to these where possible. The plan should *embody* these interests.
Fallback: If specific events or venues perfectly matching all listed user interests cannot be found for the specified weekend, you should create a creative and fun generic dating plan that is still appealing, suitable for the location, and adheres to the moderate budget. This plan should still sound exciting and fun, even if it's more general.
4. Current & Specific: Prioritize finding specific, current events, festivals, pop-ups, or unique local venues operating or happening during the specified weekend dates. If exact current events cannot be found, suggest appealing evergreen options or implement the fallback generic plan.
5. Location Details: For each place or event mentioned within a plan, you MUST provide its name, precise latitude, precise longitude, and a brief, helpful description.
6. Maximum Activities: The plan must contain a maximum of 3 distinct activities.
RETURN PLAN in MARKDOWN FORMAT
""",
tools=[google_search]
)
আর এভাবেই আমাদের প্রথম এজেন্টটি সংজ্ঞায়িত হয়ে গেল! ADK-এর অন্যতম সেরা একটি দিক হলো এর সহজবোধ্য ব্যবহার এবং এর দেওয়া দরকারি টুলগুলো। এর মধ্যে বিশেষভাবে দরকারি একটি হলো ADK Dev UI , যা আপনাকে ইন্টারেক্টিভভাবে আপনার এজেন্ট পরীক্ষা করতে এবং রিয়েল-টাইমে এর প্রতিক্রিয়া দেখতে দেয়।
👉💻 চলুন শুরু করা যাক। নিচের কমান্ডগুলো ADK DEV UI চালু করবে:
. ~/instavibe-bootstrap/set_env.sh
source ~/instavibe-bootstrap/env/bin/activate
cd ~/instavibe-bootstrap/agents
sed -i "s|^\(O\?GOOGLE_CLOUD_PROJECT\)=.*|GOOGLE_CLOUD_PROJECT=${PROJECT_ID}|" ~/instavibe-bootstrap/agents/planner/.env
adk web
কমান্ডগুলো চালানোর পর, আপনার টার্মিনালে এই ধরনের একটি আউটপুট দেখতে পাবেন যা নির্দেশ করবে যে ADK ওয়েব সার্ভারটি চালু হয়েছে:
+-----------------------------------------------------------------------------+
| ADK Web Server started |
| |
| For local testing, access at http://localhost:8000. |
+-----------------------------------------------------------------------------+
INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
👉 এরপর, আপনার ব্রাউজার থেকে ADK Dev UI অ্যাক্সেস করতে:
ক্লাউড শেল টুলবারে (সাধারণত উপরের ডানদিকে) থাকা ওয়েব প্রিভিউ আইকন (যা প্রায়শই একটি চোখ বা তীর চিহ্নসহ একটি বর্গক্ষেত্রের মতো দেখতে হয়) থেকে ‘Change port’ নির্বাচন করুন। পপ-আপ উইন্ডোতে, পোর্টটি 8000- এ সেট করুন এবং ‘Change and Preview’-এ ক্লিক করুন। এরপর ক্লাউড শেল একটি নতুন ব্রাউজার ট্যাব বা উইন্ডো খুলবে, যেখানে ADK Dev UI প্রদর্শিত হবে।

আপনার ব্রাউজারে ADK Dev UI খুলে গেলে: UI-এর উপরের ডানদিকের ড্রপডাউন মেনু থেকে, আপনি যে এজেন্টের সাথে কথা বলতে চান, তাকে প্ল্যানার হিসেবে নির্বাচন করুন। এবার, ডানদিকের চ্যাট ডায়ালগে, আপনার এজেন্টকে একটি কাজ দেওয়ার চেষ্টা করুন। উদাহরণস্বরূপ, এজেন্টের সাথে একটি কথোপকথন করুন:
Search and plan something in Seattle for me this weekend
This weekend and I enjoy food and anime
একটি তারিখ প্রস্তাব করুন (আপনার পছন্দ অনুযায়ী)
July 12 2025
এজেন্ট আপনার অনুরোধটি প্রক্রিয়া করবে এবং এর গুগল সার্চ ফলাফলের উপর ভিত্তি করে একটি পরিকল্পনা প্রদান করবে, তা আপনি দেখতে পাবেন।

এখন, কোনো এজেন্টের সাথে যোগাযোগ করা এক জিনিস, কিন্তু আমরা কীভাবে জানব যে এটি ধারাবাহিকভাবে প্রত্যাশা অনুযায়ী আচরণ করছে কিনা, বিশেষ করে যখন আমরা পরিবর্তন আনি?
এআই এজেন্টদের জেনারেটিভ এবং নন-ডিটারমিনিস্টিক প্রকৃতির কারণে, প্রচলিত সফটওয়্যার টেস্টিং পদ্ধতিগুলো প্রায়শই তাদের ক্ষেত্রে ব্যর্থ হয়। একটি আকর্ষণীয় ডেমো থেকে একটি নির্ভরযোগ্য প্রোডাকশন এজেন্টে পরিণত হওয়ার জন্য, একটি শক্তিশালী মূল্যায়ন কৌশল অত্যন্ত গুরুত্বপূর্ণ। শুধুমাত্র একটি জেনারেটিভ মডেলের চূড়ান্ত আউটপুট পরীক্ষা করার বিপরীতে, একটি এজেন্টের মূল্যায়নের ক্ষেত্রে প্রায়শই বিভিন্ন পরিস্থিতিতে তার সিদ্ধান্ত গ্রহণ প্রক্রিয়া এবং টুলস সঠিকভাবে ব্যবহার করার বা নির্দেশাবলী অনুসরণ করার ক্ষমতা যাচাই করা হয়। ADK এই কাজে সাহায্য করার জন্য বিভিন্ন ফিচার প্রদান করে।

👉 ADK Dev UI-তে, বাম দিকের নেভিগেশনে থাকা "Eval" ট্যাবে ক্লিক করুন। আপনি plan_eval নামের একটি আগে থেকে লোড করা টেস্ট ফাইল দেখতে পাবেন। এই ফাইলটিতে আমাদের প্ল্যানার এজেন্ট পরীক্ষা করার জন্য পূর্বনির্ধারিত ইনপুট এবং ক্রাইটেরিয়া রয়েছে।
👉 "বোস্টন"-এর মতো একটি সিনারিও বেছে নিন এবং রান ইভ্যালুয়েশন বোতামে ক্লিক করুন। যে পপ-আপ উইন্ডোটি আসবে, সেখানে ম্যাচ স্কোর কমিয়ে 0.3 করুন এবং স্টার্ট-এ ক্লিক করুন।

এটি টেস্ট ইনপুট দিয়ে এজেন্টটিকে চালাবে এবং এর আউটপুট নির্ধারিত প্রত্যাশা পূরণ করে কিনা তা যাচাই করবে। এর মাধ্যমে আপনি আপনার এজেন্টের পারফরম্যান্স পদ্ধতিগতভাবে পরীক্ষা করতে পারবেন।

👉 এবার, আরও কঠোর থ্রেশহোল্ড দিলে কী হয় তা দেখা যাক। "nyc" সিনারিওটি সিলেক্ট করুন এবং আবার রান ইভ্যালুয়েশন-এ ক্লিক করুন। এবার, ম্যাচ স্কোরটি তার ডিফল্ট ভ্যালুতে (রেসপন্স ম্যাচ স্কোর: ০.৭) রেখে স্টার্ট-এ ক্লিক করুন। আপনি লক্ষ্য করবেন যে ফলাফলটি ফেইল এসেছে। এটাই প্রত্যাশিত, কারণ এজেন্টের ক্রিয়েটিভ আউটপুটটি আগে থেকে নির্ধারিত "গোল্ডেন" উত্তরের সাথে পুরোপুরি মেলে না।

👉 এটি কেন ব্যর্থ হয়েছে তা বুঝতে, "nyc" সারিতে থাকা ফেইল আইকনটিতে ক্লিক করুন। UI এখন এজেন্ট থেকে পাওয়া প্রকৃত প্রতিক্রিয়া এবং টেস্ট কেস থেকে পাওয়া প্রত্যাশিত প্রতিক্রিয়ার একটি পাশাপাশি তুলনা প্রদর্শন করবে। ডিবাগিংয়ের জন্য এই ভিউটি অপরিহার্য, যা আপনাকে এজেন্টের আউটপুট ঠিক কোথায় ভিন্ন হয়েছে তা দেখতে এবং সেই অনুযায়ী এর নির্দেশনা পরিমার্জন করতে সাহায্য করে।
UI অন্বেষণ এবং মূল্যায়ন শেষ হয়ে গেলে, আপনার ক্লাউড শেল এডিটর টার্মিনালে ফিরে যান এবং ADK Dev UI বন্ধ করতে Ctrl+C চাপুন।
যদিও মুক্ত-ফর্মের টেক্সট আউটপুট একটি ভালো সূচনা, InstaVibe-এর মতো অ্যাপ্লিকেশনগুলির জন্য এজেন্টের পরামর্শগুলি সহজে ব্যবহার করতে কাঠামোগত ডেটা (যেমন JSON) অনেক বেশি বাস্তবসম্মত। চলুন আমাদের এজেন্টকে এমনভাবে পরিবর্তন করি যাতে এটি তার পরিকল্পনা একটি সামঞ্জস্যপূর্ণ JSON ফরম্যাটে ফেরত দেয়।
👉📝 ~/instavibe-bootstrap/agents/planner/agent.py ফাইলে, এজেন্টের নির্দেশনা স্ট্রিং-এর মধ্যে RETURN PLAN in MARKDOWN FORMAT লেখা আছে। সেই লাইনটি নিচের বিস্তারিত JSON কাঠামো দিয়ে প্রতিস্থাপন করুন:
Return your response *exclusively* as a single JSON object. This object should contain a top-level key, "fun_plans", which holds a plan objects. Each plan object in the list must strictly adhere to the following structure:
--json--
{
"plan_description": "A summary of the overall plan, consisting of **exactly three sentences**. Craft these sentences in a friendly, enthusiastic, and conversational tone, as if you're suggesting this awesome idea to a close friend. Make it sound exciting and personal, highlighting the positive aspects and appeal of the plan without explicitly mentioning budget or listing interest categories.",
"locations_and_activities": [
{
"name": "Name of the specific place or event",
"latitude": 0.000000, // Replace with actual latitude
"longitude": 0.000000, // Replace with actual longitude
"description": "A brief description of this place/event, why it's suitable for the date, and any specific details for the weekend (e.g., opening hours, event time)."
}
// Add more location/activity objects here if the plan involves multiple stops/parts
]
}
এখন যেহেতু আপনি এজেন্টের নির্দেশাবলী আপডেট করে বিশেষভাবে JSON আউটপুটের অনুরোধ করেছেন, চলুন পরিবর্তনটি যাচাই করে দেখি।
👉💻 আগের কমান্ডটি ব্যবহার করে ADK Dev UI পুনরায় চালু করুন :
. ~/instavibe-bootstrap/set_env.sh
source ~/instavibe-bootstrap/env/bin/activate
cd ~/instavibe-bootstrap/agents
adk web
ট্যাবটি আগে থেকেই খোলা থাকলে রিফ্রেশ করুন । অথবা, আপনার ব্রাউজারে ADK Dev UI খোলার জন্য আগের ধাপগুলোই অনুসরণ করুন (ক্লাউড শেলের ওয়েব প্রিভিউয়ের মাধ্যমে পোর্ট ৮০০০-এ)। UI লোড হয়ে গেলে, প্ল্যানার এজেন্টটি নির্বাচিত আছে কিনা তা নিশ্চিত করুন।
👉 এবার, চলুন একটি ভিন্ন অনুরোধ করি। চ্যাট ডায়ালগে লিখুন:
Plan an event Boston this weekend with art and coffee
এজেন্টের প্রতিক্রিয়াটি সাবধানে পরীক্ষা করুন। শুধুমাত্র কথোপকথনমূলক টেক্সট উত্তরের পরিবর্তে, আপনি এখন একটি প্রতিক্রিয়া দেখতে পাবেন যা কঠোরভাবে একটি JSON অবজেক্ট হিসাবে ফরম্যাট করা হয়েছে এবং যা আমাদের নির্দেশাবলীতে সংজ্ঞায়িত কাঠামোর সাথে মেলে (যার মধ্যে fun_plans, plan_description, locations_and_activities, ইত্যাদি রয়েছে)। এটি নিশ্চিত করে যে এজেন্ট এখন আমাদের InstaVibe অ্যাপ্লিকেশনের প্রোগ্রাম্যাটিক ব্যবহারের জন্য উপযুক্ত কাঠামোগত আউটপুট তৈরি করতে সক্ষম।

JSON আউটপুট নিশ্চিত করার পর, আপনার ক্লাউড শেল টার্মিনালে ফিরে যান এবং ADK Dev UI বন্ধ করতে Ctrl+C চাপুন।
ADK উপাদানসমূহ
ইন্টারেক্টিভ টেস্টিংয়ের জন্য ADK Dev UI চমৎকার হলেও, আমাদের প্রায়শই এজেন্টগুলোকে প্রোগ্রাম্যাটিকভাবে চালানোর প্রয়োজন হয়, যা হয়তো কোনো বৃহত্তর অ্যাপ্লিকেশন বা ব্যাকএন্ড সার্ভিসের অংশ হিসেবে করা হয়ে থাকে। এটি কীভাবে কাজ করে তা বোঝার জন্য, চলুন রানটাইম এবং কনটেক্সট ম্যানেজমেন্ট সম্পর্কিত ADK-এর কিছু মূল ধারণা দেখে নেওয়া যাক।
অর্থপূর্ণ, একাধিক পালাবিশিষ্ট কথোপকথনের জন্য এজেন্টদের প্রেক্ষাপট বোঝা প্রয়োজন – ধারাবাহিকতা বজায় রাখতে কী বলা হয়েছে এবং কী করা হয়েছে তা মনে রাখা। ADK, সেশন , স্টেট এবং মেমোরির মাধ্যমে এই প্রেক্ষাপট পরিচালনা করার জন্য সুসংগঠিত উপায় প্রদান করে।
- সেশন: যখন কোনো ব্যবহারকারী কোনো এজেন্টের সাথে আলাপচারিতা শুরু করেন, তখন একটি সেশন তৈরি হয়। এটিকে একটি নির্দিষ্ট চ্যাট থ্রেডের ধারক হিসেবে ভাবা যেতে পারে। এতে একটি অনন্য আইডি, আলাপচারিতার ইতিহাস (ইভেন্ট), বর্তমান কার্যরত ডেটা (স্টেট) এবং সর্বশেষ আপডেটের সময়ের মতো মেটাডেটা সংরক্ষিত থাকে।
- অবস্থা: এটি একটি একক সেশনের মধ্যে এজেন্টের স্বল্পমেয়াদী, কার্যকরী স্মৃতি। এটি একটি পরিবর্তনযোগ্য ডিকশনারি যেখানে এজেন্ট বর্তমান কাজটি সম্পন্ন করার জন্য প্রয়োজনীয় অস্থায়ী তথ্য সংরক্ষণ করতে পারে (যেমন, এখন পর্যন্ত সংগৃহীত ব্যবহারকারীর পছন্দসমূহ, টুল কল থেকে প্রাপ্ত অন্তর্বর্তী ফলাফল)।
- মেমোরি: এটি বিভিন্ন সেশন জুড়ে এজেন্টের দীর্ঘমেয়াদী স্মৃতিশক্তি অথবা বাহ্যিক জ্ঞানভান্ডারে প্রবেশের সম্ভাবনাকে নির্দেশ করে। যেখানে সেশন এবং স্টেট তাৎক্ষণিক কথোপকথন পরিচালনা করে, সেখানে মেমোরি (যা প্রায়শই একটি মেমোরিসার্ভিস দ্বারা পরিচালিত হয়) একটি এজেন্টকে অতীতের মিথস্ক্রিয়া বা কাঠামোগত ডেটা উৎস থেকে তথ্য পুনরুদ্ধার করতে সাহায্য করে, যা তাকে একটি বৃহত্তর জ্ঞানের প্রেক্ষাপট প্রদান করে। (দ্রষ্টব্য: সরলতার জন্য আমাদের সাধারণ ক্লায়েন্ট ইন-মেমোরি সার্ভিস ব্যবহার করে, যার অর্থ হলো মেমোরি/স্টেট শুধুমাত্র স্ক্রিপ্ট চলার সময়টুকুই স্থায়ী থাকে)।
- ইভেন্ট: একটি সেশনের মধ্যেকার প্রতিটি ইন্টারঅ্যাকশন (ব্যবহারকারীর বার্তা, এজেন্টের প্রতিক্রিয়া, টুল ব্যবহারের অনুরোধ, টুলের ফলাফল, অবস্থার পরিবর্তন, ত্রুটি) একটি অপরিবর্তনীয় ইভেন্ট হিসাবে রেকর্ড করা হয়। এটি একটি কালানুক্রমিক লগ তৈরি করে, যা মূলত কথোপকথনের প্রতিলিপি এবং কার্যকলাপের ইতিহাস।
তাহলে, যখন একটি এজেন্ট চলে, তখন এগুলো কীভাবে পরিচালিত হয়? সেটাই হলো রানারের কাজ।
- রানার : রানার হলো ADK দ্বারা প্রদত্ত মূল এক্সিকিউশন ইঞ্জিন। আপনি আপনার এজেন্ট এবং এর ব্যবহৃত টুলগুলো নির্ধারণ করেন, এবং রানার একজন ব্যবহারকারীর অনুরোধ পূরণের প্রক্রিয়াটি পরিচালনা করে। এটি সেশন পরিচালনা করে, ইভেন্টের প্রবাহ সামলায়, স্টেট আপডেট করে, অন্তর্নিহিত ল্যাঙ্গুয়েজ মডেলকে আহ্বান করে, টুল কলগুলোর মধ্যে সমন্বয় সাধন করে এবং সম্ভাব্যভাবে মেমোরিসার্ভিসের সাথে যোগাযোগ করে। এটিকে এমন একজন কন্ডাক্টর হিসেবে ভাবা যেতে পারে, যিনি নিশ্চিত করেন যে সমস্ত বিভিন্ন অংশ একসাথে সঠিকভাবে কাজ করছে।
আমরা রানার ব্যবহার করে আমাদের এজেন্টকে একটি স্বতন্ত্র পাইথন অ্যাপ্লিকেশন হিসেবে চালাতে পারি, যা ডেভ ইউআই থেকে সম্পূর্ণ স্বাধীন।
চলুন, আমাদের প্ল্যানার এজেন্টকে প্রোগ্রাম্যাটিকভাবে চালু করার জন্য একটি সহজ ক্লায়েন্ট স্ক্রিপ্ট তৈরি করি।
👉📝 ~/instavibe-bootstrap/agents/planner/planner_client.py ফাইলে, বিদ্যমান ইম্পোর্টগুলোর নিচে নিম্নলিখিত পাইথন কোডটি যোগ করুন। planner_client.py ফাইলে, ইম্পোর্টগুলোর নিচে নিম্নলিখিত কোডটি যোগ করুন:
async def async_main():
session_service = InMemorySessionService()
session = await session_service.create_session(
state={}, app_name='planner_app', user_id='user_dc'
)
query = "Plan Something for me in San Francisco this weekend on wine and fashion "
print(f"User Query: '{query}'")
content = types.Content(role='user', parts=[types.Part(text=query)])
root_agent = agent.root_agent
runner = Runner(
app_name='planner_app',
agent=root_agent,
session_service=session_service,
)
print("Running agent...")
events_async = runner.run_async(
session_id=session.id, user_id=session.user_id, new_message=content
)
async for event in events_async:
print(f"Event received: {event}")
if __name__ == '__main__':
try:
asyncio.run(async_main())
except Exception as e:
print(f"An error occurred: {e}")
এই কোডটি সেশন এবং আর্টিফ্যাক্ট ব্যবস্থাপনার জন্য ইন-মেমরি সার্ভিস সেট আপ করে (এই উদাহরণের জন্য বিষয়টিকে সহজ রাখা হয়েছে), একটি সেশন তৈরি করে, একটি ইউজার কোয়েরি সংজ্ঞায়িত করে, আমাদের এজেন্টের সাথে রানারকে কনফিগার করে, এবং তারপর এজেন্টটিকে অ্যাসিঙ্ক্রোনাসভাবে চালায় ও কার্য সম্পাদনের সময় তৈরি হওয়া প্রতিটি ইভেন্ট প্রিন্ট করে।
👉💻 এখন, আপনার টার্মিনাল থেকে এই ক্লায়েন্ট স্ক্রিপ্টটি চালান:
. ~/instavibe-bootstrap/set_env.sh
source ~/instavibe-bootstrap/env/bin/activate
cd ~/instavibe-bootstrap/agents
python -m planner.planner_client
👀 আউটপুটটি লক্ষ্য করুন। শুধুমাত্র চূড়ান্ত JSON প্ল্যানের পরিবর্তে, আপনি এজেন্টের কার্যসম্পাদন প্রবাহ চলাকালীন তৈরি হওয়া প্রতিটি ইভেন্ট অবজেক্টের বিস্তারিত কাঠামো দেখতে পাবেন। এর মধ্যে রয়েছে প্রাথমিক ব্যবহারকারী বার্তা ইভেন্ট, টুল কল সম্পর্কিত সম্ভাব্য ইভেন্ট (যেমন গুগল সার্চ), এবং সবশেষে, JSON প্ল্যান সম্বলিত মডেলের প্রতিক্রিয়া ইভেন্ট। এই বিস্তারিত ইভেন্ট স্ট্রিমটি ডিবাগিং এবং ADK রানটাইমের মধ্যে ঘটে চলা ধাপে ধাপে প্রক্রিয়াকরণ বোঝার জন্য খুবই সহায়ক।
Running agent...
Event received: content=Content(parts=[Part(video_metadata=None, thought=None, code_execution_result=None, executable_code=None, file_data=None, function_call=None, function_response=None, inline_data=None, text='```json\n{\n "fun_plans": [\n {\n "plan_description": "Embark on a stylish adventure through Hayes Valley,
...(turncated)
, offering a variety of fashion styles to browse and enjoy."\n }\n ]\n }\n ]\n}\n```')], role='model') grounding_metadata=GroundingMetadata(grounding_chunks=[GroundingChunk(retrieved_context=None, web=GroundingChunkWeb(domain='islands.com', title='islands.com', uri='http
...(turncated)
QyTpPV7jS6wUt-Ix7GuP2mC9J4eY_8Km6Vv44liF9cb2VSs='))], grounding_supports=[GroundingSupport(confide
...(turncated)
>\n', sdk_blob=None), web_search_queries=['..e']) partial=None turn_complete=None error_code=None error_message=None interrupted=None custom_metadata=None invocation_id='e-04d97b8b-9021-47a5-ab41-17b5cbb4bf03' author='location_search_agent' actions=EventActions(skip_summarization=None, state_delta={}, artifact_delta={}, transfer_to_agent=None, escalate=None, requested_auth_configs={}) long_running_tool_ids=None branch=None id='CInHdkKw' timestamp=1746978846.232674
যদি স্ক্রিপ্টটি ক্রমাগত চলতে থাকে বা আটকে যায়, তাহলে আপনাকে Ctrl+C চেপে ম্যানুয়ালি এটি বন্ধ করতে হতে পারে।
৭. প্ল্যাটফর্ম ইন্টারঅ্যাকশন এজেন্ট - এমসিপি সার্ভারের সাথে যোগাযোগ করে
ADK আমাদের এজেন্টদের কাঠামো তৈরিতে সাহায্য করলেও, বাস্তব জগতের কাজ সম্পাদনের জন্য তাদের প্রায়শই বাহ্যিক সিস্টেম বা API-এর সাথে যোগাযোগ করতে হয়।
মডেল প্রসঙ্গ প্রোটোকল (MCP)
The Model Context Protocol (MCP) is an open standard designed to standardize how AI applications like agents, connect with external data sources, tools, and systems. It aims to solve the problem of needing custom integrations for every AI application and data source combination by providing a universal interface. MCP utilizes a client-server architecture where MCP clients, residing within AI applications (hosts), manage connections to MCP servers. These servers are external programs that expose specific functionalities like accessing local data, interacting with remote services via APIs, or providing predefined prompts, allowing AI models to access current information and perform tasks beyond their initial training. This structure enables AI models to discover and interact with external capabilities in a standardized way, making integrations simpler and more scalable.
Build and deploy the InstaVibe MCP server

Our agents will eventually need to interact with the InstaVibe platform itself.Specifically, to create posts and register events using the platform's existing APIs. The InstaVibe application already exposes these functionalities via standard HTTP endpoints:
Enpoint | ইউআরএল | HTTP পদ্ধতি | বর্ণনা |
পোস্ট তৈরি করুন | api/posts | পোস্ট | API endpoint to add a new post. Expects JSON body: |
ইভেন্ট তৈরি করুন | api/events | পোস্ট | API endpoint to add a new event and its attendees (simplified schema). |
To make these capabilities available to our agents via MCP, we first need to create simple Python functions that act as wrappers around these API calls. These functions will handle the HTTP request logic.
👉 First, let's implement the wrapper function for creating a post. Open the file ~/instavibe-bootstrap/tools/instavibe/instavibe.py and replace the #REPLACE ME CREATE POST comment with the following Python code:
def create_post(author_name: str, text: str, sentiment: str, base_url: str = BASE_URL):
"""
Sends a POST request to the /posts endpoint to create a new post.
Args:
author_name (str): The name of the post's author.
text (str): The content of the post.
sentiment (str): The sentiment associated with the post (e.g., 'positive', 'negative', 'neutral').
base_url (str, optional): The base URL of the API. Defaults to BASE_URL.
Returns:
dict: The JSON response from the API if the request is successful.
Returns None if an error occurs.
Raises:
requests.exceptions.RequestException: If there's an issue with the network request (e.g., connection error, timeout).
"""
url = f"{base_url}/posts"
headers = {"Content-Type": "application/json"}
payload = {
"author_name": author_name,
"text": text,
"sentiment": sentiment
}
try:
response = requests.post(url, headers=headers, json=payload)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
print(f"Successfully created post. Status Code: {response.status_code}")
return response.json()
except requests.exceptions.RequestException as e:
print(f"Error creating post: {e}")
# Optionally re-raise the exception if the caller needs to handle it
# raise e
return None
except json.JSONDecodeError:
print(f"Error decoding JSON response from {url}. Response text: {response.text}")
return None
👉📝 Next, we'll create the wrapper function for the event creation API. In the same ~/instavibe-bootstrap/tools/instavibe/instavibe.py file, replace the #REPLACE ME CREATE EVENTS comment with this code:
def create_event(event_name: str, description: str, event_date: str, locations: list, attendee_names: list[str], base_url: str = BASE_URL):
"""
Sends a POST request to the /events endpoint to create a new event registration.
Args:
event_name (str): The name of the event.
description (str): The detailed description of the event.
event_date (str): The date and time of the event (ISO 8601 format recommended, e.g., "2025-06-10T09:00:00Z").
locations (list): A list of location dictionaries. Each dictionary should contain:
'name' (str), 'description' (str, optional),
'latitude' (float), 'longitude' (float),
'address' (str, optional).
attendee_names (list[str]): A list of names of the people attending the event.
base_url (str, optional): The base URL of the API. Defaults to BASE_URL.
Returns:
dict: The JSON response from the API if the request is successful.
Returns None if an error occurs.
Raises:
requests.exceptions.RequestException: If there's an issue with the network request (e.g., connection error, timeout).
"""
url = f"{base_url}/events"
headers = {"Content-Type": "application/json"}
payload = {
"event_name": event_name,
"description": description,
"event_date": event_date,
"locations": locations,
"attendee_names": attendee_names,
}
try:
response = requests.post(url, headers=headers, json=payload)
response.raise_for_status() # Raise an exception for bad status codes (4xx or 5xx)
print(f"Successfully created event registration. Status Code: {response.status_code}")
return response.json()
except requests.exceptions.RequestException as e:
print(f"Error creating event registration: {e}")
# Optionally re-raise the exception if the caller needs to handle it
# raise e
return None
except json.JSONDecodeError:
print(f"Error decoding JSON response from {url}. Response text: {response.text}")
return None
As you can see, these functions are straightforward wrappers around the existing InstaVibe APIs. This pattern is useful, if you already have APIs for your services, you can easily expose their functionality as tools for agents by creating such wrappers.
MCP Server Implementation
Now that we have the Python functions that perform the actions (calling the InstaVibe APIs), we need to build the MCP Server component. This server will expose these functions as "tools" according to the MCP standard, allowing MCP clients (like our agents) to discover and invoke them.
An MCP Server typically implements two key functionalities:
- list_tools : responsible for allowing the client to discover the available tools on the server, providing metadata like their names, descriptions, and required parameters, often defined using JSON Schema
- call_tool : handles the execution of a specific tool requested by the client, receiving the tool's name and arguments and performing the corresponding action, such as in our case interacting with an API
MCP servers are used to provide AI models with access to real-world data and actions, enabling tasks like sending emails, creating tasks in project management systems, searching databases, or interacting with various software and web services. While initial implementations often focused on local servers communicating via standard input/output (stdio) for simplicity, particularly in development or "studio" environments, the move towards remote servers utilizing protocols like HTTP with Server-Sent Events (SSE) makes more sense for broader adoption and enterprise use cases.
The remote architecture, despite the added network communication layer, offers significant advantages: it allows multiple AI clients to share access to a single server, centralizes management and updates of tools, enhances security by keeping sensitive data and API keys on the server side rather than distributed across potentially many client machines, and decouples the AI model from the specifics of the external system integration, making the entire ecosystem more scalable, secure, and maintainable than requiring every AI instance to manage its own direct integrations.

We will implement our MCP server using HTTP and Server-Sent Events (SSE) for communication, which is well-suited for potentially long-running tool executions and enterprise scenarios.
👉📝 First, let's implement the list_tools endpoint. Open the file ~/instavibe-bootstrap/tools/instavibe/mcp_server.py and replace the #REPLACE ME - LIST TOOLS comment with the following code. :
@app.list_tools()
async def list_tools() -> list[mcp_types.Tool]:
"""MCP handler to list available tools."""
# Convert the ADK tool's definition to MCP format
mcp_tool_schema_event = adk_to_mcp_tool_type(event_tool)
mcp_tool_schema_post = adk_to_mcp_tool_type(post_tool)
print(f"MCP Server: Received list_tools request. \n MCP Server: Advertising tool: {mcp_tool_schema_event.name} and {mcp_tool_schema_post}")
return [mcp_tool_schema_event,mcp_tool_schema_post]
This function defines the tools (create_event, create_post) and tells connecting clients about them.
👉📝 Next, implement the call_tool endpoint, which handles the actual execution requests from clients. In the same ~/instavibe-bootstrap/tools/instavibe/mcp_server.py file, replace the #REPLACE ME - CALL TOOLS comment with this code.
@app.call_tool()
async def call_tool(
name: str, arguments: dict
) -> list[mcp_types.TextContent | mcp_types.ImageContent | mcp_types.EmbeddedResource]:
"""MCP handler to execute a tool call."""
print(f"MCP Server: Received call_tool request for '{name}' with args: {arguments}")
# Look up the tool by name in our dictionary
tool_to_call = available_tools.get(name)
if tool_to_call:
try:
adk_response = await tool_to_call.run_async(
args=arguments,
tool_context=None, # No ADK context available here
)
print(f"MCP Server: ADK tool '{name}' executed successfully.")
response_text = json.dumps(adk_response, indent=2)
return [mcp_types.TextContent(type="text", text=response_text)]
except Exception as e:
print(f"MCP Server: Error executing ADK tool '{name}': {e}")
# Creating a proper MCP error response might be more robust
error_text = json.dumps({"error": f"Failed to execute tool '{name}': {str(e)}"})
return [mcp_types.TextContent(type="text", text=error_text)]
else:
# Handle calls to unknown tools
print(f"MCP Server: Tool '{name}' not found.")
error_text = json.dumps({"error": f"Tool '{name}' not implemented."})
return [mcp_types.TextContent(type="text", text=error_text)]
This function receives the tool name and arguments, finds the corresponding Python wrapper function we defined earlier, executes it, and returns the result
👉💻 With the MCP server logic defined, we now need to package it as a container, in the terminal run the following script to build the Docker image using Cloud Build:
. ~/instavibe-bootstrap/set_env.sh
cd ~/instavibe-bootstrap/tools/instavibe
export IMAGE_TAG="latest"
export MCP_IMAGE_NAME="mcp-tool-server"
export IMAGE_PATH="${REGION}-docker.pkg.dev/${PROJECT_ID}/${REPO_NAME}/${MCP_IMAGE_NAME}:${IMAGE_TAG}"
export SERVICE_NAME="mcp-tool-server"
export INSTAVIBE_BASE_URL=$(gcloud run services list --platform=managed --region=us-central1 --format='value(URL)' | grep instavibe)/api
gcloud builds submit . \
--tag=${IMAGE_PATH} \
--project=${PROJECT_ID}
👉💻 And deploy the image as a service on Google Cloud Run.
. ~/instavibe-bootstrap/set_env.sh
cd ~/instavibe-bootstrap/tools/instavibe
export IMAGE_TAG="latest"
export MCP_IMAGE_NAME="mcp-tool-server"
export IMAGE_PATH="${REGION}-docker.pkg.dev/${PROJECT_ID}/${REPO_NAME}/${MCP_IMAGE_NAME}:${IMAGE_TAG}"
export SERVICE_NAME="mcp-tool-server"
export INSTAVIBE_BASE_URL=$(gcloud run services list --platform=managed --region=us-central1 --format='value(URL)' | grep instavibe)/api
gcloud run deploy ${SERVICE_NAME} \
--image=${IMAGE_PATH} \
--platform=managed \
--region=${REGION} \
--allow-unauthenticated \
--set-env-vars="INSTAVIBE_BASE_URL=${INSTAVIBE_BASE_URL}" \
--set-env-vars="APP_HOST=0.0.0.0" \
--set-env-vars="APP_PORT=8080" \
--set-env-vars="GOOGLE_GENAI_USE_VERTEXAI=TRUE" \
--set-env-vars="GOOGLE_CLOUD_LOCATION=${REGION}" \
--set-env-vars="GOOGLE_CLOUD_PROJECT=${PROJECT_ID}" \
--project=${PROJECT_ID} \
--min-instances=1
👉💻 After the deployment completed successfully, the MCP server will be running and accessible via a public URL. We need to capture this URL so our agent (acting as an MCP client) knows where to connect.
export MCP_SERVER_URL=$(gcloud run services list --platform=managed --region=us-central1 --format='value(URL)' | grep mcp-tool-server)/sse
You should also now be able to see the mcp-tool-server service listed as "Running" in the Cloud Run section of your Google Cloud Console.

With the MCP server deployed and its URL captured, we can now implement the agent that will act as an MCP client and utilize the tools exposed by this server.
8. Platform Interaction Agent (using MCP)
MCP Client The MCP Client is a component that resides within an AI application or agent, acting as the interface between the AI model and one or more MCP Servers; in our implementation, this client will be integrated directly within our agent. This client's primary function is to communicate with MCP Servers to discover available tools via the list_tools function and subsequently request the execution of specific tools using the call_tool function, passing necessary arguments provided by the AI model or the agent orchestrating the call.

Now we'll build the agent that acts as the MCP Client. This agent, running within the ADK framework, will be responsible for communicating with the mcp-tool-server we just deployed.
👉 First, we need to modify the agent definition to dynamically fetch the tools from our running MCP server. In agents/platform_mcp_client/agent.py , replace #REPLACE ME - FETCH TOOLS with following:
"""Gets tools from the File System MCP Server."""
tools = MCPToolset(
connection_params=SseServerParams(url=MCP_SERVER_URL, headers={})
)
This code uses the MCPToolset.from_server method to connect to the MCP_SERVER_URL (which we set as an environment variable earlier) and retrieve the list of available tools.
Next, we need to tell the ADK agent definition to actually use these dynamically fetched tools.
👉 In agents/platform_mcp_client/agent.py , replace #REPLACE ME - SET TOOLs with following:
tools=[tools],
👉💻 Now, let's test this agent locally using the ADK Dev UI to see if it can correctly connect to the MCP server and use the tools to interact with our running InstaVibe application.
. ~/instavibe-bootstrap/set_env.sh
source ~/instavibe-bootstrap/env/bin/activate
export MCP_SERVER_URL=$(gcloud run services list --platform=managed --region=us-central1 --format='value(URL)' | grep mcp-tool-server)/sse
cd ~/instavibe-bootstrap/agents
sed -i "s|^\(O\?GOOGLE_CLOUD_PROJECT\)=.*|GOOGLE_CLOUD_PROJECT=${PROJECT_ID}|" ~/instavibe-bootstrap/agents/platform_mcp_client/.env
sed -i "s|^\(O\?MCP_SERVER_URL\)=.*|MCP_SERVER_URL=${MCP_SERVER_URL}|" ~/instavibe-bootstrap/agents/platform_mcp_client/.env
adk web
Open the ADK Dev UI in your browser again (using Cloud Shell's Web Preview on port 8000). This time, in the top-right dropdown, select the platform_mcp_client agent.
Let's test the create_post tool. In the chat dialog, enter the following request:
Create a post saying "Y'all I just got the cutest lil void baby 😭✨ Naming him Abyss bc he's deep, mysterious, and lowkey chaotic 🔥🖤 #VoidCat #NewRoomie" I'm Julia

The agent should process this, identify the need to use the create_post tool, communicate with the MCP server, which in turn calls the InstaVibe API.
👉 Verification Step: After the agent confirms the action, open the tab where your InstaVibe application is running (or refresh it). You should see the new post from "Julia" appear on the main feed!

👉💻 Run this script in a separate terminal to get Instavibe link if needed:
gcloud run services list --platform=managed --region=us-central1 --format='value(URL)' | grep instavibe
👉📝 Now, let's test the create_event tool. Enter the following multi-line request into the chat dialog:
Hey, can you set up an event for Hannah and George and me, and I'm Julia? Let's call it 'Mexico City Culinary & Art Day'.
here are more info
{"event_name": "Mexico City Culinary & Art Day",
"description": "A vibrant day in Mexico City for Hannah and George, starting with lunch at one of the city's best taco spots in the hip Condesa neighborhood, followed by an inspiring afternoon exploring the Museo Soumaya's stunning art collection.",
"event_date": "2025-10-17T12:00:00-06:00",
"locations": [
{
"name": "El Tizoncito",
"description": "Considered one of the original creators of tacos al pastor, El Tizoncito offers a legendary taco experience in the heart of Condesa. Their flavorful meats, house salsas, and casual vibe make it a must-visit for foodies.",
"latitude": 19.412179,
"longitude": -99.171308,
"address": "Av. Tamaulipas 122, Hipódromo, Cuauhtémoc, 06100 Ciudad de México, CDMX, Mexico"
},
{
"name": "Museo Soumaya",
"description": "An architectural icon in Mexico City, Museo Soumaya houses over 66,000 works of art, including pieces by Rodin, Dalí, and Rivera. The striking silver structure is a cultural landmark and a visual feast inside and out.",
"latitude": 19.440056,
"longitude": -99.204281,
"address": "Plaza Carso, Blvd. Miguel de Cervantes Saavedra 303, Granada, Miguel Hidalgo, 11529 Ciudad de México, CDMX, Mexico"
}
],
"attendee_names": ["Hannah", "George", Julia],
}
Again, the agent should use the appropriate tool via the MCP server. In the Events tab, feel free to click on the indiviual event, you will see a detailed, step-by-step trace of the execution.

👉 Verification Step: Go back to your running InstaVibe application and navigate to the "Events" section (or equivalent). You should now see the newly created "Mexico City Culinary & Art Day" event listed.

This successfully demonstrates how MCP allows our agent to leverage external tools (in this case, InstaVibe's APIs) in a standardized way.
Once you've verified both actions, return to your Cloud Shell terminal and press Ctrl+C to stop the ADK Dev UI.
9. Workflow Agent and Multi-Agents in ADK
Our agents so far can plan outings and interact with the platform. However, truly personalized planning requires understanding the user's social circle. For busy users who might not closely follow their friends' activities, gathering this context manually is difficult. To address this, we'll build a Social Profiling agent that leverages our Spanner Graph Database to analyze friend activities and interests, enabling more tailored suggestions.

First, we need tools for this agent to access the graph data.
👉📝 Add the following Python functions to the end of the file ~/instavibe-bootstrap/agents/social/instavibe.py :
def get_person_attended_events(person_id: str)-> list[dict]:
"""
Fetches events attended by a specific person using Graph Query.
Args:
person_id (str): The ID of the person whose posts to fetch.
Returns: list[dict] or None.
"""
if not db_instance: return None
graph_sql = """
Graph SocialGraph
MATCH (p:Person)-[att:Attended]->(e:Event)
WHERE p.person_id = @person_id
RETURN e.event_id, e.name, e.event_date, att.attendance_time
ORDER BY e.event_date DESC
"""
params = {"person_id": person_id}
param_types_map = {"person_id": param_types.STRING}
fields = ["event_id", "name", "event_date", "attendance_time"]
results = run_graph_query( graph_sql, params=params, param_types=param_types_map, expected_fields=fields)
if results is None: return None
for event in results:
if isinstance(event.get('event_date'), datetime):
event['event_date'] = event['event_date'].isoformat()
if isinstance(event.get('attendance_time'), datetime):
event['attendance_time'] = event['attendance_time'].isoformat()
return results
def get_person_id_by_name( name: str) -> str:
"""
Fetches the person_id for a given name using SQL.
Args:
name (str): The name of the person to search for.
Returns:
str or None: The person_id if found, otherwise None.
Returns the ID of the *first* match if names are duplicated.
"""
if not db_instance: return None
sql = """
SELECT person_id
FROM Person
WHERE name = @name
LIMIT 1 -- Return only the first match in case of duplicate names
"""
params = {"name": name}
param_types_map = {"name": param_types.STRING}
fields = ["person_id"]
# Use the standard SQL query helper
results = run_sql_query( sql, params=params, param_types=param_types_map, expected_fields=fields)
if results: # Check if the list is not empty
return results[0].get('person_id') # Return the ID from the first dictionary
else:
return None # Name not found
def get_person_posts( person_id: str)-> list[dict]:
"""
Fetches posts written by a specific person using Graph Query.
Args:
person_id (str): The ID of the person whose posts to fetch.
Returns:
list[dict] or None: List of post dictionaries with ISO date strings,
or None if an error occurs.
"""
if not db_instance: return None
# Graph Query: Find the specific Person node, follow 'Wrote' edge to Post nodes
graph_sql = """
Graph SocialGraph
MATCH (author:Person)-[w:Wrote]->(post:Post)
WHERE author.person_id = @person_id
RETURN post.post_id, post.author_id, post.text, post.sentiment, post.post_timestamp, author.name AS author_name
ORDER BY post.post_timestamp DESC
"""
# Parameters now include person_id and limit
params = {
"person_id": person_id
}
param_types_map = {
"person_id": param_types.STRING
}
# Fields returned remain the same
fields = ["post_id", "author_id", "text", "sentiment", "post_timestamp", "author_name"]
results = run_graph_query(graph_sql, params=params, param_types=param_types_map, expected_fields=fields)
if results is None:
return None
# Convert datetime objects to ISO format strings
for post in results:
if isinstance(post.get('post_timestamp'), datetime):
post['post_timestamp'] = post['post_timestamp'].isoformat()
return results
def get_person_friends( person_id: str)-> list[dict]:
"""
Fetches friends for a specific person using Graph Query.
Args:
person_id (str): The ID of the person whose posts to fetch.
Returns: list[dict] or None.
"""
if not db_instance: return None
graph_sql = """
Graph SocialGraph
MATCH (p:Person {person_id: @person_id})-[f:Friendship]-(friend:Person)
RETURN DISTINCT friend.person_id, friend.name
ORDER BY friend.name
"""
params = {"person_id": person_id}
param_types_map = {"person_id": param_types.STRING}
fields = ["person_id", "name"]
results = run_graph_query( graph_sql, params=params, param_types=param_types_map, expected_fields=fields)
return results
Now, let's discuss how to structure our agent. Analyzing multiple friends' profiles and then summarizing the findings involves several steps. This is a perfect scenario for using ADK's multi-agent capabilities, specifically Workflow Agents .
In Google's ADK, a Workflow Agent doesn't perform tasks itself but orchestrates other agents, called sub-agents . This allows for modular design, breaking down complex problems into specialized components. ADK provides built-in workflow types like
- Sequential (step-by-step)
- Parallel (concurrent execution)
- and Loop (repeated execution)

For our social profiling task, our design uses a Loop Agent to create an iterative workflow. The intention is to process one person at a time: profile_agent gathers data, summary_agent updates the analysis, and check_agent determines if we should loop again.
Let's define the sub-agents required for this workflow.
👉📝 In ~/instavibe-bootstrap/agents/social/agent.py , replace #REPLACE FOR profile_agent with following:
profile_agent = LlmAgent(
name="profile_agent",
model="gemini-2.5-flash",
description=(
"Agent to answer questions about the this person social profile. Provide the person's profile using their name, make sure to fetch the id before getting other data."
),
instruction=(
"You are a helpful agent to answer questions about the this person social profile. You'll be given a list of names, provide the person's profile using their name, make sure to fetch the id before getting other data. Get one person at a time, start with the first one on the list, and skip if already provided. return this person's result"
),
tools=[get_person_posts,get_person_friends,get_person_id_by_name,get_person_attended_events],
)
Next, the agent that takes the collected profile information (accumulated across loop iterations) and generates the final summary, identifying common ground if multiple people were analyzed.
👉📝 In the same ~/instavibe-bootstrap/agents/social/agent.py , replace #REPLACE FOR summary_agent with following:
summary_agent = LlmAgent(
name="summary_agent",
model="gemini-2.5-flash",
description=(
"Generate a comprehensive social summary as a single, cohesive paragraph. This summary should cover the activities, posts, friend networks, and event participation of one or more individuals. If multiple profiles are analyzed, the paragraph must also identify and integrate any common ground found between them."
),
instruction=(
"""
Your primary task is to synthesize social profile information into a single, comprehensive paragraph.
**Input Scope & Default Behavior:**
* If specific individuals are named by the user, focus your analysis on them.
* **If no individuals are specified, or if the request is general, assume the user wants an analysis of *all relevant profiles available in the current dataset/context*.**
**For each profile (whether specified or determined by default), you must analyze:**
1. **Post Analysis:**
* Systematically review their posts (e.g., content, topics, frequency, engagement).
* Identify recurring themes, primary interests, and expressed sentiments.
2. **Friendship Relationship Analysis:**
* Examine their connections/friends list.
* Identify key relationships, mutual friends (especially if comparing multiple profiles), and the general structure of their social network.
3. **Event Participation Analysis:**
* Investigate their past (and if available, upcoming) event participation.
* Note the types of events, frequency of attendance, and any notable roles (e.g., organizer, speaker).
**Output Generation (Single Paragraph):**
* **Your entire output must be a single, cohesive summary paragraph.**
* **If analyzing a single profile:** This paragraph will detail their activities, interests, and social connections based on the post, friend, and event analysis.
* **If analyzing multiple profiles:** This paragraph will synthesize the key findings regarding posts, friends, and events for each individual. Crucially, it must then seamlessly integrate or conclude with an identification and description of the common ground found between them (e.g., shared interests from posts, overlapping event attendance, mutual friends). The aim is a unified narrative within this single paragraph.
**Key Considerations:**
* Base your summary strictly on the available data.
* If data for a specific category (posts, friends, events) is missing or sparse for a profile, you may briefly acknowledge this within the narrative if relevant.
"""
),
output_key="summary"
)
We need a way to determine when the loop should stop (ie, when all requested profiles have been summarized)
👉📝 In the same ~/instavibe-bootstrap/agents/social/agent.py , replace #REPLACE FOR check_agent with following:
check_agent = LlmAgent(
name="check_agent",
model="gemini-2.5-flash",
description=(
"Check if everyone's social profile are summarized and has been generated. Output 'completed' or 'pending'."
),
output_key="summary_status"
)
We add a simple programmatic check (CheckCondition) that explicitly looks at the summary_status stored in the State , that are returned by check_agent and tells the Loop Agent whether to continue (escalate=False) or stop (escalate=True).
👉📝 In the same ~/instavibe-bootstrap/agents/social/agent.py , replace #REPLACE FOR CheckCondition located on the top of the file with following:
class CheckCondition(BaseAgent):
async def _run_async_impl(self, ctx: InvocationContext) -> AsyncGenerator[Event, None]:
#log.info(f"Checking status: {ctx.session.state.get("summary_status", "fail")}")
log.info(f"Summary: {ctx.session.state.get("summary")}")
status = ctx.session.state.get("summary_status", "fail").strip()
is_done = (status == "completed")
yield Event(author=self.name, actions=EventActions(escalate=is_done))
State and Callbacks for Loop Results
In Google's ADK, State is a crucial concept representing the memory or working data of an agent during its execution. It's essentially a persistent context that holds information an agent needs to maintain across different steps, tool calls, or interactions. This state can store intermediate results, user information, parameters for subsequent actions, or any other data the agent needs to remember as it progresses through a task.
In our scenario, as the Loop Agent iterates, the summary_agent and check_agent store their outputs (summary and summary_status) in the agent's State. This allows information to persist across iterations. However, the Loop Agent itself doesn't automatically return the final summary from the state when it finishes.

Callbacks in ADK allow us to inject custom logic to be executed at specific points during an agent's lifecycle or in response to certain events, such as the completion of a tool call or before the agent finishes its execution. They provide a way to customize the agent's behavior and process results dynamically.
We'll use an after_agent_callback that runs when the loop finishes (because CheckCondition escalated). This callback modify_output_after_agent retrieves the final summary from the state and formats it as the agent's final output message.

👉📝 In the same ~/instavibe-bootstrap/agents/social/agent.py , replace #REPLACE FOR modify_output_after_agent with follow:
def modify_output_after_agent(callback_context: CallbackContext) -> Optional[types.Content]:
agent_name = callback_context.agent_name
invocation_id = callback_context.invocation_id
current_state = callback_context.state.to_dict()
current_user_content = callback_context.user_content
print(f"[Callback] Exiting agent: {agent_name} (Inv: {invocation_id})")
print(f"[Callback] Current summary_status: {current_state.get("summary_status")}")
print(f"[Callback] Current Content: {current_user_content}")
status = current_state.get("summary_status").strip()
is_done = (status == "completed")
# Retrieve the final summary from the state
final_summary = current_state.get("summary")
print(f"[Callback] final_summary: {final_summary}")
if final_summary and is_done and isinstance(final_summary, str):
log.info(f"[Callback] Found final summary, constructing output Content.")
# Construct the final output Content object to be sent back
return types.Content(role="model", parts=[types.Part(text=final_summary.strip())])
else:
log.warning("[Callback] No final summary found in state or it's not a string.")
# Optionally return a default message or None if no summary was generated
return None
Defining the Root Loop Agent
Finally, we define the main LoopAgent. It orchestrates the sub-agents in sequence within each loop iteration (profile_agent -> summary_agent -> check_agent -> CheckCondition). It will repeat this sequence up to max_iterations times or until CheckCondition signals completion. The after_agent_callback ensures the final summary is returned.
👉📝 In the same ~/instavibe-bootstrap/agents/social/agent.py , replace #REPLACE FOR root_agent with follow:
root_agent = LoopAgent(
name="InteractivePipeline",
sub_agents=[
profile_agent,
summary_agent,
check_agent,
CheckCondition(name="Checker")
],
description="Find everyone's social profile on events, post and friends",
max_iterations=10,
after_agent_callback=modify_output_after_agent
)
Let's test this multi-agent workflow using the ADK Dev UI.
👉💻 Launch the ADK web server:
. ~/instavibe-bootstrap/set_env.sh
source ~/instavibe-bootstrap/env/bin/activate
cd ~/instavibe-bootstrap/agents
sed -i "s|^\(O\?GOOGLE_CLOUD_PROJECT\)=.*|GOOGLE_CLOUD_PROJECT=${PROJECT_ID}|" ~/instavibe-bootstrap/agents/social/.env
adk web
Open the ADK Dev UI (port 8000 via Web Preview). In the agent dropdown menu (top-right), select the Social Agent.
👉 Now, give it the task to profile multiple people. In the chat dialog, enter:
Tell me about Mike and Bob
After the agent responds (which might take a bit longer due to the looping and multiple LLM calls), don't just look at the final chat output. Navigate to the Events tab in the left-hand pane of the ADK Dev UI.
👉 Verification Step: In the Events tab, you will see a detailed, step-by-step trace of the execution. 
After observing how the agent invokes each sub-agent, where you expect the flow to go from profile_agent -> summary_agent -> check_agent, Checker within each iteration. But in practice, however, we see the agent's powerful 'self-optimization' in action.
Because the underlying model sees the entire request (eg, 'profile Mike and Bob'), it often chooses the most efficient path, gathering all required data in a single, consolidated turn rather than iterating multiple times. You can see the inputs and outputs and states for each step, including tool calls made by profile_agent

and the status updates from check_agent and CheckCondition. 
This visual trace is invaluable for understanding and debugging how the multi-agent workflow operates until the final summary is generated and returned by the callback.
Once you have explored the chat response and the event trace, return to the Cloud Shell terminal and press Ctrl+C to stop the ADK Dev UI.
10. Agent-to-Agent (A2A) Communication
So far, we've built specialized agents, but they operate in isolation or within a predefined workflow on the same machine. To build truly distributed and collaborative multi-agent systems, we need a way for agents, potentially running as separate services, to discover each other and communicate effectively. This is where the Agent-to-Agent (A2A) protocol comes in.
The A2A protocol is an open standard specifically designed for interoperable communication between AI agents. While MCP focuses on agent-to-tool interaction, A2A focuses on agent-to-agent interaction. It allows agents to:
- Discover : Find other agents and learn their capabilities via standardized Agent Cards.
- Communicate : Exchange messages and data securely.
- Collaborate : Delegate tasks and coordinate actions to achieve complex goals.
The A2A protocol facilitates this communication through mechanisms like "Agent Cards," which agents can use to advertise their capabilities and connection information.

A2A utilizes familiar web standards (HTTP, SSE, JSON-RPC) and often employs a client-server model where one agent (client) sends tasks to another (remote agent/server). This standardization is key to building modular, scalable systems where agents developed independently can work together.
Enabling A2A for InstaVibe Agents
To make our existing Planner, Platform Interaction, and Social agents accessible to other agents via A2A, we need to wrap each one with an A2A Server component. This server will:
- Expose an Agent Card : Serve a standard description of the agent's capabilities via an HTTP endpoint.
- Listen for Tasks(Request Messages) : Accept incoming task requests from other agents (A2A clients) according to the A2A protocol.
- Manage Task(Request Messages) Execution : Hand off received tasks to the underlying ADK agent logic for processing.
Planner Agent (A2A Enabled)

Let's start by adding the A2A server layer to our Planner Agent.
Define the A2A server startup logic. This code defines the AgentCard (the public description of the agent), configures the A2AServer, and starts it, linking it to the PlatformAgentExecutor .
👉📝 Add the following code to the end of ~/instavibe-bootstrap/agents/planner/a2a_server.py :
class PlannerAgent:
"""An agent to help user planning a event with its desire location."""
SUPPORTED_CONTENT_TYPES = ["text", "text/plain"]
def __init__(self):
self._agent = self._build_agent()
self.runner = Runner(
app_name=self._agent.name,
agent=self._agent,
artifact_service=InMemoryArtifactService(),
session_service=InMemorySessionService(),
memory_service=InMemoryMemoryService(),
)
capabilities = AgentCapabilities(streaming=True)
skill = AgentSkill(
id="event_planner",
name="Event planner",
description="""
This agent generates multiple fun plan suggestions tailored to your specified location, dates, and interests,
all designed for a moderate budget. It delivers detailed itineraries,
including precise venue information (name, latitude, longitude, and description), in a structured JSON format.
""",
tags=["instavibe"],
examples=["What about Bostona MA this weekend?"],
)
self.agent_card = AgentCard(
name="Event Planner Agent",
description="""
This agent generates multiple fun plan suggestions tailored to your specified location, dates, and interests,
all designed for a moderate budget. It delivers detailed itineraries,
including precise venue information (name, latitude, longitude, and description), in a structured JSON format.
""",
url=f"{PUBLIC_URL}",
version="1.0.0",
defaultInputModes=PlannerAgent.SUPPORTED_CONTENT_TYPES,
defaultOutputModes=PlannerAgent.SUPPORTED_CONTENT_TYPES,
capabilities=capabilities,
skills=[skill],
)
def get_processing_message(self) -> str:
return "Processing the planning request..."
def _build_agent(self) -> LlmAgent:
"""Builds the LLM agent for the night out planning agent."""
return agent.root_agent
if __name__ == '__main__':
try:
plannerAgent = PlannerAgent()
request_handler = DefaultRequestHandler(
agent_executor=PlannerAgentExecutor(plannerAgent.runner,plannerAgent.agent_card),
task_store=InMemoryTaskStore(),
)
server = A2AStarletteApplication(
agent_card=plannerAgent.agent_card,
http_handler=request_handler,
)
logger.info(f"Attempting to start server with Agent Card: {plannerAgent.agent_card.name}")
logger.info(f"Server object created: {server}")
uvicorn.run(server.build(), host='0.0.0.0', port=port)
except Exception as e:
logger.error(f"An error occurred during server startup: {e}")
exit(1)
👉💻 Let's quickly test if the A2A server starts correctly locally and serves its Agent Card. Run the following command in your first terminal:
. ~/instavibe-bootstrap/set_env.sh
source ~/instavibe-bootstrap/env/bin/activate
cd ~/instavibe-bootstrap/agents/
python -m planner.a2a_server
👉 Now, open another terminal window. (Click on the + sign in the terminal panel) 
👉💻 Use curl to request the Agent Card from the locally running server:
curl http://localhost:10003/.well-known/agent.json | jq
You should see the JSON representation of the AgentCard we defined, confirming the server is running and advertising the Planner agent.

Go back to the first terminal (where the server is running) and press Ctrl+C to stop it.
👉💻 With the A2A server logic added, we can now build the container image.
Build and Deploy the Planner Agent
. ~/instavibe-bootstrap/set_env.sh
cd ~/instavibe-bootstrap/agents
# Set variables specific to the PLANNER agent
export IMAGE_TAG="latest"
export AGENT_NAME="planner"
export IMAGE_NAME="planner-agent"
export IMAGE_PATH="${REGION}-docker.pkg.dev/${PROJECT_ID}/${REPO_NAME}/${IMAGE_NAME}:${IMAGE_TAG}"
export SERVICE_NAME="planner-agent"
export PUBLIC_URL="https://planner-agent-${PROJECT_NUMBER}.${REGION}.run.app"
echo "Building ${AGENT_NAME} agent..."
gcloud builds submit . \
--config=cloudbuild-build.yaml \
--project=${PROJECT_ID} \
--region=${REGION} \
--substitutions=_AGENT_NAME=${AGENT_NAME},_IMAGE_PATH=${IMAGE_PATH}
echo "Image built and pushed to: ${IMAGE_PATH}"
👉💻 And deploy our Planner Agent on Cloud Run.
. ~/instavibe-bootstrap/set_env.sh
cd ~/instavibe-bootstrap/agents
# Set variables specific to the PLANNER agent
export IMAGE_TAG="latest"
export AGENT_NAME="planner"
export IMAGE_NAME="planner-agent"
export IMAGE_PATH="${REGION}-docker.pkg.dev/${PROJECT_ID}/${REPO_NAME}/${IMAGE_NAME}:${IMAGE_TAG}"
export SERVICE_NAME="planner-agent"
export PUBLIC_URL="https://planner-agent-${PROJECT_NUMBER}.${REGION}.run.app"
gcloud run deploy ${SERVICE_NAME} \
--image=${IMAGE_PATH} \
--platform=managed \
--region=${REGION} \
--set-env-vars="A2A_HOST=0.0.0.0" \
--set-env-vars="A2A_PORT=8080" \
--set-env-vars="GOOGLE_GENAI_USE_VERTEXAI=TRUE" \
--set-env-vars="GOOGLE_CLOUD_LOCATION=${REGION}" \
--set-env-vars="GOOGLE_CLOUD_PROJECT=${PROJECT_ID}" \
--set-env-vars="PUBLIC_URL=${PUBLIC_URL}" \
--allow-unauthenticated \
--project=${PROJECT_ID} \
--min-instances=1
Let's verify that the deployed service is running and serving its Agent Card correctly from the cloud using the A2A Inspector .
👉 From the Web preview icon in the Cloud Shell toolbar, select Change port. Set the port to 8081 and click "Change and Preview". A new browser tab will open with the A2A Inspector interface.

👉💻 In the terminal, get the URL of your deployed planner agent:
export PLANNER_AGENT_URL=$(gcloud run services list --platform=managed --region=us-central1 --format='value(URL)' | grep planner-agent)
echo ${PLANNER_AGENT_URL}
👉💻 Copy the output URL.
👉 In the A2A Inspector UI, paste the URL into the Agent URL field and click Connect.
👀 The agent's card details and JSON should appear on the Agent Card tab, confirming a successful connection.

👉 Click on the Chat tab in the A2A Inspector. This is where you can interact directly with your deployed agen, Send it a message to test its planning capability. For example:
Plan something for me in Boston MA this weekend, and I enjoy classical music
👀 To inspect the raw communication, click on your message bubble and then on the agent's response bubble in the chat window. As you click each one, it will display the full JSON-RPC 2.0 message that was sent or received, which is invaluable for debugging.
Let's keep the A2A Inspector tab handy. Do NOT close it! We'll be using it again in a moment to test our other two agents.

Platform Interaction Agent (A2A Enabled)

Next, we'll repeat the process for the Platform Interaction Agent (the one using MCP).
👉📝 Define the A2A server setup, including its unique AgentCard, at the end of ~/instavibe-bootstrap/agents/platform_mcp_client/a2a_server.py :
class PlatformAgent:
"""An agent that post event and post to instavibe."""
SUPPORTED_CONTENT_TYPES = ["text", "text/plain"]
def __init__(self):
self._agent = self._build_agent()
self.runner = Runner(
app_name=self._agent.name,
agent=self._agent,
artifact_service=InMemoryArtifactService(),
session_service=InMemorySessionService(),
memory_service=InMemoryMemoryService(),
)
capabilities = AgentCapabilities(streaming=True)
skill = AgentSkill(
id="instavibe_posting",
name="Post social post and events on instavibe",
description="""
This "Instavibe" agent helps you create posts (identifying author, text, and sentiment – inferred if unspecified) and register
for events (gathering name, date, attendee). It efficiently collects required information and utilizes dedicated tools
to perform these actions on your behalf, ensuring a smooth sharing experience.
""",
tags=["instavibe"],
examples=["Create a post for me, the post is about my cute cat and make it positive, and I'm Alice"],
)
self.agent_card = AgentCard(
name="Instavibe Posting Agent",
description="""
This "Instavibe" agent helps you create posts (identifying author, text, and sentiment – inferred if unspecified) and register
for events (gathering name, date, attendee). It efficiently collects required information and utilizes dedicated tools
to perform these actions on your behalf, ensuring a smooth sharing experience.
""",
url=f"{PUBLIC_URL}",
version="1.0.0",
defaultInputModes=PlatformAgent.SUPPORTED_CONTENT_TYPES,
defaultOutputModes=PlatformAgent.SUPPORTED_CONTENT_TYPES,
capabilities=capabilities,
skills=[skill],
)
def get_processing_message(self) -> str:
return "Processing the social post and event request..."
def _build_agent(self) -> LlmAgent:
"""Builds the LLM agent for the Processing the social post and event request."""
return agent.root_agent
if __name__ == '__main__':
try:
platformAgent = PlatformAgent()
request_handler = DefaultRequestHandler(
agent_executor=PlatformAgentExecutor(platformAgent.runner,platformAgent.agent_card),
task_store=InMemoryTaskStore(),
)
server = A2AStarletteApplication(
agent_card=platformAgent.agent_card,
http_handler=request_handler,
)
uvicorn.run(server.build(), host='0.0.0.0', port=port)
except Exception as e:
logger.error(f"An error occurred during server startup: {e}")
exit(1)
Social Agent (A2A Enabled)

Finally, let's enable A2A for our Social Profiling Agent.
👉📝 Define the A2A server setup and AgentCard at the end of ~/instavibe-bootstrap/agents/social/a2a_server.py :
class SocialAgent:
"""An agent that handles social profile analysis."""
SUPPORTED_CONTENT_TYPES = ["text", "text/plain"]
def __init__(self):
self._agent = self._build_agent()
self.runner = Runner(
app_name=self._agent.name,
agent=self._agent,
artifact_service=InMemoryArtifactService(),
session_service=InMemorySessionService(),
memory_service=InMemoryMemoryService(),
)
capabilities = AgentCapabilities(streaming=True)
skill = AgentSkill(
id="social_profile_analysis",
name="Analyze Instavibe social profile",
description="""
Using a provided list of names, this agent synthesizes Instavibe social profile information by analyzing posts, friends, and events.
It delivers a comprehensive single-paragraph summary for individuals, and for groups, identifies commonalities in their social activities
and connections based on profile data.
""",
tags=["instavibe"],
examples=["Can you tell me about Bob and Alice?"],
)
self.agent_card = AgentCard(
name="Social Profile Agent",
description="""
Using a provided list of names, this agent synthesizes Instavibe social profile information by analyzing posts, friends, and events.
It delivers a comprehensive single-paragraph summary for individuals, and for groups, identifies commonalities in their social activities
and connections based on profile data.
""",
url=f"{PUBLIC_URL}",
version="1.0.0",
defaultInputModes=self.SUPPORTED_CONTENT_TYPES,
defaultOutputModes=self.SUPPORTED_CONTENT_TYPES,
capabilities=capabilities,
skills=[skill],
)
def get_processing_message(self) -> str:
return "Processing the social profile analysis request..."
def _build_agent(self) -> LoopAgent:
"""Builds the LLM agent for the social profile analysis agent."""
return agent.root_agent
if __name__ == '__main__':
try:
socialAgent = SocialAgent()
request_handler = DefaultRequestHandler(
agent_executor=SocialAgentExecutor(socialAgent.runner,socialAgent.agent_card),
task_store=InMemoryTaskStore(),
)
server = A2AStarletteApplication(
agent_card=socialAgent.agent_card,
http_handler=request_handler,
)
uvicorn.run(server.build(), host='0.0.0.0', port=port)
except Exception as e:
logger.error(f"An error occurred during server startup: {e}")
exit(1)
Build and Deploy the Platform Interaction and Social agents
These agents need access to Spanner, so ensure the SPANNER_INSTANCE_ID , SPANNER_DATABASE_ID and MCP_SERVER_URL environment variables are correctly passed during deployment.
👉💻 Build and deploy to Cloud Run with Cloud Build :
. ~/instavibe-bootstrap/set_env.sh
cd ~/instavibe-bootstrap/agents
export MCP_SERVER_URL=$(gcloud run services list --platform=managed --region=us-central1 --format='value(URL)' | grep mcp-tool-server)/sse
gcloud builds submit . \
--config=cloudbuild.yaml \
--project="${PROJECT_ID}" \
--region="${REGION}" \
--substitutions=\
_PROJECT_ID="${PROJECT_ID}",\
_PROJECT_NUMBER="${PROJECT_NUMBER}",\
_REGION="${REGION}",\
_REPO_NAME="${REPO_NAME}",\
_SPANNER_INSTANCE_ID="${SPANNER_INSTANCE_ID}",\
_SPANNER_DATABASE_ID="${SPANNER_DATABASE_ID}",\
_MCP_SERVER_URL="${MCP_SERVER_URL}"
👉💻 In the terminal, get the URL of your deployed platform agent:
export PLATFORM_MPC_CLIENT_URL=$(gcloud run services list --platform=managed --region=us-central1 --format='value(URL)' | grep platform-mcp-client)
echo $PLATFORM_MPC_CLIENT_URL
👉💻 Copy the output URL.
👉 In the A2A Inspector UI, paste the URL into the Agent URL field and click Connect.
👀 The agent's card details and JSON should appear on the Agent Card tab, confirming a successful connection.

👉 Click on the Chat tab in the A2A Inspector. This is where you can interact directly with your deployed agen, Send it a message test the agent's ability to create posts:
Create a post for me, the post says 'Paws, purrs, and ocean views 🐾☕🌊. Spent my morning at the Morning Seaside Cat Café, where every sip comes with a side of snuggles and sea breeze.' and make it positive, and I'm Oscar.
👀 To inspect the raw communication, click on your message bubble and then on the agent's response bubble in the chat window. As you click each one, it will display the full JSON-RPC 2.0 message that was sent or received, which is invaluable for debugging.
👉💻 In the terminal, get the URL of your deployed Social agent:
export SOCIAL_AGENT_URL=$(gcloud run services list --platform=managed --region=us-central1 --format='value(URL)' | grep social-agent)
echo $SOCIAL_AGENT_URL
👉💻 Copy the output URL.
👉 In the A2A Inspector UI, paste the URL into the Agent URL field and click Connect.
👀 The agent's card details and JSON should appear on the Agent Card tab, confirming a successful connection.

👉 Click on the Chat tab in the A2A Inspector. This is where you can interact directly with your deployed agen, Send it a message to analyze user profiles from your database:
Can you tell me about both Ian and Kevin's profile, what are their common interests?
👀 To inspect the raw communication, click on your message bubble and then on the agent's response bubble in the chat window. As you click each one, it will display the full JSON-RPC 2.0 message that was sent or received, which is invaluable for debugging.
👉 Great, we've finished inspecting all our agents. You can close the A2A Inspector tab now.
11. Orchestrator Agent (A2A Client)
We now have three specialized agents (Planner, Platform, Social) running as independent, A2A-enabled services on Cloud Run. The final piece is the Orchestrator Agent. This agent will act as the central coordinator or A2A Client. It will receive user requests, figure out which remote agent(s) are needed to fulfill the request (potentially in sequence), and then use the A2A protocol to delegate tasks to those remote agents. For this workshop, we will run the Orchestrator agent locally using the ADK Dev UI.

First, let's enhance the Orchestrator's logic to handle the registration of remote agents it discovers. Stores the connection details from the fetched Agent Cards during initialization.
👉📝 In ~/instavibe-bootstrap/agents/orchestrate/agent.py , replace #REPLACE ME REG AGENT CARD with:
async with httpx.AsyncClient(timeout=30) as client:
for i, address in enumerate(REMOTE_AGENT_ADDRESSES):
log.info(f"--- STEP 3.{i}: Attempting connection to: {address} ---")
try:
card_resolver = A2ACardResolver(client, address)
card = await card_resolver.get_agent_card()
remote_connection = RemoteAgentConnections(agent_card=card, agent_url=address)
self.remote_agent_connections[card.name] = remote_connection
self.cards[card.name] = card
log.info(f"--- STEP 5.{i}: Successfully stored connection for {card.name} ---")
except Exception as e:
log.error(f"--- CRITICAL FAILURE at STEP 4.{i} for address: {address} ---")
log.error(f"--- The hidden exception type is: {type(e).__name__} ---")
log.error(f"--- Full exception details and traceback: ---", exc_info=True)
Next, define the tool for the Orchestrator agent itself within ADK.
-
send_message(the A2A function to delegate work).
👉📝 Replace #REPLACE ME CREATE AGENT in ~/instavibe-bootstrap/agents/orchestrate/agent.py with:
def create_agent(self) -> Agent:
"""Synchronously creates the ADK Agent object."""
return Agent(
model="gemini-2.5-flash",
name="orchestrate_agent",
instruction=self.root_instruction,
before_agent_callback=self.before_agent_callback,
description=("Orchestrates tasks for child agents."),
tools=[self.send_message],
)
The core logic of the Orchestrator lies in its instructions, which tell it how to use A2A.
👉📝 Replace #REPLACE ME INSTRUCTIONS in ~/instavibe-bootstrap/agents/orchestrate/agent.py with this instruction-generating method:
def root_instruction(self, context: ReadonlyContext) -> str:
current_agent = self.check_active_agent(context)
return f"""
You are an expert AI Orchestrator. Your primary responsibility is to intelligently interpret user requests, break them down into a logical plan of discrete actions, and delegate each action to the most appropriate specialized remote agent using the send_message function. You do not perform the tasks yourself but manage their assignment, sequence, and critically, their outcomes.
**Core Directives & Decision Making:**
* **Understand User Intent & Complexity:**
* Carefully analyze the user's request to determine the core task(s) they want to achieve. Pay close attention to keywords and the overall goal.
* Identify if the request requires a single agent or a sequence of actions from multiple agents. For example, "Analyze John Doe's profile and then create a positive post about his recent event attendance" would require two agents in sequence.
* **Task Planning & Sequencing (for Multi-Step Requests):**
* Before delegating, outline the clear sequence of agent tasks.
* Identify dependencies. If Task B requires output from Task A, execute them sequentially. If tasks are independent (like creating a post and then creating an event), execute them one after the other as separate delegations.
* Agent Reusability: An agent's completion of one task does not make it unavailable. If a user's plan involves multiple, distinct actions that fall under the same agent's expertise (e.g., create a post, then create an event), you must call that same agent again for the subsequent task.
* **Task Delegation & Management (using `send_message`):**
* **Delegation:** Use `send_message` to assign actionable tasks to the selected remote agent. Your `send_message` call MUST include:
* The `remote_agent_name` you've selected.
* The `user_request` or all necessary parameters extracted from the user's input, formatted in a way the target agent will understand.
* **Contextual Awareness for Remote Agents:** If a remote agent repeatedly requests user confirmation or seems to lack context, assume it lacks access to the full conversation history. In such cases, enrich your `send_message` with all necessary contextual information relevant to that specific agent from the conversation history.
* **Sequential Task Execution:**
* After a preceding task completes (indicated by the agent's response or a success signal), gather any necessary output from it.
* Then, use `send_message` for the next agent in the sequence, providing it with the user's original relevant intent and any necessary data obtained from the previous agent's task.
* **Active Agent Prioritization:** If an active agent is already engaged and the user's request is related to its current task, route subsequent related requests directly to that agent by providing updated context via `send_message`.
**Critical Success Verification:**
* You **MUST** wait for the tool_output after every send_message call before taking any further action.
* Your decision to proceed to the next task in a sequence **MUST** be based entirely on a confirmation of success from the tool_output of the previous task.
* If a tool call fails, returns an error, or the tool_output is ambiguous, you MUST STOP the sequence. Your next action is to report the exact failure or ambiguity to the user.
* DO NOT assume a task was successful. Do not invent success messages like "The event has been created." Only state that a task is complete if the tool's response explicitly says so.
**Communication with User:**
* **Transparent Communication:** Always present the complete and detailed response from the remote agent to the user. Do not summarize or filter unless explicitly instructed.
* When you delegate a task (or the first task in a sequence), clearly inform the user which remote agent is handling it.
* For multi-step requests, you can optionally inform the user of the planned sequence (e.g., "Okay, first I'll ask the 'Social Profile Agent' to analyze the profile, and then I'll have the 'Instavibe Posting Agent' create the post.").
* If waiting for a task in a sequence to complete, you can inform the user (e.g., "The 'Social Profile Agent' is currently processing. I'll proceed with the post once that's done.").
* **User Confirmation Relay:** If a remote agent asks for confirmation, and the user has not already provided it, just make up something.
* If the user's request is ambiguous, if necessary information is missing for any agent in the sequence, or if you are unsure about the plan, just make up something.
**Important Reminders:**
* **Autonomous Agent Engagement:** Never seek user permission before engaging with remote agents. If multiple agents are required to fulfill a request, connect with them directly without requesting user preference or confirmation.
* **Focused Information Sharing:** Provide remote agents with only relevant contextual information. Avoid extraneous details that are not directly pertinent to their task.
* **No Redundant Confirmations:** Do not ask remote agents for confirmation of information or actions they have already processed or committed to.
* **Tool Reliance:** Strictly rely on your available tools, primarily `send_message`, to address user requests. Do not generate responses based on assumptions. If information is insufficient, request clarification from the user.
* **Prioritize Recent Interaction:** Focus primarily on the most recent parts of the conversation when processing requests, while maintaining awareness of the overall goal for multi-step tasks.
* Always prioritize selecting the correct agent(s) based on their documented purpose.
* Ensure all information required by the chosen remote agent is included in the `send_message` call, including outputs from previous agents if it's a sequential task.
Agents:
{self.agents}
Current agent: {current_agent['active_agent']}`
"""
Testing the Orchestrator and the Full A2A System
Now, let's test the entire system. We'll run the Orchestrator locally using the ADK Dev UI, and it will communicate with the Planner, Platform, and Social agents running remotely on Cloud Run.
👉💻 First, ensure the environment variable REMOTE_AGENT_ADDRESSES contains the comma-separated URLs of your deployed A2A-enabled agents. Then, set the necessary environment variables for the Orchestrator agent and launch the ADK Dev UI:
. ~/instavibe-bootstrap/set_env.sh
source ~/instavibe-bootstrap/env/bin/activate
export PLATFORM_MPC_CLIENT_URL=$(gcloud run services list --platform=managed --region=us-central1 --format='value(URL)' | grep platform-mcp-client)
export PLANNER_AGENT_URL=$(gcloud run services list --platform=managed --region=us-central1 --format='value(URL)' | grep planner-agent)
export SOCIAL_AGENT_URL=$(gcloud run services list --platform=managed --region=us-central1 --format='value(URL)' | grep social-agent)
export REMOTE_AGENT_ADDRESSES=${PLANNER_AGENT_URL},${PLATFORM_MPC_CLIENT_URL},${SOCIAL_AGENT_URL}
cd ~/instavibe-bootstrap/agents
sed -i "s|^\(O\?REMOTE_AGENT_ADDRESSES\)=.*|REMOTE_AGENT_ADDRESSES=${REMOTE_AGENT_ADDRESSES}|" ~/instavibe-bootstrap/agents/orchestrate/.env
adk web
👉 Open the ADK Dev UI (Change the port back to 8000 via Web Preview).

👉 In the agent dropdown, select the orchestrate agent.
👉 Now, give it a complex task that requires coordinating multiple remote agents. Try this first example, which should involve the Social Agent and then the Planner Agent:
You are an expert event planner for a user named Diana.
Your task is to design a fun and personalized event.
Here are the details for the plan:
- Friends to invite: Ian, Nora
- Desired date: "2025-10-15"
- Location idea or general preference: "Chicago"
Your process should be:
1. Analyze the provided friend names. If you have access to a tool to get their InstaVibe profiles or summarized interests, please use it.
2. Based on their potential interests (or general good taste if profiles are unavailable), create a tailored plan for the outing, check if you have access to any event planner tools.
3. Ensure the plan includes the original `planned_date`.
The user wants a comprehensive plan that includes:
- The list of invited friends.
- A catchy and descriptive name for the event.
- The exact planned date for the event.
- A summary of what the group will do.
- Specific recommended spots (e.g., restaurants, bars, activity venues) with their names, (if possible, approximate latitude/longitude for mapping, and address), and a brief description of why it fits the plan.
- A short, exciting message that {Diana} can send to {Ian, Nora} to get them excited about the event.

Observe the interaction in the ADK Dev UI chat window. Pay close attention to the Orchestrator's responses – it should state which remote agent it's delegating tasks to (eg, "Okay, I'll ask the Social Profile Agent about Ian and Nora first...").
Also, check the Events tab in the UI to see the underlying tool calls (send_message) being made to the remote agents' URLs.

👉 Now, try a second example that should involve the Platform Integration Agent directly:
Hey, can you register an event on Instavibe for Laura and Charlie? Let's call it 'Vienna Concert & Castles Day'.
here are more info
"event_name": "Vienna Concert & Castles Day",
"description": "A refined and unforgettable day in Vienna with Laura and Charlie. The day begins with a guided tour of the magnificent Schönbrunn Palace, showcasing imperial architecture and history. In the evening, enjoy a classical music concert in one of Vienna's most iconic concert halls.",
"event_date": "2025-10-14T10:00:00+02:00",
"locations": [
{
"name": "Schönbrunn Palace",
"description": "A UNESCO World Heritage Site and former imperial summer residence, Schönbrunn Palace offers opulent rooms, beautiful baroque gardens, and a glimpse into the life of the Habsburg monarchy. Visitors can stroll the grounds or take a guided historical tour.",
"latitude": 48.184516,
"longitude": 16.312222,
"address": "Schönbrunner Schloßstraße 47, 1130 Wien, Austria"
},
{
"name": "Musikverein Vienna",
"description": "Home to the world-renowned Vienna Philharmonic, the Musikverein is one of the finest concert halls in the world. Its 'Golden Hall' is famous for its acoustics and ornate design. Attendees can enjoy a powerful classical concert in an unforgettable setting.",
"latitude": 48.200132,
"longitude": 16.373777,
"address": "Musikvereinsplatz 1, 1010 Wien, Austria"
}
],
"attendee_names": ["Laura", "Charlie", "Oscar"] And I am Oscar
Again, monitor the chat and the Events tab. The Orchestrator should identify the need to create an event and delegate the task (with all the provided details) to the "Platform Integration Agent". You can also click on Trace button to view traces to analyze query response times and executed operations. 
You can then verify the event appears in the InstaVibe web application. 
This demonstrates the successful implementation of a multi-agent system using ADK and the A2A protocol, where a central orchestrator delegates tasks to specialized, remote agents.
Remember to stop the ADK Dev UI ( Ctrl+C in the terminal) when you are finished testing.
12. Agent Engine and Remote Call from InstaVibe
So far, we've run our specialized agents on Cloud Run and tested the Orchestrator locally using the ADK Dev UI. For a production scenario, we need a robust, scalable, and managed environment to host our agents. This is where Google Vertex AI Agent Engine comes in.
Agent Engine is a fully managed service on Vertex AI designed specifically for deploying and scaling AI agents. It abstracts away infrastructure management, security, and operational overhead, allowing developers (especially those less familiar with complex cloud environments) to focus on the agent's logic and capabilities rather than managing servers. It provides a dedicated runtime optimized for agentic workloads.
We'll now deploy our Orchestrator agent to Agent Engine. (Note: The deployment mechanism shown below uses a custom script (agent_engine_app.py) provided in the workshop materials, as official direct ADK-to-Agent-Engine deployment tools might still be evolving. This script handles packaging and deploying the Orchestrator agent, configured with the necessary remote agent addresses.)
Execute the following command to deploy the Orchestrator agent to Agent Engine. Make sure the REMOTE_AGENT_ADDRESSES environment variable (containing the URLs of your Planner, Platform, and Social agents on Cloud Run) is still correctly set from the previous section.
👉💻 We'll deploy the Orchestrate agent to Agent Engine (Note: this is my own implementation of the deployment, ADK has an CLI to help deploy, I will update this after BYO-SA being implemented.)
cd ~/instavibe-bootstrap/agents/
. ~/instavibe-bootstrap/set_env.sh
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:service-$PROJECT_NUMBER@gcp-sa-aiplatform-re.iam.gserviceaccount.com" \
--role="roles/viewer"
source ~/instavibe-bootstrap/env/bin/activate
export PLATFORM_MPC_CLIENT_URL=$(gcloud run services list --platform=managed --region=us-central1 --format='value(URL)' | grep platform-mcp-client)
export PLANNER_AGENT_URL=$(gcloud run services list --platform=managed --region=us-central1 --format='value(URL)' | grep planner-agent)
export SOCIAL_AGENT_URL=$(gcloud run services list --platform=managed --region=us-central1 --format='value(URL)' | grep social-agent)
export REMOTE_AGENT_ADDRESSES=${PLANNER_AGENT_URL},${PLATFORM_MPC_CLIENT_URL},${SOCIAL_AGENT_URL}
sed -i "s|^\(O\?REMOTE_AGENT_ADDRESSES\)=.*|REMOTE_AGENT_ADDRESSES=${REMOTE_AGENT_ADDRESSES}|" ~/instavibe-bootstrap/agents/orchestrate/.env
adk deploy agent_engine \
--display_name "orchestrate-agent" \
--project $GOOGLE_CLOUD_PROJECT \
--region $GOOGLE_CLOUD_LOCATION \
--staging_bucket gs://$GOOGLE_CLOUD_PROJECT-agent-engine \
--trace_to_cloud \
--requirements_file orchestrate/requirements.txt \
orchestrate
Now that the Orchestrator is hosted on the managed Agent Engine platform, our InstaVibe web application needs to communicate with it. Instead of interacting via ADK Dev UI, the web app will make remote calls to the Agent Engine endpoint.

First, we need to modify the InstaVibe application code to initialize the Agent Engine client using the unique ID of our deployed Orchestrator agent. This ID is required to target the correct agent instance on the platform.
👉📝 Open ~/instavibe-bootstrap/instavibe/introvertally.py and replace the #REPLACE ME initiate agent_engine with the following code. This retrieves the Agent Engine ID from an environment variable (which we'll set shortly) and gets a client object:
ORCHESTRATE_AGENT_ID = os.environ.get('ORCHESTRATE_AGENT_ID')
agent_engine = agent_engines.get(ORCHESTRATE_AGENT_ID)
Our planned user flow in InstaVibe involves two interactions with the agent: first, generating the recommended plan, and second, asking the user to confirm before the agent actually posts the event to the platform.
Since the InstaVibe web application (running on Cloud Run) and the Orchestrator agent (running on Agent Engine) are now separate services, the web app needs to make remote calls to the Agent Engine endpoint to interact with the agent.
👉📝 Let's update the code that makes the initial call to generate the plan recommendation. In the same introvertally.py file, replace the #REPLACE ME Query remote agent get plan with the following snippet, which uses the agent_engine client to send the user's request:
agent_engine.stream_query(
user_id=user_id,
message=prompt_message,
)
👉📝 Next, update the code that handles the user's confirmation (eg, when the user clicks "Confirm Plan"). This sends a follow-up message to the same conversation on Agent Engine, instructing the Orchestrator to proceed with posting the event (which it will delegate to the Platform Integration agent). Replace #REPLACE ME Query remote agent for confirmation for confirmation in introvertally.py with:
agent_engine.stream_query(
user_id=agent_session_user_id,
message=prompt_message,
)
The web application's routes need access to these functions. Ensure the necessary functions from introvertally.py are imported in the Flask routes file.
👉📝 In cd ~/instavibe-bootstrap/instavibe/ally_routes.py , we'll first point to the instance replace # REPLACE ME TO ADD IMPORT with following:
from introvertally import call_agent_for_plan, post_plan_event
👉📝 Add the prototype feature to InstaVibe, in ~/instavibe-bootstrap/instavibe/templates/base.html , replace <!–REPLACE_ME_LINK_TO_INTROVERT_ALLY–> with following:
<li class="nav-item">
<a class="nav-link" href="{{ url_for('ally.introvert_ally_page') }}">Introvert Ally</a>
</li>
Before we can redeploy the InstaVibe app, we need the specific Resource ID of the Orchestrator agent we deployed to Agent Engine.
Currently, retrieving this programmatically via gcloud might be limited, so we'll use a helper Python script ( temp-endpoint.py provided in the workshop) to fetch the ID and store it in an environment variable.
👉💻 Run the following commands to execute the script. The script will capture the Agent Engine Endpoint ID and grant the necessary permissions to the agent engine's default service account (Note: The script is configured to use the default service account as it is currently not user-modifiable).
. ~/instavibe-bootstrap/set_env.sh
cd ~/instavibe-bootstrap/instavibe/
source ~/instavibe-bootstrap/env/bin/activate
python temp-endpoint.py
export ORCHESTRATE_AGENT_ID=$(cat temp_endpoint.txt)
echo "ORCHESTRATE_AGENT_ID set to: ${ORCHESTRATE_AGENT_ID}"

Finally, we need to redeploy the InstaVibe web application with the updated code and the new ORCHESTRATE_AGENT_ID environment variable so it knows how to connect to our agent running on Agent Engine.
👉💻 The following commands rebuild the InstaVibe application image and deploy the new version to Cloud Run:
. ~/instavibe-bootstrap/set_env.sh
cd ~/instavibe-bootstrap/instavibe/
export IMAGE_TAG="latest"
export APP_FOLDER_NAME="instavibe"
export IMAGE_NAME="instavibe-webapp"
export IMAGE_PATH="${REGION}-docker.pkg.dev/${PROJECT_ID}/${REPO_NAME}/${IMAGE_NAME}:${IMAGE_TAG}"
export SERVICE_NAME="instavibe"
echo "Building ${APP_FOLDER_NAME} webapp image..."
gcloud builds submit . \
--tag=${IMAGE_PATH} \
--project=${PROJECT_ID}
echo "Deploying ${SERVICE_NAME} to Cloud Run..."
gcloud run deploy ${SERVICE_NAME} \
--image=${IMAGE_PATH} \
--platform=managed \
--region=${REGION} \
--allow-unauthenticated \
--set-env-vars="SPANNER_INSTANCE_ID=${SPANNER_INSTANCE_ID}" \
--set-env-vars="SPANNER_DATABASE_ID=${SPANNER_DATABASE_ID}" \
--set-env-vars="APP_HOST=0.0.0.0" \
--set-env-vars="APP_PORT=8080" \
--set-env-vars="GOOGLE_CLOUD_LOCATION=${REGION}" \
--set-env-vars="GOOGLE_CLOUD_PROJECT=${PROJECT_ID}" \
--set-env-vars="GOOGLE_MAPS_API_KEY=${GOOGLE_MAPS_API_KEY}" \
--set-env-vars="ORCHESTRATE_AGENT_ID=${ORCHESTRATE_AGENT_ID}" \
--project=${PROJECT_ID} \
--min-instances=1 \
--cpu=2 \
--memory=2Gi
With the final deployment complete, navigate to your InstaVibe application URL in a different browser tab.
Testing the Full AI-Powered InstaVibe Experience
The "InstaVibe Ally" feature is now live, powered by our multi-agent system orchestrated via Vertex AI Agent Engine and communicating through A2A.

Click into "InstaVibe Ally" and ask it to plan an event.

Observe the activity log on the right while the agents work (it may take 90-120 seconds). Once the plan appears, review it and click "Confirm This Plan" to proceed with posting.

The orchestrator will now instruct the Platform agent to create the post and event within InstaVibe. 
Check the InstaVibe home page for the new post and event. 
The event page will reflect the details generated by the agent.

Analyzing Performance with Cloud Trace
You might notice the process takes some time. Vertex AI Agent Engine integrates with Cloud Trace, allowing us to analyze the latency of our multi-agent system.
Go to the Traces in the google cloud console, select agent_run[orchestrate_agent] in the Span, you should see a couple of Spans, click into it

Within the trace details, you can identify which parts took longer. For example, calls to the Planner agent might show higher latency due to search grounding and complex generation. 
Similarly, when creating the post and event, you might see time spent by the Orchestrator processing data and preparing tool calls for the Platform agent. 
Exploring these traces helps understand and optimize the performance of your agent system.

Congratulations! You've successfully built, deployed, and tested a sophisticated multi-agent AI system using Google's ADK, A2A, MCP, and Google Cloud services. You've tackled agent orchestration, tool usage, state management, and cloud deployment, creating a functional AI-powered feature for InstaVibe. Well done on completing the workshop!
13. Clean Up
To avoid ongoing charges to your Google Cloud account, it's important to delete the resources we created during this workshop. The following commands will help you remove the Spanner instance, Cloud Run services, Artifact Registry repository, API Key, Vertex AI Agent Engine, and associated IAM permissions.
গুরুত্বপূর্ণ:
- Ensure you are running these commands in the same Google Cloud project used for the workshop.
- If you've closed your Cloud Shell terminal, some environment variables like $PROJECT_ID, $SPANNER_INSTANCE_ID, etc., might not be set. You'll need to either re-export them as you did during the workshop setup or replace the variables in the commands below with their actual values.
- These commands will permanently delete your resources. Double-check before running if you have other important data in this project.
👉💻 Run the following scripts to clean up.
Reset environment variables
. ~/instavibe-bootstrap/set_env.sh
Delete Agent Engine:
cd ~/instavibe-bootstrap/utils
source ~/instavibe-bootstrap/env/bin/activate
export ORCHESTRATE_AGENT_ID=$(cat ~/instavibe-bootstrap/instavibe/temp_endpoint.txt)
echo "ORCHESTRATE_AGENT_ID set to: ${ORCHESTRATE_AGENT_ID}"
python remote_delete.py
deactivate
echo "Vertex AI Agent Engine deletion initiated."
Delete Cloud Run Services:
# InstaVibe Web Application
gcloud run services delete instavibe --platform=managed --region=${REGION} --project=${PROJECT_ID} --quiet
# MCP Tool Server
gcloud run services delete mcp-tool-server --platform=managed --region=${REGION} --project=${PROJECT_ID} --quiet
# Planner Agent (A2A Server)
gcloud run services delete planner-agent --platform=managed --region=${REGION} --project=${PROJECT_ID} --quiet
# Platform MCP Client Agent (A2A Server)
gcloud run services delete platform-mcp-client --platform=managed --region=${REGION} --project=${PROJECT_ID} --quiet
# Social Agent (A2A Server)
gcloud run services delete social-agent --platform=managed --region=${REGION} --project=${PROJECT_ID} --quiet
echo "Cloud Run services deletion initiated."
Stop and Remove the A2A Inspector Docker Container
docker rm --force a2a-inspector
Delete Spanner Instance:
echo "Deleting Spanner instance: ${SPANNER_INSTANCE_ID}..."
gcloud spanner instances delete ${SPANNER_INSTANCE_ID} --project=${PROJECT_ID} --quiet
echo "Spanner instance deletion initiated."
Delete Artifact Registry Repository:
echo "Deleting Artifact Registry repository: ${REPO_NAME}..."
gcloud artifacts repositories delete ${REPO_NAME} --location=${REGION} --project=${PROJECT_ID} --quiet
echo "Artifact Registry repository deletion initiated."
Remove Roles from Service Account:
echo "Removing roles from service account: $SERVICE_ACCOUNT_NAME in project $PROJECT_ID"
# Remove Project-level roles for default service account
gcloud projects remove-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/spanner.admin"
gcloud projects remove-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/spanner.databaseUser"
gcloud projects remove-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/artifactregistry.admin"
gcloud projects remove-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/cloudbuild.builds.editor"
gcloud projects remove-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/run.admin"
gcloud projects remove-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/iam.serviceAccountUser"
gcloud projects remove-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/aiplatform.user"
gcloud projects remove-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/logging.logWriter"
gcloud projects remove-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:$SERVICE_ACCOUNT_NAME" \
--role="roles/logging.viewer"
echo "All specified roles have been removed."
Delete Local Workshop Files:
echo "Removing local workshop directory ~/instavibe-bootstrap..."
rm -rf ~/instavibe-bootstrap
rm -rf ~/a2a-inspector
rm -f ~/mapkey.txt
rm -f ~/project_id.txt
echo "Local directory removed."
