Instant Structured Streaming
When you need low-latency feedback (real-time UI, progressive summaries), you usually want structured output as it streams. Instant is built for that.
Define the structure
python
from agently import Agently
agent = Agently.create_agent()
response = (
agent
.input("Explain recursion in one sentence and give 2 tips")
.output({
"definition": (str, "One-line definition"),
"tips": [("str", "Short tip")]
})
.get_response()
)Use the Instant generator
python
for msg in response.get_generator(type="instant"):
if msg.path == "definition" and msg.delta:
print(msg.delta, end="", flush=True)
if msg.wildcard_path == "tips[*]" and msg.delta:
print(msg.delta, end="", flush=True)
print()Paths and consumption
msg.pathis the concrete field pathmsg.wildcard_pathis for list fieldsmsg.deltais the incremental chunk
Instant keeps the schema stable while the text streams in.