I would like to review the following points on the current PR (this branch vs main). Spawn one agent per point, wait for all of them, and summarize the result for each point.
- Security issue
- Code quality
- Bugs
- Race conditions
- Test flakiness
- Maintainability of the code
ในสถานการณ์นี้ Codex น่าจะเปิดใช้งาน subagents หกตัวที่แตกต่างกัน โดยแต่ละตัวจะเชี่ยวชาญในประเด็นการตรวจสอบที่ระบุไว้ หลังจากที่แต่ละเอเจนต์ทำการวิเคราะห์เสร็จสิ้น Codex จะรวบรวมผลการค้นหาเป็นรายงานเดียวที่มีโครงสร้าง ให้ภาพรวมที่ครอบคลุมของการร้องขอแบบดึง (pull request) ซึ่งแสดงให้เห็นถึงประสิทธิภาพที่ได้รับจากการกระจายภาระงานในหมู่เอนทิตี AI เฉพาะทาง
## การจัดการและรักษาความปลอดภัยระบบนิเวศ Subagent ของคุณ
การจัดการที่มีประสิทธิภาพและความปลอดภัยที่แข็งแกร่งเป็นข้อพิจารณาหลักเมื่อทำงานกับ subagents Codex มีเครื่องมือและกลไกในการกำกับดูแลกิจกรรมของ subagent และรับประกันการทำงานที่ปลอดภัยภายในสภาพแวดล้อม sandboxed ของพวกมัน
ในเซสชัน CLI แบบโต้ตอบ นักพัฒนาสามารถใช้คำสั่ง `/agent` เพื่อสลับระหว่างเธรดเอเจนต์ที่ใช้งานอยู่ ตรวจสอบกระบวนการที่กำลังดำเนินอยู่ หรือควบคุม subagent เฉพาะ การควบคุมที่ละเอียดนี้ช่วยให้สามารถปรับเปลี่ยนและตรวจสอบความคืบหน้าของเอเจนต์แต่ละตัวได้แบบเรียลไทม์ คุณยังสามารถขอให้ Codex หยุด subagent ที่กำลังทำงานอยู่ หรือปิดเธรดที่เสร็จสมบูรณ์เพื่อจัดการทรัพยากรและมุ่งเน้นได้
ความปลอดภัยเป็นสิ่งสำคัญยิ่ง และ subagents จะรับนโยบาย Sandbox ปัจจุบันจากเซสชัน Codex หลัก สิ่งนี้ทำให้มั่นใจว่าการทำงานของพวกมันเป็นไปตามกฎความปลอดภัยและการเข้าถึงที่กำหนดไว้ล่วงหน้า เมื่อคำขออนุมัติเกิดขึ้นจากเธรดเอเจนต์ที่ไม่ได้ใช้งาน โดยเฉพาะอย่างยิ่งในเซสชัน CLI แบบโต้ตอบ Codex จะแสดงสิ่งเหล่านี้ต่อผู้ใช้อย่างชาญฉลาด หน้าต่างอนุมัติจะระบุเธรดต้นทาง ทำให้คุณสามารถกด 'o' เพื่อเปิดและตรวจสอบเธรดนั้นก่อนที่จะตัดสินใจอย่างมีข้อมูลเพื่ออนุมัติ ปฏิเสธ หรือตอบรับคำขอ สิ่งนี้ช่วยป้องกันการอนุมัติแบบไม่รู้เรื่องและรักษาการกำกับดูแลของนักพัฒนา
สำหรับการทำงานที่ไม่โต้ตอบหรือสถานการณ์ที่ไม่สามารถแสดงการอนุมัติใหม่ได้ การดำเนินการใดๆ ที่ต้องมีการอนุมัติใหม่จะล้มเหลวโดยอัตโนมัติ โดย Codex จะรายงานข้อผิดพลาดกลับไปยังเวิร์กโฟลว์หลัก กลไกป้องกันความผิดพลาดนี้ช่วยป้องกันการดำเนินการที่ไม่ได้รับอนุญาตในบริบทอัตโนมัติ ยิ่งไปกว่านั้น Codex ยังนำการแทนที่รันไทม์แบบสดของเซสชันหลักกลับมาใช้ซ้ำ—เช่น การเปลี่ยนแปลงที่ทำผ่าน `/approvals` หรือแฟล็ก `--yolo`—กับเอเจนต์ย่อยที่สร้างขึ้น เพื่อให้มั่นใจถึงท่าทีด้านความปลอดภัยที่สอดคล้องกันตลอดลำดับชั้นของเอเจนต์ สำหรับผู้ใช้ขั้นสูง ยังสามารถแทนที่การกำหนดค่า Sandbox สำหรับ [เอเจนต์ที่กำหนดเอง](#defining-custom-subagents-for-tailored-tasks) แต่ละตัวได้ ทำให้สามารถควบคุมสิทธิ์ของพวกมันได้อย่างละเอียด ตัวอย่างเช่น โดยการทำเครื่องหมายเอเจนต์ว่าเป็น 'อ่านอย่างเดียว'
## การกำหนด Subagent ที่กำหนดเองสำหรับงานที่ปรับแต่งเป็นพิเศษ
แม้ว่า Codex จะมีเอเจนต์ในตัวหลายตัว เช่น `default` สำหรับวัตถุประสงค์ทั่วไป `worker` สำหรับงานที่เน้นการดำเนินการ และ `explorer` สำหรับการสำรวจโค้ดเบสที่เน้นการอ่าน แต่พลังที่แท้จริงของระบบ subagent อยู่ที่ความสามารถในการขยาย นักพัฒนาสามารถกำหนด **เอเจนต์ที่กำหนดเอง** ของตนเองเพื่อตอบสนองความต้องการเฉพาะทางสูง ปรับแต่งพฤติกรรม AI ให้เข้ากับบริบทโครงการที่ไม่เหมือนใคร
เอเจนต์ที่กำหนดเองถูกกำหนดโดยใช้ไฟล์ TOML แบบสแตนด์อโลน ไฟล์เหล่านี้สามารถวางไว้ใน `~/.codex/agents/` สำหรับเอเจนต์ส่วนบุคคล หรือ `.codex/agents/` สำหรับเอเจนต์ที่อยู่ในขอบเขตของโครงการ ไฟล์ TOML แต่ละไฟล์จะทำหน้าที่เป็นชั้นการกำหนดค่า ทำให้นักพัฒนาสามารถแทนที่การตั้งค่าที่มิฉะนั้นจะสืบทอดมาจากเซสชันหลัก ซึ่งรวมถึงพารามิเตอร์ที่สำคัญ เช่น โมเดล AI ที่ใช้ ความพยายามในการให้เหตุผล โหมด Sandbox และแม้แต่การกำหนดค่าทักษะเฉพาะ
ทุกไฟล์เอเจนต์ที่กำหนดเองแบบสแตนด์อโลน *ต้อง* กำหนดฟิลด์ต่อไปนี้:
* **`name`**: ตัวระบุเฉพาะของเอเจนต์ ซึ่ง Codex ใช้เมื่อสร้างหรืออ้างอิงถึงมัน
* **`description`**: คำแนะนำที่มนุษย์อ่านได้ ซึ่งช่วยให้ Codex เข้าใจว่าจะปรับใช้เอเจนต์นี้เมื่อใด
* **`developer_instructions`**: ชุดคำแนะนำหลักที่กำหนดพฤติกรรมและตรรกะการทำงานของเอเจนต์
ฟิลด์เสริมเช่น `nickname_candidates`, `model`, `model_reasoning_effort`, `sandbox_mode`, `mcp_servers` และ `skills.config` สามารถรวมอยู่ได้เช่นกัน หากละเว้น การตั้งค่าเหล่านี้จะสืบทอดมาจากเซสชันหลัก ซึ่งช่วยให้การกำหนดค่าง่ายขึ้นในกรณีที่ค่าเริ่มต้นเป็นที่ยอมรับได้ สำหรับแนวทางปฏิบัติที่ดีที่สุดในการออกแบบพรอมต์ ซึ่งส่งผลโดยตรงต่อคำแนะนำของเอเจนต์ โปรดดูแหล่งข้อมูลเช่น [คู่มือการแจ้งพรอมต์ Codex](/th/codex-prompting-guide)
ฟิลด์ `name` เป็นตัวระบุที่ชัดเจนสำหรับเอเจนต์ที่กำหนดเอง แม้ว่าการจับคู่ชื่อไฟล์กับชื่อเอเจนต์จะเป็นธรรมเนียมปฏิบัติที่พบเห็นได้ทั่วไปและแนะนำ แต่ฟิลด์ `name` ภายในไฟล์ TOML เป็นแหล่งที่มาของความจริงสูงสุด ฟิลด์ `nickname_candidates` เป็นส่วนเสริมที่มีประโยชน์สำหรับประสบการณ์ผู้ใช้ ทำให้ Codex สามารถกำหนดชื่อที่แสดงผลได้อ่านง่ายขึ้นให้กับเอเจนต์ที่สร้างขึ้น ซึ่งมีประโยชน์อย่างยิ่งในสถานการณ์ที่มีหลายเอเจนต์ที่ซับซ้อน
## การตั้งค่าส่วนกลางและการกำหนดค่า Subagent ขั้นสูง
นอกเหนือจากการกำหนดเอเจนต์ที่กำหนดเองแต่ละตัวแล้ว Codex ยังมีการตั้งค่าการกำหนดค่าส่วนกลางเพื่อจัดการพฤติกรรมโดยรวมของเวิร์กโฟลว์ subagent การตั้งค่าเหล่านี้มักจะอยู่ภายใต้ส่วน `[agents]` ในไฟล์การกำหนดค่าหลักของคุณ ซึ่งให้การควบคุมแบบรวมศูนย์ในการจัดสรรทรัพยากรและพารามิเตอร์การทำงาน
นี่คือรายละเอียดการตั้งค่า subagent ส่วนกลางที่สำคัญ:
| ฟิลด์ | ประเภท | จำเป็น | วัตถุประสงค์ |
| :--------------------------- | :----- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `agents.max_threads` | number | ไม่ | จำกัดจำนวนเธรดเอเจนต์ที่เปิดพร้อมกัน ค่าเริ่มต้นคือ `6` หากไม่ได้ตั้งค่า |
| `agents.max_depth` | number | ไม่ | จำกัดความลึกของการซ้อนของเอเจนต์ที่สร้างขึ้น (เซสชันรากเริ่มต้นที่ 0) ค่าเริ่มต้นคือ `1` ป้องกันการมอบหมายแบบเรียกซ้ำเกินกว่าเอเจนต์ลูกโดยตรง เพื่อจัดการการใช้โทเค็นและเวลาแฝง |
| `agents.job_max_runtime_seconds` | number | ไม่ | กำหนดระยะเวลาหมดเวลาเริ่มต้นต่อ worker สำหรับงาน `spawn_agents_on_csv` หากไม่ได้ตั้งค่า ค่าเริ่มต้นคือ `1800` วินาที (30 นาที) |
การตั้งค่า `agents.max_threads` ซึ่งมีค่าเริ่มต้นเป็น `6` เป็นการป้องกันการใช้ทรัพยากรที่มากเกินไปโดยการจำกัดจำนวน subagents ที่สามารถทำงานพร้อมกันได้ การตั้งค่า `agents.max_depth` ซึ่งมีค่าเริ่มต้นเป็น `1` มีความสำคัญเป็นพิเศษ แม้ว่าการซ้อนที่ลึกขึ้นอาจดูน่าดึงดูดใจสำหรับการมอบหมายงานที่ซับซ้อน แต่การเพิ่มค่านี้อาจนำไปสู่การเพิ่มขึ้นอย่างมากในการใช้โทเค็น เวลาแฝง และการใช้ทรัพยากรในเครื่อง เนื่องจากการขยายงานแบบ fan-out ซ้ำๆ โดยทั่วไปแนะนำให้รักษาค่าเริ่มต้นไว้ เว้นแต่ว่ารูปแบบการมอบหมายงานแบบเรียกซ้ำที่เฉพาะเจาะจงมีความจำเป็นอย่างยิ่งและได้รับการจัดการอย่างระมัดระวัง
ไฟล์เอเจนต์ที่กำหนดเองยังสามารถรวมคีย์ `config.toml` ที่รองรับอื่นๆ ได้ ซึ่งขยายความสามารถในการกำหนดค่าได้มากกว่าแค่ฟิลด์บังคับ แนวทางการกำหนดค่าแบบโมดูลาร์และหลายชั้นนี้ช่วยให้นักพัฒนาสามารถควบคุมเอเจนต์ AI ของตนได้อย่างละเอียด ทำให้พวกเขาสามารถปรับปรุงประสิทธิภาพ ต้นทุน และความปลอดภัยให้เหมาะสมกับความต้องการในการพัฒนาเฉพาะของตนเองได้ ด้วยการทำความเข้าใจและใช้ประโยชน์จากความสามารถของ subagent ที่ทรงพลังเหล่านี้ นักพัฒนาสามารถผลักดันขีดจำกัดของการเขียนโค้ดที่ขับเคลื่อนด้วย AI และเพิ่มประสิทธิภาพเวิร์กโฟลว์การพัฒนาของตนได้อย่างมาก
คำถามที่พบบ่อย
What are Codex subagents and how do they enhance AI development workflows?
Codex subagents are specialized AI agents that can be spawned in parallel by a primary Codex instance to tackle complex, multi-faceted tasks. They significantly enhance AI development workflows by enabling the division of labor across different agents, each focusing on a specific aspect of a task. This parallel processing capability is particularly beneficial for computationally intensive or intricate operations like comprehensive codebase exploration, implementing large-scale multi-step feature plans, or conducting extensive code reviews. By distributing the workload, subagents help in accelerating development cycles, improving the quality of outputs, and managing complexity more effectively than a single agent could.
How does Codex manage the orchestration of multiple subagents?
Codex excels at orchestrating subagent workflows by managing the entire lifecycle from spawning new agents to consolidating their results. When a complex task is initiated, Codex can intelligently route follow-up instructions to the appropriate subagents, monitor their progress, and await the completion of all requested tasks. Once all subagents have finished their assignments and returned their respective outputs, Codex then aggregates these results into a unified, consolidated response. This seamless orchestration ensures that even highly parallelized tasks remain coherent and deliver a comprehensive solution, simplifying complex project management for developers.
What are the security considerations and controls for Codex subagents?
Security for Codex subagents is a critical aspect, with several mechanisms in place to ensure safe operation. Subagents inherently inherit the current sandbox policy of the parent session, ensuring a consistent security posture. For interactive command-line interface (CLI) sessions, approval requests stemming from inactive agent threads can be surfaced to the user, allowing for informed decisions before actions are taken. In non-interactive environments or when immediate approval isn't feasible, actions requiring new approval will fail, preventing unauthorized operations. Developers can also apply runtime overrides for sandbox and approval choices, and even configure individual custom agents with specific sandbox modes, such as 'read-only', for fine-grained control over their operational scope and access.
How can developers create and utilize custom agents within Codex?
Developers can define custom agents in Codex to tailor AI behavior to specific needs. This is achieved by creating standalone TOML configuration files under `~/.codex/agents/` for personal agents or `.codex/agents/` for project-scoped ones. Each TOML file defines a single custom agent and acts as a configuration layer, allowing developers to override default settings like model choice, reasoning effort, or sandbox mode. Essential fields such as 'name', 'description', and 'developer_instructions' are mandatory, guiding the agent's identity and core behavior. This flexibility enables the creation of highly specialized agents for unique development tasks, further enhancing the adaptability of the Codex system.
What global settings are available for managing subagent behavior in Codex?
Codex provides several global settings to manage subagent behavior, primarily located under the `[agents]` section in the configuration file. Key settings include `agents.max_threads`, which controls the maximum number of concurrent open agent threads (defaulting to 6); `agents.max_depth`, which limits the nesting depth of spawned agents (defaulting to 1 to prevent excessive recursion and resource consumption); and `agents.job_max_runtime_seconds`, which sets a default timeout for workers in `spawn_agents_on_csv` jobs (defaulting to 1800 seconds if not specified). These settings are crucial for balancing performance, resource usage, and control over complex agent workflows, helping developers prevent unintended fan-out and manage token consumption effectively.
What are the primary advantages of using subagents for complex tasks?
The primary advantages of using subagents for complex tasks within Codex lie in their ability to parallelize and specialize operations. By breaking down a large task into smaller, manageable subtasks and assigning each to a specialized agent, development teams can achieve significant speed improvements and higher quality outcomes. For instance, in a large codebase review, one subagent might focus on security vulnerabilities, another on code quality, and a third on performance bottlenecks simultaneously. This concurrent processing not only accelerates the overall task but also allows for deeper, more focused analysis in each area, leading to more robust and comprehensive solutions than a single, monolithic AI agent could provide.
อัปเดตข่าวสาร
รับข่าว AI ล่าสุดในกล่องจดหมายของคุณ
