I ran 100 AI agents on one laptop. The hierarchy is what made the work usable

I ran roughly 100 agents on one laptop against a single goal, and the count is the least useful part of that sentence. What made the run finish was a hierarchy: one lead model that kept the decisions and the approvals, and a set of smaller agents that each did one bounded job and reported back.

The failure this replaced is familiar. One model writes the feature, runs the tests, reads the logs, and then tries to repair what it just built. Its context fills with output it will never need again, and the answers late in the session are worse than the answers at the start. What runs out first is room in the context, and a stronger model runs out of it too.

Claude Code's subagent documentation describes the fix in mechanical terms. Each subagent runs in its own context window with its own system prompt, its own tool access and independent permissions, and only its summary comes back to the main conversation. The verbose reading stays in the subagent's context, away from where the decisions are made.

An agent is a Markdown file. In .claude/agents/<name>.md, the frontmatter carries name, a description that tells the lead when to delegate, a tools allowlist, and a model. A review agent declared with tools: Read, Grep, Glob cannot write to a file whatever it concludes, because it was never given a tool that writes.

The model line is one word. It accepts fable, opus, sonnet, haiku, a full model ID, or inherit. Anthropic's model overview recommends Claude Opus 5 for most workloads and Claude Fable 5.1 for demanding reasoning and long-horizon agentic work, and it prices Fable 5.1 at 10 dollars per million input tokens against 2 for Sonnet 5 and 1 for Haiku 4.5. So the lead gets Fable 5.1, implementation gets Opus 5, and Sonnet 5 takes the reading and the repetitive passes.

The limits explain why 100 is a total across the run. Claude Code runs 20 subagents at once by default and lets an agent spawn agents 3 layers deep. At that ceiling the work arrives in waves, and each wave ends with the lead running the checks itself and closing only the tasks whose evidence is in hand. The copy block below is that system as a file structure, a lead prompt and a wave rule. Start with one project and 3 agents.

