Agent SDKInput & OutputStreaming Input

Streaming Input

A single prompt is enough for one-shot tasks, but interactive agents need to accept input over time. Streaming input lets you hand Amara an asynchronous sequence of user messages instead of a fixed string, so the conversation stays alive across many turns and a person can steer the work as it unfolds.

Instead of passing prompt as text, you pass an async iterator that yields message objects. The SDK reads from that iterator as the agent becomes ready for the next turn, preserving the full session context between messages.

Supplying an async message stream

Build a generator that yields user turns, then hand it to query. The agent consumes each turn, runs the loop, and pauses for the next one.

import { query } from "@syntic/agent-sdk";
 
async function* turns() {
  yield { role: "user", content: "Open the config loader and add a timeout option." };
  yield { role: "user", content: "Now write a test that covers the new option." };
}
 
for await (const message of query({ prompt: turns() })) {
  if (message.type === "result") console.log(message.result);
}
import asyncio
from syntic_agent_sdk import query
 
async def turns():
    yield {"role": "user", "content": "Open the config loader and add a timeout option."}
    yield {"role": "user", "content": "Now write a test that covers the new option."}
 
async def main():
    async for message in query(prompt=turns()):
        if message.type == "result":
            print(message.result)
 
asyncio.run(main())

Interactive and long-lived sessions

Because the iterator is pulled lazily, you can feed it from any real-time source — a chat UI, a message queue, or a WebSocket — and yield a new turn only when a human actually sends one. The agent simply waits between turns without ending the session.

This model is the foundation for assistants that hold a running dialogue with a user. Each new message builds on the accumulated context rather than starting fresh, which keeps Amara aware of earlier decisions, file edits, and tool results. To carry that context across process restarts or separate requests, combine streaming input with session persistence described in the Core Concepts section.