Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions book-ar/chapter1.ar.md
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,22 @@ else:

توضح ممارسة Anthropic في بناء الوكلاء ذوي التشغيل الطويل كيف يمكن لتصميم Harness أن يحل المشكلات التي لا يستطيع النموذج نفسه حلها. لقد قاموا بتقسيم المهام المعقدة بين "وكيل التهيئة" (إعداد البيئة، وتفكيك قائمة المهام) و"وكيل التنفيذ" (إحراز تقدم تدريجي في كل جلسة وترك عناصر تسليم واضحة)، باستخدام أداة مساعدة منظمة لمعالجة وضعي الفشل للمهام الطويلة: نفاد السياق والإعلان عن إنجاز المهمة قبل الأوان. تتناول الفصول المقبلة عنصر الربط تلو الآخر - يبدأ الفصل الثاني بالعنصر الأكثر مركزية، وهو هندسة السياق، ويوضح الفصل الخامس الممارسة الكاملة لهندسة منظومة التشغيل في وكلاء البرمجة.

## أنماط تصميم تسري في الكتاب كلّه

تعود الفصول التسعة التالية مرارًا إلى المجموعة نفسها من البِنى. وهي ليست ملكًا لفصل بعينه، بل حلول متكرّرة تحت القيد نفسه؛ ولذلك نسمّيها هنا مرّة واحدة ونعطي كلًّا منها تعريفًا معياريًّا، فتكتفي الفصول التالية باستدعائها بالاسم وبيان ما يخصّها من اختلاف.

**المقترِح—المراجِع (Proposer-Reviewer)**: يتولّى الإنتاجَ والحكمَ دوران لا يتشاركان السياق، ويرى المراجِعُ المنتَجَ نفسه — الناتج المُصيَّر، ومخرجات الاختبار، ومعاملات الاستدعاء المهيكلة — لا مسار استدلال المنتِج. ومقدّمته أن **المراجعة الذاتية غير موثوقة**: فالنموذج داخل سياق بعينه لا يستطيع أن يهتدي إلى ما لم يهتدِ إليه، ويصعب عليه أن يحكم هل حُقن بالفعل أم لا. يستخدمه الفصل الثالث لتحديث المعرفة، والفصل الرابع للموافقة المسبقة والتحقّق اللاحق على استدعاءات الأدوات (وSidecar صيغته للقراءة فقط)، وتجارب الفصل الخامس الثلاث — العرض التقديمي والفيديو والسجلات — مبنيّة كلّها عليه، ويستخدمه الفصل السابع لتقييم الواجهات، والفصل التاسع لمراجعة مقترحات التحديث، ويناقش الفصل العاشر صورته في التعاون بين الأنداد، ولماذا لا يجوز أن يراجع Agent نفسه.

**الكشف التدريجي (Progressive Disclosure)**: بدل وضع المعلومات كلّها في السياق دفعةً واحدة، يُقدَّم أولًا فهرس قابل للبحث ثم تُحمّل التفاصيل عند الحاجة. وهو يحسّن أمرين في آن: ميزانية السياق ودقّة الاختيار. وAgent Skills في الفصل الثاني أوضح صوره (البيانات الوصفية مقيمة، والمتن يُحمَّل عند الطلب)، والاسترجاع الطبقي في الفصل الثالث، والاكتشاف النشط للأدوات والاقتطاع بالصفحات في الفصل الرابع، واكتشاف الوكلاء في الفصل العاشر، كلّها صيغ منه.

**الإضافة فقط (Append-only)**: تتقدّم الحالة بالإضافة، ولا يُعاد تعديل ما كُتب. والمقابل قابلية للتخزين المؤقّت وإعادة التشغيل والتدقيق. واستقرار بادئة KV Cache في الفصل الثاني هو صورته الأدائية — فكلّما تقدّم موضع التغيير بطل من الذاكرة المؤقّتة أكثر؛ والذاكرة الحدثية في الفصل الثالث، وعادة الفصل الرابع في إلحاق مخطّط الأداة الجديدة بذيل المسار بدل إعادة حشره في البادئة، تتبعان الانضباط نفسه.

