ข้ามไปยังเนื้อหา
Subagents เข้า Gemini CLI — แตก task ให้ specialized agent ทำคู่กับ orchestrator session หลัก
เครื่องมือนักพัฒนา

Subagents เข้า Gemini CLI — แตก task ให้ specialized agent ทำคู่กับ orchestrator session หลัก

อ่าน 4 นาที ที่มา: Google Developers Blog

Google for Developers ปล่อยบทความใน developers.googleblog.com แนะนำ subagents ใน Gemini CLI — feature ที่อนุญาตให้ Gemini CLI session หลัก delegate task ที่ซับซ้อน, ซ้ำ ๆ หรือ high-volume ไปยัง specialized expert agent ที่ run แยกได้

ในทางสถาปัตยกรรม session หลักทำหน้าที่เป็น strategic orchestrator ส่วน subagent ทำงานใน:

  • context window แยก ของตัวเอง
  • system instruction custom ตามบทบาท
  • set ของ tool ที่ตัด curate เฉพาะที่จำเป็น

ทำไมต้องมี subagent

ปัญหาที่ developer ที่ใช้ Gemini CLI ในงาน large-scale พบ:

  • Context contamination — ทำหลาย task ใน session เดียว → context window เต็มไปด้วย noise → quality ของ output ลดลง
  • Tool overload — Gemini CLI default มี tool หลายตัว (read_file, write_file, run_shell, web_fetch, search, etc.) → ทุก turn model ต้องเลือกจาก list ใหญ่ → cost token เพิ่ม + decision ผิดบ่อยขึ้น
  • Sequential bottleneck — งานที่ทำ parallel ได้ (เช่น analyze 50 file ในโครงสร้าง) ต้องทำ sequential ใน session เดียว

Subagent แก้ทั้ง 3:

  • แต่ละ subagent มี fresh context window → orchestrator คัดเฉพาะ summary กลับมา
  • subagent มี scoped tool list → decision space ลดลง → ไว้ขึ้น + ถูกขึ้น
  • หลาย subagent run parallel → throughput เพิ่ม linear

Built-in subagents

Gemini CLI ship พร้อม subagent default 2 ตัว:

1. generalist

  • general-purpose agent ที่มี access ทุก tool
  • ใช้สำหรับ task ที่ turn-intensive — เช่น batch refactor, run command ที่ output volume สูง
  • คล้าย general-purpose agent ใน Claude Code

2. codebase_investigator

  • specialized สำหรับ explore codebase
  • ใช้ tool: read_file, grep, list_directory + symbolic search
  • เหมาะกับ task: architectural mapping, root-cause analysis ของ bug ที่ cross-module, ทำความเข้าใจ system-wide dependency

Custom subagent — สร้างเองด้วย markdown

วิธี define custom subagent: สร้าง file ที่ .gemini/agents/<name>.md ใน project — Gemini CLI จะ pick up automatic

structure ของ file:

---
name: frontend-specialist
description: Expert in React, Next.js, and Tailwind. Use for UI tasks.
tools: [read_file, write_file, run_shell]
---

You are a senior frontend engineer specializing in React 19, Next.js 15, and Tailwind v4.
When given a UI task:
1. Read existing components first to match style.
2. Prefer composition over abstraction.
3. Use Tailwind utility classes over custom CSS.
...

หลัง create แล้ว developer สามารถ invoke ใน prompt: “use the frontend-specialist subagent to refactor this component” — orchestrator จะ delegate

ระบบนี้คล้ายกับ subagent ใน Claude Code (Anthropic ที่ ship feature นี้ก่อน) — Google รับ pattern มา + extend ให้ทำ parallel native

Parallel execution

ตัวอย่าง pattern ที่ Gemini CLI ทำได้แล้วแต่ Claude Code ยังจำกัด:

prompt: "Audit security across all 5 services in /services/*"

→ orchestrator แตกเป็น 5 subagent (security-auditor) parallel
  - subagent 1: services/auth
  - subagent 2: services/billing
  - subagent 3: services/notification
  - subagent 4: services/api-gateway
  - subagent 5: services/data
→ แต่ละตัวคืน finding ใน 30 วินาที
→ orchestrator merge result + output unified report ใน 35 วินาที total

เทียบกับ sequential ที่ใช้ ~150 วินาที (5 × 30s)

Bundle ใน extension

Subagent definition สามารถ bundle เป็นส่วนของ Gemini CLI extension ได้ — ทำให้ทีมหรือ open-source community แชร์ specialized agent ผ่าน extension marketplace แบบเดียวกับ VS Code extension

มุมมอง AI Curator

Subagents เป็น “inevitable feature” สำหรับ coding assistant ที่จะ scale — ผมจับตา 3 ประเด็น:

1. Convergence ของ agent UX กำลังเกิดขึ้น — Anthropic Claude Code ออก subagent ปลายปี 2025, OpenAI Codex CLI มี delegate pattern, Microsoft Foundry มี multi-agent workflow, ตอนนี้ Gemini CLI — ทุก stack มาบรรจบที่ pattern: strategic orchestrator + curated specialists — สิ่งที่จะ differentiate ต่อจากนี้คือ quality ของ built-in subagent (เช่น codebase_investigator ที่ Google ทำดี) และ ease of definition (markdown file vs. JSON config) — Google เลือก markdown ตาม Anthropic เป็นการยอม UX dominance

2. Tool curation = under-rated optimization — ส่วนใหญ่ developer คิดว่า “ใส่ tool ให้เยอะ ๆ ดี model จะเลือกเอง” — ในทางปฏิบัติ scope ของ tool ที่แคบลง = ราคาถูกขึ้น 30-50% + decision ตรงเป้า — pattern นี้จะกลายเป็น best practice ของ enterprise agent ในปีนี้

