محل & محلي

queue()

agent.queue(message | { message?, inputs? }) → { queued: true, id, position } | { queued: false, reason }

ترسل رسالة بينما يعمل الوكيل. تنتظر الأدوات الجارية، ثم تذهب إلى النموذج قبل دوره التالي — ويجيب عنها التشغيل نفسه. SDK 0.5.4+.

synchronousread before the next turnnever lost
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

const running = agent.run({ message: "Clean up the Notes folder" });

// Later, while a tool is still running:
agent.queue("Also keep a copy of plan.md");
// { queued: true, id: "u1", position: 1 }

const result = await running;   // the copy was made in the same run
import threading

results = []
worker = threading.Thread(target=lambda: results.append(agent.run(message="Clean up the Notes folder")))
worker.start()

# From another thread, while a tool is still running:
agent.queue("Also keep a copy of plan.md")
# {"queued": True, "id": "u1", "position": 1}

worker.join()   # the copy was made in the same run

متى تُقرأ الرسالة

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

عندما لا يعمل شيء

ترد بـ { queued: false, reason: "not_running" } ولا تحتفظ بشيء: قبل run()، أو بعد انتهائه، أو بعد stop(). أرسل النص كرسالة جديدة باستخدام run().

ما لم يُقرأ

إذا انتهى التشغيل قبل قراءتها — أُوقف، أو نفدت الميزانية، أو نفدت الخطوات، أو فشل — تعود الرسالة في result.unsent بالشكل [{ id, text }]. أعدها إلى حقل الكتابة، أو أرسلها كرسالة تالية.

صورة

{ message, inputs: [{ type: "image", content, mime }] } يضع صورًا في الطابور مع النص. وتدخل المحادثة مع الرسالة، مثل مدخلات run().

في Python

agent.run() يحجب التنفيذ، لذا يُستدعى agent.queue() من خيط آخر — واجهة، أو دالة رد نداء on_event. وهو آمن بين الخيوط. SDK Python 0.2.0+.