**مجموعة الحدود + مجموعة الاحتفاظ (Boundary Set + Retention Set)**: يجب التحقّق من أي تعديل على «العيّنات التي يُفترض أن يغيّرها» و«العيّنات التي يجب ألّا يمسّها» معًا. فقياس الأولى وحدها يجعل فرط المطابقة يبدو تقدّمًا، وقياس الثانية وحدها يجعل التعديل عديم الأثر يبدو آمنًا. ومهامّ الانحدار في الفصل السابع، وعزل التدريب عن التقييم في الفصل الثامن، والتحقّق من مقترحات التحديث في الفصل التاسع، تقوم كلّها على هذين المجموعتين.

**أقلّ فرق ممكن وقابلية التراجع (Minimal Diff, Reversible)**: يكون كل تعديل أصغر ما يمكن، حاملًا مصدره، قابلًا للتراجع عنه وحده، لا إعادة كتابة شاملة. وهذا ما يجعل العزو ممكنًا: فإذا حدث خلل أمكن ردّه إلى تعديل بعينه. وتحديثات المعرفة في الفصل الثالث، ورقع الشيفرة في الفصل الخامس، وتحديثات الموجّهات والبرامج في الفصل التاسع، تتبع هذه القاعدة؛ كما أن مسارات التحديث الثلاثة التي وردت في أول هذا الفصل (التكيّف داخل السياق، وتحديث المنتجات الخارجية، وتحديث المعاملات) مرتّبة بالضبط من الأسهل تراجعًا إلى الأصعب.

وتتشارك هذه الأنماط الخمسة موضوعًا واحدًا: **نقل الحكم من «النموذج يقرّر بنفسه» إلى «آلية خارج النموذج تقرّر»** — فالمراجِع خارج السياق، والفهرس خارج المتن، والذاكرة المؤقّتة خارج التغيير، ومجموعة الاحتفاظ خارج مجموعة الحدود، والتراجع خارج الالتزام. وضوابط الأمان الثلاث التي وردت قبل قليل في هذا الفصل هي هذا الموضوع نفسه مطبَّقًا على الأمن. وحين نلقاها لاحقًا يكتفي الكتاب باسم النمط وبيان اختلاف الفصل، ولا يعيد اشتقاقها.

## ملخص الفصل

لقد قام هذا الفصل ببناء إطار عمل عملي أولاً لفهم وبناء وكلاء الذكاء الاصطناعي.
Expand All @@ -509,6 +525,8 @@ else:

**من سير العمل إلى الوكيل المستقل**: يطالب أولاً، ثم سير العمل، ثم الوكلاء المستقلون أخيرًا - هذا الطلب هو الطريقة الأكثر عملية لتقليل السلوك غير المتوقع. كل نمط تزامن له مواقف تناسبه؛ لا يوجد نمط واحد هو الأفضل في كل مكان.

**خمسة أنماط تسري في الكتاب كلّه**: المقترِح—المراجِع، والكشف التدريجي، والإضافة فقط، ومجموعة الحدود + مجموعة الاحتفاظ، وأقلّ فرق ممكن مع قابلية التراجع — وكلّها تتشارك موضوعًا واحدًا: نقل الحكم من النموذج نفسه إلى آلية خارجه. وتستدعيها الفصول التالية بالاسم بدل إعادة اشتقاقها.

**الأمن مشكلة معمارية**: حواجز الحماية، والتدخل البشري في الحلقة، والمحاذاة (الحفاظ على سلوك النموذج متسقًا مع القصد البشري) - يجب تصميم الأمان من السطر الأول من التعليمات البرمجية، وليس تصحيحه قبل الإطلاق. وتنقسم ضوابط الأمان بحسب صعوبة الالتفاف عليها إلى ثلاث طبقات — السياق والتنفيذ والبيانات — وكل ما يأتي في الفصول التالية من نقاش أمني معلّق على هذا الهيكل.

يتناول الفصل التالي بعمق العنصر الأكثر مركزية في منظومة التشغيل: هندسة السياق. يغطي الفصل الثامن الجذور الأكاديمية لمفهوم الوكيل في التعلم المعزز ويقارن RL التقليدي بوكلاء LLM الحديثين.
Expand Down
18 changes: 18 additions & 0 deletions book-en/chapter1.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,22 @@ Seen through the lens of Harness engineering, each chapter of this book systemat

Anthropic's practice in building long-running Agents shows how Harness design can solve problems the model itself cannot. They split complex tasks between an "Initialization Agent" (setting up the environment, decomposing the task list) and an "Execution Agent" (making incremental progress each session and leaving clear handover artifacts), using a structured Harness to tackle the two failure modes of long tasks: running out of context and declaring the task done prematurely. The chapters ahead work through the Harness component by component—Chapter 2 begins with the most central one, context engineering, and Chapter 5 lays out the complete practice of Harness engineering in Coding Agents.

