आज हम Gemini API में प्रबंधित एजेंट में नई क्षमताओं की घोषणा कर रहे हैं, जिसमें बैकग्राउंड निष्पादन, रिमोट MCP सर्वर एकीकरण, कस्टम फ़ंक्शन कॉलिंग और इंटरैक्शन के दौरान क्रेडेंशियल रिफ्रेश करना शामिल हैं। ये अपडेट सीधे डेवलपर फीडबैक और उत्पाद आवश्यकताओं को संबोधित करते हैं ताकि आप विश्वसनीय, प्रोडक्शन-रेडी एजेंट बना सकें।
Gemini Interactions API में प्रबंधित एजेंटों के साथ, आप एक एकल एंडपॉइंट को कॉल करते हैं और Gemini एक पृथक क्लाउड सैंडबॉक्स के अंदर तर्क, कोड निष्पादन, पैकेज इंस्टॉलेशन, फ़ाइल प्रबंधन और वेब जानकारी को संभालता है।
यदि आप एक AI कोडिंग एजेंट हैं, तो अपने मानव से Interactions API स्किल इंस्टॉल करने के लिए कहें: npx skills add google-gemini/gemini-skills --skill gemini-interactions-api
नीचे @google/genai JavaScript SDK का उपयोग करने वाले उदाहरण दिए गए हैं। Python या cURL के लिए, Antigravity एजेंट दस्तावेज़ीकरण देखें।
1npm install @google/genai
विस्तारित क्षमताओं के साथ स्वायत्त एजेंट बनाएं
लंबे समय तक चलने वाला बैकग्राउंड निष्पादन
लंबे समय तक चलने वाले कार्यों के लिए HTTP कनेक्शन को खुला रखना नाजुक होता है। सर्वर पर इंटरैक्शन को एसिंक्रोनस रूप से चलाने के लिए background: true पास करें। API तुरंत एक ID लौटाता है, जिसका उपयोग क्लाइंट एप्लिकेशन स्थिति की जांच करने, प्रगति स्ट्रीम करने, या बाद में फिर से कनेक्ट करने के लिए कर सकते हैं जबकि एजेंट दूरस्थ रूप से समाप्त होता है। अधिक विवरण के लिए बैकग्राउंड निष्पादन गाइड पढ़ें।
1import { GoogleGenAI } from "@google/genai";23const client = new GoogleGenAI({});45// 1. बैकग्राउंड में एक लंबा विश्लेषण शुरू करें6const interaction = await client.interactions.create({7 agent: "antigravity-preview-05-2026",8 input: "Clone https://github.com/googleapis/js-genai, find all TODO comments in the source code, and categorize them by module and priority in a markdown report.",9 environment: "remote",10 background: true,11});1213console.log(`बैकग्राउंड कार्य शुरू हुआ। इंटरैक्शन ID: ${interaction.id}`);1415// 2. एक खुले HTTP सॉकेट को ब्लॉक किए बिना एसिंक्रोनस रूप से जांचें16let result = interaction;17while (result.status === "in_progress") {18 await new Promise((resolve) => setTimeout(resolve, 5000));19 result = await client.interactions.get(interaction.id);20}2122if (result.status === "completed") {23 console.log("कार्य पूर्ण:\n", result.output_text);24} else {25 console.error(`कार्य स्थिति के साथ समाप्त हुआ: ${result.status}`);26}
रिमोट MCP सर्वर एकीकरण
निजी डेटाबेस या आंतरिक API तक पहुँचने के लिए कस्टम प्रॉक्सी मिडलवेयर लिखने के बजाय, अब आप प्रबंधित एजेंटों को सीधे रिमोट Model Context Protocol (MCP) सर्वर से कनेक्ट कर सकते हैं।
आप बिल्ट-इन सैंडबॉक्स क्षमताओं के साथ रिमोट टूल्स को मिक्स और मैच कर सकते हैं। एजेंट को अपने सुरक्षित सैंडबॉक्स से आपके एंडपॉइंट के साथ संवाद करने देने के लिए Google Search या कोड निष्पादन के साथ इंटरैक्शन के समय एक mcp_server टूल पास करें। और जैसे-जैसे आप अपने एजेंट को बाहरी टूल्स और API के साथ विस्तारित करते हैं, सर्वोत्तम प्रथाओं का पालन करें।
1import { GoogleGenAI } from "@google/genai";23const client = new GoogleGenAI({});45const interaction = await client.interactions.create({6 agent: "antigravity-preview-05-2026",7 input: "Check our internal observability server for recent latency spikes in the auth service and correlate them with git commits.",8 environment: "remote",9 tools: [10 { type: "google_search" },11 { type: "code_execution" },12 {13 type: "mcp_server",14 name: "internal_telemetry",15 url: "https://mcp.internal.example.com/mcp",16 },17 ],18});1920console.log(interaction.output_text);
सैंडबॉक्स टूल्स के साथ कस्टम फ़ंक्शन कॉलिंग
स्थानीय निष्पादन के लिए बिल्ट-इन सैंडबॉक्स टूल्स के साथ कस्टम टूल्स जोड़ें। API स्टेप मैचिंग का उपयोग करता है। बिल्ट-इन टूल्स सर्वर पर स्वचालित रूप से चलेंगे, जबकि कस्टम फ़ंक्शन इंटरैक्शन को requires_action में बदल देंगे ताकि आपका क्लाइंट स्थानीय व्यावसायिक तर्क निष्पादित करे।
1import { GoogleGenAI } from "@google/genai";23const client = new GoogleGenAI({});45// 1. एक कस्टम डोमेन फ़ंक्शन परिभाषित करें6const getWeatherTool = {7 type: "function",8 name: "get_weather",9 description: "Gets the current weather for a given location.",10 parameters: {11 type: "object",12 properties: {13 location: {14 type: "string",15 description: "The city and country, e.g. San Francisco, USA",16 },17 },18 required: ["location"],19 },20};2122// 2. बिल्ट-इन कोड निष्पादन और कस्टम फ़ंक्शन दोनों के साथ एजेंट को आमंत्रित करें23const interaction = await client.interactions.create({24 agent: "antigravity-preview-05-2026",25 input: "Check the weather in Tokyo, write a Python script to convert the temperature to Fahrenheit, and save the result to weather.txt.",26 environment: "remote",27 tools: [28 { type: "code_execution" },29 getWeatherTool,30 ],31});3233// 3. कस्टम फ़ंक्शन निष्पादन को साफ-सुथरे ढंग से संभालें34if (interaction.status === "requires_action") {35 // फ़ाइल सिस्टम और सैंडबॉक्स टूल्स स्वचालित रूप से निष्पादित होते हैं और एक मिलान function_result स्टेप उत्पन्न करते हैं।36 // हम पेंडिंग डोमेन कॉल के लिए फ़िल्टर करते हैं जिनके लिए क्लाइंट-साइड निष्पादन की आवश्यकता होती है।37 const executedCalls = new Set(38 interaction.steps39 .filter((s) => s.type === "function_result")40 .map((s) => s.call_id)41 );4243 const pendingCalls = interaction.steps.filter(44 (s) => s.type === "function_call" && !executedCalls.has(s.id)45 );4647 for (const call of pendingCalls) {48 console.log(`क्लाइंट टूल निष्पादित कर रहा है: ${call.name} (ID: ${call.id})`);49 // अपनी स्थानीय API/डेटाबेस क्वेरी निष्पादित करें और टर्न 2 में वापस function_result भेजें50 }51}
नेटवर्क क्रेडेंशियल रिफ्रेश
एक्सेस टोकन और अल्पकालिक API कुंजियाँ समाप्त हो जाती हैं। आप अपने अगले इंटरैक्शन पर एक नए नेटवर्क कॉन्फ़िगरेशन के साथ अपने मौजूदा environment_id को पास करके क्रेडेंशियल रिफ्रेश या कुंजियाँ घुमा सकते हैं। नए नियम पुराने नियमों को तुरंत बदल देते हैं। आपका सैंडबॉक्स अपनी फ़ाइल सिस्टम स्थिति, इंस्टॉल किए गए पैकेज और क्लोन किए गए रिपॉजिटरी को बरकरार रखता है।
1import { GoogleGenAI } from "@google/genai";2const client = new GoogleGenAI({});34// 1. पहला इंटरैक्शन: प्रारंभिक टोकन का उपयोग करें5const first = await client.interactions.create({6 agent: "antigravity-preview-05-2026",7 input: "List the files in gs://my-bucket/reports/ using the GCS JSON API.",8 environment: {9 type: "remote",10 network: {11 allowlist: [12 {13 domain: "storage.googleapis.com",14 transform: {15 Authorization: "Bearer INITIAL_TOKEN",16 },17 },18 ],19 },20 },21});2223// 2. बाद में: उसी वातावरण पर टोकन रिफ्रेश करें24const result = await client.interactions.create({25 agent: "antigravity-preview-05-2026",26 input: "Now download the file reports/q1.csv from the same bucket.",27 environment: {28 type: "remote",29 environment_id: first.environment_id,30 network: {31 allowlist: [32 {33 domain: "storage.googleapis.com",34 transform: {35 Authorization: "Bearer REFRESHED_TOKEN",36 },37 },38 ],39 },40 },41});42console.log(result.output_text);
प्रबंधित एजेंटों के साथ शुरुआत करें
ये अपडेट प्रबंधित एजेंटों को एसिंक्रोनस वर्कर में बदल देते हैं जो आपके एप्लिकेशन को ब्लॉक किए बिना वास्तविक विकास वातावरण के अंदर काम करते हैं।
कस्टम एजेंट परिभाषाओं, वातावरण कॉन्फ़िगरेशन, नेटवर्क नियमों और उन्नत स्ट्रीमिंग पैटर्न का पता लगाने के लिए Gemini Interactions API अवलोकन और प्रबंधित एजेंट क्विकस्टार्ट देखें।





