Overview
Agently is an open-source Python framework, maintained by AgentEra, for building the backend of an AI application. Its focus is the engineering layer around model calls: a request is composed from named prompt slots (role, info, instruct, input, output), the expected result shape is declared with `.output(...)`, and the framework owns parsing, required-key checks, retries and validation handlers instead of relying only on a provider's native JSON mode. The same request contract sits in front of every model provider, so the project's stated goal is that swapping DeepSeek for a local Ollama model or Claude does not change what downstream business code receives.
On top of that request layer sit several opt-in pieces. Actions are model-callable capabilities — decorated local functions, MCP servers, built-in Search and Browse packages, and managed Python, shell, Node.js and SQLite runtimes — and every call leaves a structured action log. TriggerFlow is the workflow layer: an event- and signal-driven engine with branching, `for_each` fan-out, pause/resume, human-in-the-loop events, save/load and close snapshots. Dynamic Task turns a model- or app-generated DAG into a validated task graph that runs on TriggerFlow, and Session keeps bounded multi-turn memory.

Agently also exposes structure while a model is still streaming: its `instant` mode emits events per output field, so a UI or SSE route can render a partial structured answer before the final token. A `FastAPIHelper` publishes agents, requests and TriggerFlow executions over POST, SSE or WebSocket, and the optional `agently-devtools` package adds a local console for runtime observation, evaluations and a playground. The core is Apache-2.0 licensed under an open-core model, requires Python 3.10 or newer, and is published on PyPI as `agently`.
What it does
- Contract-first structured output — `.output(...)` schemas with required fields, `ensure_keys`, parser feedback, retries and validation handlers, also expressible in YAML or JSON prompt files
- One request contract across providers: an OpenAI-compatible requester (OpenAI, DeepSeek, Qwen, Ollama, Kimi, GLM and others) plus an Anthropic-compatible requester, with model pools and API-key pools for failover
- `instant` structured streaming that emits an event per field path as the model generates, for live UIs and SSE routes
- Actions runtime covering decorated Python functions, MCP servers, built-in Search/Browse, and managed Python, shell, Node.js and SQLite resources, with structured action logs
- TriggerFlow event-driven workflows with branching, fan-out, external events, pause/resume, persistence and close snapshots, plus Dynamic Task for validated DAG plans
- Service and tooling surfaces: FastAPIHelper for POST/SSE/WebSocket exposure and the optional agently-devtools console for observation and evaluation
Getting started
Agently is a Python package (Python 3.10+). Any OpenAI-compatible endpoint works as the model; the README's quickstart uses DeepSeek's hosted API or a local Ollama model.
Install
Install or upgrade the package from PyPI.
pip install -U agentlyConfigure a model and ask for structured output
Point Agently at an OpenAI-compatible endpoint, create an agent, and declare the result shape with .output(). The third tuple item marks a field as required.
from agently import Agently
Agently.set_settings(
"OpenAICompatible",
{
"base_url": "https://api.deepseek.com/v1",
"model": "deepseek-v4-flash",
"api_key": "${ENV.DEEPSEEK_API_KEY}",
"model_type": "chat",
},
)
agent = Agently.create_agent()
result = (
agent
.input("Introduce Python in one sentence and state three distinct strengths.")
.output({
"intro": (str, "one sentence", True),
"strengths": {
"first": (str, "first strength", True),
"second": (str, "second strength", True),
"third": (str, "third strength", True),
},
})
.get_result()
)
print(result.get_data())Or run against a local model
Swap only the provider settings to use Ollama; the request code stays the same.
# ollama pull qwen2.5:7b
Agently.set_settings(
"OpenAICompatible",
{
"base_url": "http://127.0.0.1:11434/v1",
"model": "qwen2.5:7b",
"api_key": "ollama",
"model_type": "chat",
},
)Give the agent an action
Decorate a function with @agent.action_func and register it; the model can call it and the calls are recorded in the result's action logs.
@agent.action_func
def calculate_total(price: float, quantity: int) -> float:
"""Calculate an order total."""
return price * quantity
agent.use_actions(calculate_total)
result = agent.input("Use the available action to calculate 19.5 * 4, then explain the result.").get_result()
print(result.get_text())Observe runs with DevTools (optional)
Install the companion devtools package, start its local console, and attach an ObservationBridge in your app to see each run.
pip install -U agently agently-devtools
agently-devtools start
Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Reach for it when an AI-backed API must return a stable JSON shape even as you switch between hosted and local models
- Reach for it to stream partially-filled structured answers into a chat UI or SSE endpoint before the model finishes
- Reach for it when a multi-step AI process needs branching, fan-out, human approval pauses and restart-safe state in plain Python

- Reach for it to let a model operate business objects through a constrained set of logged actions rather than free-form tool calls
How Agently compares
Agently alongside other open-source app frameworks tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| LangChain | ★ 148k | A widely used Python and JavaScript framework for building LLM applications by composing models, prompts, tools, retrievers, and memory into chains. |
| LlamaIndex | ★ 52.6k | A data framework for connecting language models to your own documents and data sources, with built-in agent and retrieval (RAG) tooling. |
| Haystack | ★ 26.8k | An orchestration framework from deepset for building modular LLM pipelines and agents for search, RAG, and question answering. |
| Jina | ★ 21.9k | Jina-serve is a Python framework for building, scaling, and deploying AI services and multi-step pipelines that communicate over gRPC, HTTP, and WebSockets. |
| RocketRide | ★ 17.7k | MIT-licensed AI pipeline builder and multithreaded C++ runtime: design .pipe JSON workflows visually in VS Code from 100+ nodes (LLMs, vector DBs, OCR, agents), then call them via Python/TypeScript SDKs or MCP. |
| LLM | ★ 12.6k | Simon Willison's plugin-extensible CLI and Python library for prompting remote and local models, logging every prompt and response to SQLite, and generating embeddings. |
| Prompt Flow | ★ 11.3k | Microsoft's toolkit for building LLM apps as executable flows that link prompts, Python code, and tools, with tracing, batch evaluation, and deployment. |
| Agently | ★ 1.7k | Python framework for AI service backends with output contracts, observable actions and event-driven workflows |