- Gemini CLI ने आधिकारिक तौर पर multi-agent architecture को सपोर्ट करना शुरू कर दिया है, जिससे जटिल और दोहराए जाने वाले काम विशेषज्ञ sub-agent को सौंपे जा सकते हैं
- हर sub-agent स्वतंत्र context window, custom system instructions और dedicated tool set के साथ isolated environment में चलता है
- Markdown फ़ाइलों और YAML frontmatter के ज़रिए custom sub-agent परिभाषित किए जा सकते हैं, और उन्हें global या project level पर टीम के साथ साझा किया जा सकता है
- कई sub-agent को parallel में चलाया जा सकता है, जिससे research, refactoring जैसे कई कामों का कुल समय काफ़ी घट जाता है
- built-in agent (generalist, cli_help, codebase_investigator) के साथ @agent syntax से explicit task delegation संभव है, जिससे CLI-आधारित development workflow की scalability बढ़ती है
sub-agent की अवधारणा और मुख्य फ़ायदे
- sub-agent ऐसे विशेषज्ञ agent हैं जो मुख्य Gemini CLI session के साथ काम करते हैं। जब कोई जटिल काम मिलता है, तो Gemini CLI एक strategic orchestrator की तरह काम करके सबसे उपयुक्त sub-agent को sub-task सौंपता है
- हर sub-agent के पास अपने tools, MCP server, system instructions और context window होते हैं, और वह पूरी तरह isolated स्थिति में चलता है
- sub-agent का पूरा execution, जिसमें दर्जनों tool calls, file search और test execution शामिल हो सकते हैं, एक single response में समेकित होकर main agent को वापस मिलता है
- इससे main context window भरने से बचती है और आगे की interaction की speed तथा cost efficiency बनी रहती है
- तीन मुख्य फ़ायदे:
- base agent overall goal, decision-making और final response पर फोकस कर सकता है
- research, code exploration, analysis और testing जैसे कामों के लिए विशेषज्ञ sub-agent को parallel में चलाकर गति बढ़ाई जा सकती है
- sub-agent summary या formatted response लौटाते हैं, जिससे base session में context rot और context pollution से बचाव होता है
custom sub-agent बनाना
- Markdown फ़ाइल (
.md) में YAML frontmatter का उपयोग करके custom sub-agent परिभाषित किए जाते हैं
~/.gemini/agents में रखने पर वे व्यक्तिगत workflow के लिए global agent बन जाते हैं, और repository की .gemini/agents में commit करने पर उन्हें project level पर टीम के साथ साझा किया जा सकता है
- Gemini CLI extensions की
agents/ directory में agent definition files शामिल करके उन्हें extension के हिस्से के रूप में bundle भी किया जा सकता है
- उदाहरण में दिए गए
frontend-specialist agent की configuration:
- frontmatter में
name, description, tools(read_file, grep_search, glob, list_directory, web_fetch, google_web_search), model: inherit आदि परिभाषित हैं
- system instructions में Senior Frontend Specialist और UI/UX Architect की भूमिका दी गई है
- core principles के रूप में modular architecture design, Core Web Vitals आधारित performance optimization, और WCAG 2.1+ accessibility compliance शामिल हैं
- guideline में browser native API को प्राथमिकता, Atomic component design, state के अनुसार visual feedback (loading, skeleton, error, empty state, success), Progressive Enhancement, और maintainability-केंद्रित design शामिल हैं
- इस agent की भूमिका analysis और improvement suggestions तक सीमित है, और यह सीधे code में बदलाव नहीं करता
- फ़ाइल को
.gemini/agents/frontend-specialist.md में रखते ही Gemini CLI इसे तुरंत नए विशेषज्ञ के रूप में पहचान लेता है
parallel execution
- Gemini CLI parallel sub-agent execution को सपोर्ट करता है, जिससे कई sub-agent या एक ही sub-agent की कई instances को एक साथ चलाया जा सकता है
- जब 5 अलग-अलग विषयों पर research करनी हो या कई components को refactor करना हो, तब कई agent को एक साथ dispatch करके कुल समय काफ़ी कम किया जा सकता है
- explicit request का उदाहरण: "Run the frontend-specialist on each package in parallel."
- ध्यान देने योग्य बातें:
- बड़े code editing tasks में parallel sub-agent का उपयोग करने पर conflicts और agents के बीच code overwrite होने का जोखिम है
- parallel execution में request एक साथ भेजे जाते हैं, इसलिए usage limits जल्दी पहुँच सकते हैं
built-in sub-agent और उनका उपयोग
- Gemini CLI में डिफ़ॉल्ट रूप से शामिल तीन sub-agent:
- generalist: सभी tools तक पहुँच वाला general-purpose agent, जो batch refactoring या बड़े output वाले commands जैसे turn-intensive कामों के लिए उपयुक्त है (यह सामान्य Gemini CLI agent की sub-agent copy जैसा है)
- cli_help: Gemini CLI का विशेषज्ञ agent, जो Gemini CLI documentation तक सीधे पहुँचकर फीचर-संबंधी सवालों के जवाब देता है
- codebase_investigator: codebase exploration, architecture mapping, bug के root cause analysis, और पूरे system की dependencies समझने में विशेषज्ञ
- Gemini CLI sub-agent के description के आधार पर automatic routing करता है, लेकिन @agent syntax के ज़रिए किसी खास agent को explicit रूप से task दिया जा सकता है
- उदाहरण:
@frontend-specialist से app review और improvement points flag करने का अनुरोध
- उदाहरण:
@generalist से पूरे project में license header update कराना
- उदाहरण:
@codebase_investigator से authentication flow map कराना
- @ चिन्ह के बाद sub-agent का नाम लिखने पर काम उसी agent की isolated context window के भीतर किया जाता है
- अभी configured सभी sub-agent देखने के लिए Gemini CLI में
/agents command चलाएँ
अभी कोई टिप्पणी नहीं है.