Follow for more:

  • https://www.instagram.com/ai.with.mo/
  • Course Registration: https://halaqa.app/enrollment?course=start-with-ai

    One model doing everything runs out of room before it runs out of ability

    A single session that writes the code and then checks it reads far more than it produces. It opens whole files to find one function and runs a whole test suite to see one failure. All of that stays in the same context that holds the plan and the decisions made two hours ago. By the end of a long session the model is reasoning about a transcript of the project. It rarely looks like a context problem. The typical failure looks like finished work: a change made in one file and forgotten in the file that calls it, or a test reported as passing without being run. None of it comes back as an error, which is what makes it expensive. The correction is structural: move the reading out of the room where the decisions are made. Claude Code's subagent documentation names this directly: delegating an operation that produces a lot of output keeps that output in the subagent's own context, and only the summary returns. The lead then spends its room on judgment, which is the one thing it cannot delegate.

    Delegation only works when the boundary is a permission

    A subagent is defined in a file, .claude/agents/<name>.md for one project or ~/.claude/agents/<name>.md for every project. Four lines of frontmatter do the work: name identifies it, description tells the lead when to delegate to it, tools lists what it is allowed to touch, and model sets which model runs it. The body is its system prompt. The tools line is the part people skip, and it is the reason a hundred agents can be trusted with a project. A researcher declared with tools: Read, Grep, Glob, WebFetch can read anything and write nothing. A reviewer given Bash can run the test command and still not edit the file it is judging. This is a permission, so it holds when the model is wrong and when the instruction is ambiguous. An instruction that says please do not edit anything holds only while the model agrees with it. The lead keeps what cannot be split: the plan, the decisions between two acceptable approaches, the integration of results that arrive separately, and the final approval. Everything else is a delegation with a boundary, and Claude Code enforces that boundary itself, because each subagent runs with independent permissions.

    Fable 5.1 leads because the expensive thinking happens once

    The model line accepts fable, opus, sonnet, haiku, a full model ID, or inherit to follow the main conversation. Claude Code resolves it in a fixed order: a model passed at invocation, then the frontmatter, then CLAUDE_CODE_SUBAGENT_MODEL, then the model of the main conversation. So routing lives in the definition file, and you never have to repeat it in a prompt. Anthropic's model overview is the basis for how I route. It recommends Claude Opus 5 for most workloads and Claude Fable 5.1 for demanding reasoning and long-horizon agentic work, which is exactly the shape of a lead that plans a large goal and then holds it across hours. It also lists the prices: 10 dollars per million input tokens for Fable 5.1, 5 for Opus 5, 2 for Sonnet 5 and 1 for Haiku 4.5, with Haiku on a 200 thousand token context window while the other three carry 1 million. That spread is the argument for a hierarchy rather than a fleet of equals. Planning happens once and its errors spread through every task after it, so it belongs to the most capable model available. Searching a repository, comparing two sources, summarizing a log and applying a repetitive edit are bounded jobs with a clear acceptance check, and they are the volume of the run. The documentation names cost control through faster, cheaper models as one of the reasons subagents exist. The cheap model still has to pass its check.

    The task graph decides how many agents run

    Claude Code sets a default ceiling of 20 subagents running at once, and spawning the twenty first fails with a concurrent subagent limit reached error. An agent may spawn agents of its own up to 3 layers below the main conversation. Both are configurable, through CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS and CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH. My run reached about 100 agents in total, on one laptop, for one goal. What decides the count is the task graph. Two tasks that touch the same file stay in sequence, because parallel edits to one file produce repair work that costs more than the time saved. A task that needs an earlier decision waits for it. Parallel work is reserved for branches that can reach a finished result on their own, which is the same rule whether the wave holds 3 agents or 15. There is one more limit worth knowing before the roster grows: Claude Code warns at startup once the combined description fields pass 15,000 tokens, so keep each description to the one sentence that says when to delegate. The rule that made the difference is the last one. A report is not a completion. A task closes when the command named in the plan passes and its evidence is recorded, and until then it stays open however confident the agent sounded. That approval gate is the lead's job: Fable 5.1 reads every result and runs the checks itself before a task is marked done.

    شغّلت ⁨100 agent⁩ على لابتوب واحد، وما أنجح التجربة هو ترتيب من يدير من

    على لابتوب واحد، وضعت قرابة ⁨100 agent⁩ أمام هدف واحد. في الأعلى ⁨Claude Fable 5.1⁩، وأسمّيه الرأس الكبير: يدير سير العمل ويوافق على التغييرات قبل أن تدخل المشروع. وتحته ⁨agents⁩ من ⁨Claude Opus⁩ و⁨Claude Sonnet⁩ تعمل بالتوازي، لكل واحد منها قطعة محددة من العمل.

    إن وصلت إلى هنا من المقطع الذي يسأل هل تستطيع فعلًا أن تدير شركة برمجيات كاملة من لابتوبك، فجوابي من التجربة أن ذلك ممكن بشرطين. الأول هرم واضح: الرأس يمسك الخطة والقرار الأخير، وكل ⁨agent⁩ تحته يأخذ مهمة لها بداية ونهاية. والثاني أن تكون حدود كل ⁨agent⁩ صلاحيات مكتوبة في ملفه، فالـ⁨agent⁩ الذي لم تعطه أداة كتابة لن يعدّل ملفًا مهما طلبت منه.

    أما لماذا لا يكفي نموذج واحد يفعل كل شيء، فلأن المكان يضيق عليه حين يكتب الكود ويفحصه في الجلسة نفسها، مهما كان قويًا. ومع طول الجلسة يبدأ بتسليم عمل يبدو كاملًا، وفيه ثغرات لا تظهر في أي رسالة خطأ. توزيع العمل على ⁨agents⁩ يُبقي جلسة الرأس خفيفة، لأن كل واحد منها يحمل تفاصيله في مساحته ويعيد إليه الخلاصة.

    والهرم يخفف الفاتورة أيضًا، لأن أغلى نموذج يعمل على الخطة والموافقة الأخيرة، وأغلب الـ⁨tokens⁩ تذهب إلى نماذج أرخص منه. وعمل النموذج الأرخص يمر على الفحص نفسه قبل أن يُقبل.

    وعدد الـ⁨agents⁩ يحدده شكل المهام. قد يحتاج مشروع صغير إلى ثلاثة فقط، وقد تتفرع المهام في مشروع آخر إلى العشرات، والمهم أن يعرف الرأس ما الذي يعمل الآن وما الذي ينتظر غيره. وكل مهمة تبقى مفتوحة إلى أن يمر فحصها، مهما بدا تقرير الـ⁨agent⁩ مقنعًا.

    الرقم والهرم من تجربتي. أما الحدود التقنية والأسعار فمن توثيق ⁨Anthropic⁩، وستجد الرابط عند كل معلومة منها.

    تابعني على ⁨Instagram⁩:

  • https://www.instagram.com/ai.with.mo/
  • التسجيل في الدورة: https://halaqa.app/enrollment?course=start-with-ai

    الخطوات

    النموذج الذي يكتب ويفحص وحده يمتلئ قبل أن يعجز

    ليعدّل دالة واحدة، يقرأ النموذج الملف كله. وليفهم سبب فشل اختبار واحد، يقرأ نتيجة تشغيل الاختبارات كاملة ومعها ⁨logs⁩ طويلة. هذا كله يدخل الـ⁨context⁩ الذي يحفظ فيه الخطة والقرارات التي اتُّخذت في أول الجلسة، وكلما طالت الجلسة ساءت الإجابات التي تأتي في آخرها. والفشل هنا يشبه العمل المنجز، فلا يرفع أي خطأ. النمط المعتاد أن يعدّل النموذج دالة في ملف وينسى الملف الذي يستدعيها، أو يكتب أن الاختبار نجح وهو لم يشغّله أصلًا. التقرير يصلك مرتبًا، والعيب في مكان لم ينظر إليه أحد. هذه هي المشكلة التي تعالجها الـ⁨subagents⁩. بحسب توثيق ⁨Claude Code⁩، يعمل كل ⁨subagent⁩ في ⁨context⁩ مستقل، وله ⁨system prompt⁩ خاص به، ولا يعود إلى المحادثة الرئيسية إلا ملخّص ما فعله. نتيجة الاختبارات التي قد تمتد آلاف الأسطر تبقى عنده، ويصل إلى الرأس منها ما يحتاجه فقط.

    التفويض يصمد عندما تُكتب حدوده صلاحيات في ملف الـ⁨agent⁩

    الـ⁨subagent⁩ ملف ⁨Markdown⁩. تضعه في ⁨.claude/agents/<name>.md⁩ ليعمل في مشروع واحد، أو في ⁨~/.claude/agents/<name>.md⁩ ليكون متاحًا في كل مشاريعك. في أعلى الملف ⁨frontmatter⁩ بأربعة حقول: ⁨name⁩، ثم ⁨description⁩ الذي يقرؤه الرأس ليعرف متى يسلّمه مهمة، ثم ⁨tools⁩ وهي قائمة الأدوات المسموحة له، ثم ⁨model⁩. وما تحت ذلك هو الـ⁨system prompt⁩ الخاص به. قائمة ⁨tools⁩ صلاحية، لا تعليمة. المراجع الذي لا تعطيه غير ⁨Read⁩، ⁨Grep⁩، ⁨Glob⁩ لا يستطيع الكتابة في أي ملف، حتى لو رأى خطأ واضحًا وأراد إصلاحه. والباحث الذي تضيف له ⁨WebFetch⁩ يقرأ من الويب، والكتابة خارج صلاحياته. وإن أعطيت المراجع ⁨Bash⁩ صار يشغّل أمر الاختبارات بنفسه، ويبقى عاجزًا عن تعديل أي ملف. وبحسب التوثيق نفسه، لكل ⁨subagent⁩ صلاحيات مستقلة. في هرم فيه عشرات الـ⁨agents⁩، هذه الحدود هي ما يسمح لك بتسليم مهمة دون أن تراقبها سطرًا بسطر. ابدأ كل ⁨agent⁩ جديد بأقل قائمة ⁨tools⁩ تكفي مهمته، وأضف الأداة حين تطلبها مهمة فعلًا.

    ⁨Fable 5.1⁩ في الرأس لأن التفكير المكلف يحدث مرة واحدة

    الرأس يحتفظ بما لا يمكن تقسيمه: الخطة، والاختيار بين طريقتين مقبولتين، وجمع النتائج التي تصل متفرقة في عمل واحد، ثم الموافقة الأخيرة. التخطيط يحدث مرة واحدة، وأي خطأ فيه ترثه كل المهام التي تُبنى عليه، ولذلك يذهب إلى أقوى نموذج عندك. صفحة نماذج ⁨Anthropic⁩ توصي بـ⁨Claude Opus 5⁩ لمعظم الأعمال، وبـ⁨Claude Fable 5.1⁩ للاستدلال الصعب وللعمل الطويل الذي يديره ⁨agent⁩. بقية الحجم مهام محدودة لها فحص واضح: البحث في الـ⁨codebase⁩، ومقارنة المصادر، وتلخيص الـ⁨logs⁩، والتعديلات المتكررة. هذه تذهب إلى نماذج أسرع وأرخص، وهذا هو السبب الثاني الذي يذكره توثيق ⁨Claude Code⁩ لوجود الـ⁨subagents⁩ بعد حماية الـ⁨context⁩. وعليها مع ذلك أن تنجح في فحصها مثل أي مهمة أخرى. وتحدد النموذج في حقل ⁨model⁩ داخل ملف كل ⁨agent⁩، وهو يقبل ⁨fable⁩ أو ⁨opus⁩ أو ⁨sonnet⁩ أو ⁨haiku⁩، أو معرّفًا كاملًا للنموذج، أو ⁨inherit⁩ ليأخذ نموذج المحادثة الرئيسية. وعند التعارض يُقدَّم النموذج المحدد لحظة الاستدعاء، ثم الـ⁨frontmatter⁩، ثم متغير البيئة ⁨CLAUDE_CODE_SUBAGENT_MODEL⁩، ثم نموذج المحادثة الرئيسية. والفرق في الكلفة يظهر في أسعار الـ⁨API⁩. سعر المليون ⁨token⁩ من المدخلات ⁨10⁩ دولارات في ⁨Fable 5.1⁩، و⁨5⁩ دولارات في ⁨Opus 5⁩، ودولاران في ⁨Sonnet 5⁩، ودولار واحد في ⁨Haiku 4.5⁩. والثلاثة الأولى تتسع لمليون ⁨token⁩ من الـ⁨context⁩، أما ⁨Haiku 4.5⁩ فلمئتي ألف.

    خريطة المهام تحدد كم ⁨agent⁩ تشغّل، والمهمة تُغلق حين ينجح فحصها

    مهمتان تلمسان الملف نفسه تعملان الواحدة بعد الأخرى. والمهمة التي تحتاج قرارًا من مهمة سابقة تنتظره. ويبقى التوازي للفروع التي تنتهي دون أن تحتاج شيئًا من غيرها. لذلك ارسم المهام أولًا، ومن يعتمد منها على من، ثم احسب العدد من الرسم. وللعدد سقف. بحسب توثيق ⁨Claude Code⁩، الحد الافتراضي ⁨20 subagent⁩ تعمل في وقت واحد، وأي محاولة لتشغيل واحد إضافي تفشل برسالة «⁨Concurrent subagent limit reached⁩». ويستطيع الـ⁨subagent⁩ أن يطلق ⁨subagents⁩ خاصة به حتى ثلاث طبقات تحت المحادثة الرئيسية. الحدّان قابلان للتغيير عبر ⁨CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS⁩ و⁨CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH⁩، ويظهر تحذير عند التشغيل إذا تجاوز مجموع حقول ⁨description⁩ في كل الـ⁨subagents⁩ حدّ ⁨15,000 token⁩. وبهذا السقف لا تصل إلى قرابة ⁨100 agent⁩ إلا على موجات. كل موجة تنتهي بأن يقرأ الرأس التقارير ويشغّل الفحوص بنفسه. التقرير الذي يقول إن المهمة انتهت هو كلام الـ⁨agent⁩ عن نفسه، والمهمة تُغلق حين ينجح الفحص المسمّى لها ويُسجَّل دليله. في مربع النسخ أسفل الصفحة، بالإنجليزية، هيكل الملفات والـ⁨prompt⁩ الذي يُعطى للرأس وقاعدة الموجات. جرّبها على مشروع واحد بثلاثة ⁨agents⁩، ولا ترفع العدد قبل أن يغلق الرأس موجة كاملة بفحوص ناجحة.

    Prompt

    # AGENT HIERARCHY FOR ONE LAPTOP
    # Use this when one goal is too large for a single session to hold.
    # Lead: Fable 5.1. Implementation: Opus 5. Reading and volume: Sonnet 5.
    
    # --- FILES ---
    # CLAUDE.md
    # The rules every session must see:
    # - the goal and the architecture
    # - the build, test and lint commands
    # - what may never be touched
    # - where the memory and the task file live
    
    # .claude/agents/researcher.md
    # ---
    # name: researcher
    # description: Reads the codebase and external sources, returns findings only
    # tools: Read, Grep, Glob, WebFetch
    # model: sonnet
    # ---
    # Report what you found with file paths and line numbers. Change nothing.
    
    # .claude/agents/reviewer.md
    # ---
    # name: reviewer
    # description: Checks a finished change against its acceptance command
    # tools: Read, Grep, Glob, Bash
    # model: opus
    # ---
    # Run the command named in the task. Report pass or fail with the output.
    
    # An agent that must not write is given no tool that writes. Control comes
    # from that permission, whatever the prompt says.
    
    # --- THE LEAD PROMPT ---
    # Read CLAUDE.md, then the task file. You are the lead. You keep the
    # decisions, the integration and the final approval.
    #
    # Write the work as a checklist. Every task carries:
    # 1. one bounded objective;
    # 2. the files or system it owns;
    # 3. the agent and the model that will run it;
    # 4. the command that proves it worked;
    # 5. the evidence it must return.
    #
    # Delegate only tasks that are independent. Two agents never edit the same
    # file in the same wave. A task that needs an earlier decision waits.
    
    # --- THE WAVE RULE ---
    # Run 3 to 5 agents, then stop and reconcile: read the reports, run the
    # checks yourself, resolve the conflicts, update the checklist.
    #
    # A report is not a completion. A task closes when its command passes and
    # its evidence is recorded. When a check fails, open the smallest repair
    # task that can fix it.
    #
    # Launch another wave only while independent work remains. Stop at the goal
    # or at a stop condition you named in advance, then write the receipt: what
    # shipped, what was verified, what failed, and the next exact action.