Agently Docs

Agently documentation for building AI applications with stable outputs, observable actions, and durable workflows.

View the Project on GitHub AgentEra/Agently

Async First

Agently is async-native at the runtime layer. Sync methods are convenience wrappers generated from the async ones via FunctionShifter.syncify(). For real services, async should be the default path.

When sync is fine

When async is the default

The combination worth learning first:

instant events are field-level: each item arrives only after its leaf has fully parsed, so downstream code never sees a half-string.

API surface map

Sync Async equivalent
agent.start() / request.start() agent.async_start() / request.async_start()
response.get_data() response.async_get_data()
response.get_text() response.async_get_text()
response.get_meta() response.async_get_meta()
response.get_generator(type=...) response.get_async_generator(type=...)
flow.start() flow.async_start()
execution.start() / execution.close() execution.async_start() / execution.async_close()
data.set_state(...) / data.emit(...) data.async_set_state(...) / data.async_emit(...)

Minimal async example

import asyncio
from agently import Agently

agent = Agently.create_agent()


async def main():
    response = (
        agent
        .input("Give me a title and two bullets.")
        .output({
            "title": (str, "Title", True),
            "items": [(str, "Bullet point", True)],
        })
        .get_response()
    )

    async for item in response.get_async_generator(type="instant"):
        if item.is_complete:
            print(item.path, item.value)

    final = await response.async_get_data()
    print(final)


asyncio.run(main())

get_response() returns a reusable ModelResponse. You can pull text, structured data, and metadata from the same response without re-issuing the request — see Model Response.

Async + TriggerFlow

For event-driven orchestration, prefer:

See TriggerFlow Lifecycle.

Don’t oversell async

Async First improves concurrency, service composition, and progressive UX. It does not make a single isolated model request faster. The wall-clock latency of one request is bounded by the model, not by sync vs async.