LocalAgent

queue()

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

Envía un mensaje mientras el agente trabaja. Espera a las herramientas en curso y llega al modelo antes de su siguiente turno: la misma ejecución lo responde. 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

Cuándo se lee el mensaje

Antes del siguiente turno del modelo, después de que hayan respondido las herramientas del turno actual. Una herramienta que ya se está ejecutando nunca se interrumpe por él. Una ejecución que iba a terminar (el modelo había acabado de responder) continúa un turno más, así que un mensaje escrito en el último segundo no se pierde.

Cuando no se ejecuta nada

Responde { queued: false, reason: "not_running" } y no guarda nada: antes de run(), después de que termine o después de stop(). Envíe el texto como un mensaje nuevo con run().

Lo que no se leyó

Si la ejecución termina antes de leerlo (detenida, sin presupuesto, sin pasos o con error), el mensaje vuelve en result.unsent como [{ id, text }]. Vuelva a ponerlo en el campo de texto o envíelo como el siguiente mensaje.

Imágenes

{ message, inputs: [{ type: "image", content, mime }] } pone imágenes en cola junto con el texto. Entran en la conversación con el mensaje, como las entradas de run().

En Python

agent.run() bloquea, así que agent.queue() se llama desde otro hilo: una interfaz, una devolución de llamada on_event. Es seguro entre hilos. SDK Python 0.2.0+.