कोडिंग हार्नेस (CodingAgent)
CodingAgent एक पतला हार्नेस है — जो adk-agent में coding फीचर के पीछे शिप किया गया है — जो dev tools, एक योजना write_todos टूल, और एक न्यूनतम कोडिंग सिस्टम प्रॉम्प्ट को एक सामान्य LlmAgent पर जोड़ता है। यह configuration over LlmAgent है, कोई नया एजेंट टाइप नहीं, इसलिए यह डिफ़ॉल्ट adk-agent बिल्ड को हल्का रखता है (यह फीचर adk-devtools को शामिल करता है)।
एक बनाएं
use adk_agent::coding::CodingAgent;
use adk_devtools::Workspace;
let coding = CodingAgent::builder()
.model(model) // any adk-model provider (required)
.workspace(Workspace::new("./my-repo")) // sandboxed (required)
.instruction("Follow the project's existing style; prefer small diffs.") // optional, appended
.build()?;
let agent = coding.agent(); // Arc<dyn Agent> — hand to a Runner
बिल्ड विकल्प:
| विधि | प्रभाव |
|---|---|
.model(Arc<dyn Llm>) | मॉडल (आवश्यक)। |
.workspace(Workspace) | वह कार्यक्षेत्र जिसमें टूल सीमित हैं (आवश्यक)। |
.name("…") | एजेंट का नाम (डिफ़ॉल्ट "coding-agent"). |
.instruction("…") | आधार कोडिंग प्रॉम्प्ट में जोड़ा गया अतिरिक्त मार्गदर्शन। |
.tool(Arc<dyn Tool>) | एक अतिरिक्त टूल पंजीकृत करें (MCP, फ़ंक्शन टूल, …)। |
.without_todos() | write_todos योजना टूल को अक्षम करें। |
क्या वायर किया गया है
-
डेव टूलसेट — read/write/edit/glob/grep/bash, workspace तक सीमित।
-
write_todos— एक planning tool जिसका उपयोग model एक छोटी task list को रिकॉर्ड और अपडेट करने के लिए करता है। इसे harness से वापस पढ़ें:for todo in coding.todos() { println!("[{}] {}", todo.status, todo.content); // pending | in_progress | completed } -
एक minimal prompt — sub-1k-token base instructions ("explore before you change", "read before you edit", "verify by running tests", "track a plan"), जानबूझकर छोटा रखा गया है ताकि capabilities बड़े prompt के बजाय tools और skills से आएँ।
लूप
आप एक CodingAgent को किसी भी agent की तरह चलाते हैं — एक Runner के माध्यम से। एक turn के भीतर underlying LlmAgent पहले से ही plan → act → observe loop निष्पादित करता है: यह tools को कॉल करता है, उनके परिणाम देखता है, और तब तक जारी रहता है जब तक काम पूरा न हो जाए। एक सामान्य turn:
write_todos(...) # plan
glob / grep / read_file # explore
edit_file / write_file # change
bash("…test…") # verify
write_todos(... completed) # update plan
→ final summary
multi-turn काम के लिए, calls के बीच वही Runner + session पुनः उपयोग करें और agent अपनी पिछली work पर आधारित आगे बढ़ता है (यह अपने द्वारा लिखी गई files को फिर से पढ़ता और edit करता है)। coding_agent example देखें (multiturn mode)।
मेमोरी और skills
क्योंकि यह नीचे LlmAgent है, इसलिए ADK में बाकी सब कुछ एक साथ compose होता है:
- cross-session project memory के लिए
Runnerपर एकMemoryService(उदा. bi-temporal knowledge graph) attach करें। - prompt को फुलाए बिना capabilities बढ़ाने के लिए
adk-skillके माध्यम से lazy skills जोड़ें। - Hooks/guardrails (
adk-plugin,adk-guardrail) tool calls को deterministically gate करते हैं।
इसे चलाना
हarness एक Arc<dyn Agent> बनाता है; इसे adk-runner से चलाएँ (देखें quick start) या CLI का उपयोग करें, जो यह सब wrap करता है।
आगे: The CLI →