## Design Patterns That Run Through the Book

The nine chapters that follow keep reaching for the same handful of structures. They do not belong to any single chapter—they are repeated solutions under one and the same constraint—so we name them once here and give each a canonical definition. Later chapters then call them by name and only describe the local variation.

**Proposer-Reviewer**: production and judgment are carried out by two roles that do not share a context, and the judge sees the artifact itself—the rendered result, the test output, the structured call arguments—rather than the producer's reasoning. The premise is that **self-review is unreliable**: a model inside a given context can neither think of what it failed to think of, nor readily tell whether it has already been injected. Chapter 3 uses it to update knowledge; Chapter 4 uses it for pre-approval and post-validation of tool calls (the Sidecar is a read-only variant); the PPT, video and log experiments of Chapter 5 are all built on it; Chapter 7 uses it to evaluate UIs; Chapter 9 uses it to review update proposals; and Chapter 10 discusses its shape in peer collaboration, and why an Agent must not review itself.

**Progressive Disclosure**: rather than putting everything into the context at once, offer a searchable catalogue first and load the details on demand. It optimizes two things simultaneously—the context budget and selection accuracy. Agent Skills in Chapter 2 is the archetype (metadata resident, body loaded on demand); the layered retrieval of Chapter 3, the proactive tool discovery and paginated truncation of Chapter 4, and Agent discovery in Chapter 10 are all variants.

**Append-only**: state evolves by appending, and what has been written is never revised in place. What this buys is cacheability, replayability and auditability. The KV Cache prefix stability of Chapter 2 is its performance form—the earlier a change lands, the more cache it invalidates; the event-shaped memory of Chapter 3 and Chapter 4's habit of appending a newly discovered tool schema to the end of the trajectory rather than splicing it back into the prefix follow the same discipline.

**Boundary Set + Retention Set**: every change must be validated both on "the samples it is supposed to change" and on "the samples it must not affect". Testing only the former mistakes overfitting for progress; testing only the latter mistakes an ineffective change for a safe one. The regression tasks of Chapter 7, the training/evaluation isolation of Chapter 8, and the update-proposal validation of Chapter 9 all rest on this pair of sets.

**Minimal Diff, Reversible**: keep each change as small as possible, carrying its provenance, and independently revertible instead of rewritten wholesale. This is what makes attribution possible—when something breaks, it can be traced to one specific change. The knowledge updates of Chapter 3, the code patches of Chapter 5, and the prompt and program updates of Chapter 9 all follow it; and the three update paths given at the start of this chapter (in-context adaptation, external-artifact updates, parameter updates) are themselves ordered from most to least reversible.

These five patterns share one motif: **moving judgment from "the model decides" to "a mechanism outside the model decides"**—the reviewer sits outside the context, the catalogue outside the body text, the cache outside the change, the retention set outside the boundary set, the rollback outside the commit. The three-layer guardrails given earlier in this chapter are that motif applied to security. When these patterns reappear later, this book names them and states the local difference rather than deriving them again.

## Chapter Summary

This chapter has built a practice-first framework for understanding and constructing AI Agents.
Expand All @@ -512,6 +528,8 @@ This chapter has built a practice-first framework for understanding and construc

**From Workflow to Autonomous Agent**: Prompts first, then workflows, autonomous Agents last—that ordering is the most practical way to reduce unexpected behavior. Every orchestration pattern has situations where it fits; no single pattern is best everywhere.

**Five patterns run through the book**: Proposer-Reviewer, Progressive Disclosure, Append-only, Boundary Set + Retention Set, and Minimal Diff / Reversible—all sharing one motif, moving judgment from the model itself to a mechanism outside it. Later chapters call them by name instead of deriving them again.

**Security Is an Architectural Issue**: Guardrails, human-in-the-loop intervention, alignment (keeping the model's behavior consistent with human intent)—security has to be designed in from the first line of code, not patched on before launch. Guardrails fall into three layers—context, execution, and data—ordered by how hard they are to bypass, and every later chapter hangs its security discussion on that skeleton.

The next chapter examines the Harness's most central component in depth: context engineering. Chapter 8 covers the Agent concept's academic roots in reinforcement learning and compares traditional RL with modern LLM Agents.
Expand Down
Loading
Loading