# Write while the agent works.

Canonical URL: https://www.iagenify.com/news/iagenify-write-while-the-agent-works

Send a message during a run: the agent reads it before its next step, in the same run. In the beta, the desktop app and the SDK 0.5.4.

## Key points
- agent.queue() sends a message while a run is in progress; the agent reads it before its next model turn.
- A run that was about to finish continues to answer it, so a last-second message is not lost.
- Messages that were never read come back in result.unsent instead of disappearing.

Long agent runs used to be all or nothing: once the agent started, adding a detail meant waiting for the end or stopping it. Now you can keep writing. The message waits for the tools in progress, reaches the model before its next step, and the same run answers it.

## In the apps

In the IaGenify beta and the desktop app, the message box stays open during a run. A queued message appears as a chip you can remove until the agent reads it; once read, it takes its place in the conversation and the answer continues below it. The same works in the agent panels of the Design, Workflows and Mail editors.

## In the SDK


```
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;
result.unsent;   // only present if a message was never read
```

queue() answers at once. If no run is in progress it says so and keeps nothing, so the text can be sent as a new message. If a run ends before reading a message — stopped or out of budget — the message comes back in result.unsent.

## In Python

Python's agent.run() blocks, so queue() is called from another thread, and it is thread-safe. It ships with the Python SDK 0.2.0.


```
import threading

worker = threading.Thread(target=lambda: agent.run(message="Clean up the Notes folder"))
worker.start()
agent.queue("Also keep a copy of plan.md")
worker.join()
```

## Documentation
- [agent.queue() — IaGenify developers](https://developers.iagenify.com/sdk/ref/local-agent/queue)

## FAQ
### Does a queued message interrupt a running tool?
No. Tools already running finish first; the message is read before the next model turn.

### What happens if I stop the agent?
Unread messages are returned, not sent. In the apps, they go back to the message box.
