الوكلاء الفرعيون يحمون رصيدك بهدوء
كل بحث طويل تجريه في جلستك الرئيسية مع الذكاء الاصطناعي يكلّفك توكنز بدون ما تحس.
لما تفتح محادثة وتبدأ تضيف إليها مقالات وصفحات نتائج ودوّرات تانية على نفس الموضوع، أنت ما تشوف التكلفة لكن هي تتراكم. كل رسالة إضافية تضيفها للجلسة تملأ نافذة السياق (Context Window) وترفع الحساب. الوكيل الفرعي (Subagent) هو الطريقة الصح لحل هذا بالضبط، وما كثير ناس يعرفونها.
🧩 إيش هو بالضبط
الوكيل الفرعي (Subagent) هو نسخة منفصلة من الذكاء الاصطناعي تشغّلها من داخل جلستك الرئيسية لتشتغل لوحدها على مهمة محددة. الفكرة مثل ما تطلب من موظف يروح يدور على معلومة معينة ويرجع لك بالجواب النهائي فقط. أنت ما تحتاج تشوف كل خطواته وكل صفحة شافها، تبي النتيجة بس.
الجلسة الرئيسية تبقى نظيفة وخفيفة. الوكيل الفرعي يشتغل في نافذة سياق مستقلة خاصته، يبحث ويحلّل ويفكّر، ثم يرجع لك بجواب مختصر. النتيجة إنك توفّر توكنز وايد لأن الجلسة الرئيسية ما تحمّلت كل هذا العبء.
⚙️ كيف يشتغل
لازم تفهم شيء أساسي أول: كل محادثة عندها حد أقصى للمعلومات اللي تقدر تحتويها. هذا هو نافذة السياق (Context Window). لما تملأ هذا الحد بنتائج بحث وصفحات طويلة وردود متكررة، الذكاء الاصطناعي يبدأ "ينسى" المعلومات القديمة، وأنت تدفع ثمن هذا الازدحام كله.
الوكيل الفرعي يحل هذا بطريقة بسيطة:
1️⃣ تعطيه مهمة واحدة واضحة: "ابحث عن أفضل 3 أدوات مفتوحة المصدر لإدارة المشاريع واشرح الفرق بينها"
2️⃣ يفتح نافذة سياق جديدة خاصة فيه ويبدأ يشتغل بشكل مستقل تماماً
3️⃣ يبحث ويقيّم ويصفّي النتائج كلها في سياقه هو وما يلوّث جلستك
4️⃣ يرسل لك جواباً مباشراً ومختصراً: "الأدوات هي X وY وZ وهذا الفرق بينها"
5️⃣ جلستك الرئيسية تستقبل هذه النتيجة فقط، بدون أي ضجيج أو وزن إضافي
🌍 وين تشوفه في حياتك
هذا المفهوم موجود في أدوات حقيقية تقدر تستخدمها اليوم:
🔍 في Claude Code عندك أداة Agent مدمجة تشغّل وكلاء فرعيين مباشرة من جلستك
💬 في منظومة OpenAI، الـ Assistants API يخلي المطورين يفصلون المهام بين وكلاء مختلفين كل وحد عنده سياقه
🏢 في بيئات الشركات، أطر عمل مثل AutoGen من Microsoft تبني شبكات وكلاء كاملة تتعاون مع بعض
⚡ في تطبيقات الإنتاجية الجديدة، الذكاء الاصطناعي يشغّل وكلاء متعددين في الخلفية وأنت ما تحس إلا بالنتيجة النهائية
🛠️ الأدوات اللي تستخدمها فعلاً
🔧 Claude Code
بيئة تطوير من Anthropic تحتوي أداة Agent مدمجة. من داخل جلستك الرئيسية تقدر تطلق وكيلاً فرعياً يبحث في ملفات مشروعك أو يسوّي مهمة بحثية محددة ويرجع لك بالنتيجة نظيفة.
كيف تبدأ:
1️⃣ ثبّته عبر: npm install -g @anthropic-ai/claude-code أو زور claude.ai/code
2️⃣ شغّله في أي مجلد وافتح جلسة جديدة
3️⃣ اطلب مهمة بحثية محددة وشاهد كيف يظهر الـ Agent وهو يشتغل بشكل مستقل عن جلستك
🔧 AutoGen
إطار عمل مفتوح المصدر من Microsoft لبناء شبكات وكلاء. وكيل رئيسي ينسّق، وبقية الوكلاء كل وحد متخصص في جزء من المهمة.
كيف تبدأ:
1️⃣ ثبّته عبر: pip install pyautogen
2️⃣ افتح المستودع الرسمي على github.com/microsoft/autogen وشوف الأمثلة
3️⃣ ابدأ بمثال المحادثة بين وكيلين، وكيل يسأل ووكيل يجاوب، وهو الأبسط للتجربة
🔧 LangGraph
مكتبة Python من LangChain لبناء وكلاء على شكل مخططات تدفق. كل عقدة (Node) في المخطط هي وكيل مستقل أو خطوة منفصلة.
كيف تبدأ:
1️⃣ ثبّته عبر: pip install langgraph
2️⃣ اقرأ مثال ReAct Agent في التوثيق الرسمي على langgraph.dev
3️⃣ ابنِ مخططاً بسيطاً بعقدتين: وكيل يبحث ووكيل يلخّص النتائج
💡 جرّب بنفسك: خطوة بخطوة
خلنا نقول إنك تكتب تقرير عن أفضل أدوات الذكاء الاصطناعي لتحليل البيانات، وتبي تفادي تملأ جلستك الرئيسية بمعلومات كثيرة. هذا اللي تسويه:
1️⃣ افتح Claude Code وابدأ جلسة جديدة في أي مجلد على جهازك
2️⃣ قل للوكيل الرئيسي: "أطلق وكيلاً فرعياً يبحث عن أفضل 5 أدوات ذكاء اصطناعي لتحليل البيانات ويرجع لي بملخص من 3 جمل لكل أداة"
3️⃣ شاهد كيف تظهر عملية Agent في الجلسة وهي تشتغل في الخلفية. الوكيل الفرعي يبحث ويحلّل وأنت تشوف التقدم بدون ما يلوّث جلستك
4️⃣ بعد دقيقة أو دقيقتين يرجعك الوكيل بنتيجة منظّمة ومختصرة. جلستك الرئيسية احتوت هذه النتيجة النهائية فقط، مو كل عملية البحث اللي صارت في الخلفية
وش تسوي بعد ذا
✅ جرّب Claude Code وشغّل مهمة بحثية واحدة عبر أداة Agent لتشوف الوكيل الفرعي وهو يشتغل فعلاً
✅ ابحث عن مفهوم "Context Window" لأنه الأساس اللي كل اللي تحدثنا عنه مبني عليه
✅ فكّر وش المهام اللي تكررها في كل جلسة أو تعيد شرحها من الصفر كل مرة، هذي بالضبط أكثر المهام اللي يستحق فيها استخدام وكيل فرعي
الذكاء الاصطناعي الحقيقي مو بس في الجواب، هو في كيف تشتغل وأين تصرف رصيدك.
———— English ————
Subagents Protect Your Credit Quietly
Every long search you run inside your main AI session quietly drains your token budget in the background.
Most people treat their AI session like a search engine. They paste in article after article, ask the model to read through pages of results, then circle back with more context. The conversation grows heavy fast. What they do not see is that every message added to that main session costs tokens — and as the context fills up, the model starts losing the thread of earlier exchanges. A subagent is the cleaner way to work, and most users never discover it.
**What it actually is**
A subagent is a separate instance of the AI that you launch from inside your main session to handle a specific task on its own. Think of it like asking a trusted colleague to go find specific information and report back with just the answer — you do not need to watch every step they take or read every page they checked. You need the result.
The main session stays lean. The subagent works inside its own independent context window, does the research or analysis, then returns a compact summary. Your main session receives only that final answer. None of the intermediate noise makes it into your active context.
**How it works**
Every AI conversation has a hard limit on how much information it can hold at once. This is called the context window. When you fill that window with raw search results, long documents, and repeated clarifications, the model starts dropping older details to make room — and you pay for every token in that crowded window whether it helped you or not.
The subagent solves this by working in isolation:
1️⃣ You give it one clear task: "Search for the top 3 open source project management tools and explain the key difference between them"
2️⃣ It opens its own separate context window and starts working completely independently
3️⃣ It searches, evaluates, and filters all inside its own space without touching your session
4️⃣ It sends back a tight, direct answer: "The top 3 are X, Y, and Z — here is how they differ"
5️⃣ Your main session receives only that final output, with none of the intermediate work weighing it down
**Where you see it**
This is no longer theoretical. It shows up in tools you can use right now:
🔍 In Claude Code, the Agent tool lets you launch subagents directly from your active session to handle targeted research or code tasks
💬 In the OpenAI ecosystem, the Assistants API lets developers separate work across distinct agents, each with its own persistent thread
🏢 In enterprise environments, frameworks like AutoGen from Microsoft build full networks of specialized agents that coordinate without any single agent holding all the context
⚡ In newer productivity apps, AI quietly runs multiple background agents in parallel and presents you with a synthesized result — you never see the work behind it
**🛠️ Tools you actually use**
🔧 Claude Code
Anthropic's development environment with a built-in Agent tool. From inside your main session, you can spawn a subagent to search your project files, do focused research, or complete a bounded task and return just the result.
How to get started:
1️⃣ Install it via npm: npm install -g @anthropic-ai/claude-code or visit claude.ai/code
2️⃣ Open it inside any working folder and start a new session
3️⃣ Ask it to launch an agent for a specific research task and watch the Agent process spin up independently
🔧 AutoGen
An open source multi-agent framework from Microsoft. One orchestrating agent coordinates a network of specialized workers, each handling a slice of the overall task in its own context.
How to get started:
1️⃣ Install via: pip install pyautogen
2️⃣ Open the official repository at github.com/microsoft/autogen and explore the examples folder
3️⃣ Start with the basic two agent conversation example: one user agent, one assistant agent, one defined task
🔧 LangGraph
A Python library from LangChain for building agents as flow graphs. Each node in the graph is a separate step or specialized agent, and the graph controls how results pass between them.
How to get started:
1️⃣ Install via: pip install langgraph
2️⃣ Read the ReAct Agent example in the official docs at langgraph.dev
3️⃣ Build a two-node graph to start: one agent that searches, one that summarizes
**💡 Try it yourself: step by step**
Say you are writing a report on the best AI tools for data analysis and you want to avoid flooding your main session with raw research. Here is what you do:
1️⃣ Open Claude Code and start a fresh session in any folder on your machine
2️⃣ Ask the main agent: "Launch a subagent to research the top 5 AI tools for data analysis and return a three sentence summary for each one"
3️⃣ Watch the Agent process appear in the session view. The subagent works in the background and you can follow its progress without it polluting your main context at all
4️⃣ Within a minute or two, the subagent returns a clean and organized summary. Your main session only ever held that final answer, not the full research trail that produced it
**What to do next**
✅ Open Claude Code and run one research task through the Agent tool to see the subagent pattern working in real time
✅ Read about context windows — that concept is the foundation for everything described here
✅ Think about which tasks you currently repeat across sessions or re-explain from scratch each time — those are exactly where subagents pay off most
Knowing how to delegate inside an AI session is what separates users who constantly hit credit limits from those who never notice them.