3. Markdown-as-config = win สำหรับ portability — agent definition ใน .md file แทน JSON/YAML กลายเป็น standard de facto — Anthropic เริ่ม, Google ตาม, ผมคาด Microsoft Foundry และ AWS Bedrock จะ accept markdown subagent file ในไม่กี่เดือนข้างหน้า — สำหรับ developer ไทย: เริ่มเขียน agent definition เป็น markdown ที่ portable ดีกว่าถูก lock-in กับ vendor-specific schema

บริบทไทย/SEA:

  • ทีม developer ไทยที่ใช้ Gemini CLI (free tier ของ Google ทำให้ adoption สูงในนิสิต/นักศึกษา) — feature นี้จะลด token cost ของ project ใหญ่ ๆ ลง 30-40% — ทำ AI-assisted thesis หรือ work project ในงบ student ได้ดีขึ้น
  • บริษัท IT services ของไทยที่ทำ outsource code review หรือ legacy migration — codebase_investigator subagent + custom subagent (เช่น cobol-modernizer, java-to-go-translator) จะลดเวลา discovery phase ลงครึ่งหนึ่ง
  • ตลาด localized subagent จะเปิด — เช่น “thai-content-writer” ที่ specialize SEO ไทย, “thai-legal-doc-analyzer” ที่อ่าน พ.ร.บ. — community ไทยน่าจะเริ่ม build extension ในช่วง 6 เดือนข้างหน้า

ที่ต้องตั้งคำถาม: subagent มี quality เท่าไหร่จริง? Google publish benchmark ว่า codebase_investigator beat baseline 22% ใน task root-cause analysis — แต่ benchmark เป็น Google internal — community ยังต้องการ open eval ที่เปรียบ subagent ของ Gemini CLI vs. Claude Code vs. Codex — ผมคาดว่าจะมี paper หรือ leaderboard ออกในเดือน พ.ค.-มิ.ย.

แหล่งข่าว

บทความนี้เรียบเรียงจากแหล่งข่าวต้นทาง — Google Developers Blog

เนื้อหาบน blog นี้สร้างโดย AI โดยมีการกำกับบรรณาธิการจากมนุษย์

อ่านเพิ่มในหมวด เครื่องมือนักพัฒนา

Betelgeuse รัน Qwen3.8 Flash Next ขนาด 68GB บน RTX 3060 กับแรม 16GB ส่วน Basalt วัดให้เห็นว่าเอนจินที่เร่งด้วยแฟล็กลัดทำให้โมเดลลืมของ
เครื่องมือนักพัฒนา

Betelgeuse รัน Qwen3.8 Flash Next ขนาด 68GB บน RTX 3060 กับแรม 16GB ส่วน Basalt วัดให้เห็นว่าเอนจินที่เร่งด้วยแฟล็กลัดทำให้โมเดลลืมของ

Betelgeuse ฟอร์ก llama.cpp ที่เปิดเมื่อ 31 ต.ค. ดึง expert จาก NVMe เข้า VRAM ตามต้องการ อ้าง 22 tok/s แบบไม่ทิ้ง expert แต่ README เตือนเองว่ายังทดลองและตัวเลขมาจากคนละรอบ วันเดียวกันผู้พัฒนา Basalt เผยผลวัดว่าแฟล็กเร่งความเร็วทำคุณภาพ Q8 ตกไปใกล้ Q2

· อ่าน 5 นาที
กฎห้ามโคลนเกมของ Claude Code เริ่มกระทบงานจริง บริษัทรับทำเกมกระดานร้องงานลูกค้าหยุด แต่รายงานหลายชิ้นปนกับตัวกรองไซเบอร์คนละเรื่อง
เครื่องมือนักพัฒนา

กฎห้ามโคลนเกมของ Claude Code เริ่มกระทบงานจริง บริษัทรับทำเกมกระดานร้องงานลูกค้าหยุด แต่รายงานหลายชิ้นปนกับตัวกรองไซเบอร์คนละเรื่อง

ต่อจากที่เราพบกฎนี้ในไบนารี Claude Code ผู้ใช้เริ่มรายงานว่างานเชิงพาณิชย์ถูกปฏิเสธ และ Tom's Hardware กับ Mashable หยิบไปรายงาน แต่เมื่อไล่ issue ที่อ้างถึง พบว่าหลายรายการเกิดก่อนกฎจะมา จึงน่าจะเป็นตัวกรองด้านไซเบอร์ ส่วน Anthropic ยังไม่ชี้แจง

· อ่าน 4 นาที
Claude Code ส่ง transcript ของ background agent ให้โมเดลทุก ~30 วินาทีเพื่อเขียนสถานะ 3–5 คำ ผู้วัดรายงานกินราว 16% และยังปิดแบบทางการไม่ได้
เครื่องมือนักพัฒนา

Claude Code ส่ง transcript ของ background agent ให้โมเดลทุก ~30 วินาทีเพื่อเขียนสถานะ 3–5 คำ ผู้วัดรายงานกินราว 16% และยังปิดแบบทางการไม่ได้

รายงานอิสระพบว่าฟีเจอร์ agent_summary ของ Claude Code ส่ง transcript เต็มของ background agent ไปถามสถานะทุก ~30 วินาที คิดเป็น 16.4% ของค่าใช้จ่ายในระบบของผู้วัด Issue เปิดมาตั้งแต่ ส.ค. ยังไม่มีสวิตช์ปิดที่รองรับ เราตรวจพบโค้ดนี้ใน 2.1.314 และพบกฎใหม่เรื่องเกมที่ไม่อยู่ใน changelog

· อ่าน 4 นาที