█

AI/TLDR

Agently

Python framework for AI service backends with output contracts, observable actions and event-driven workflows

App FrameworksOpen source
Language
Python
License
Apache-2.0
$pip install -U agently

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.

A Markdown daily report rendered by the Daily News Collector workflow built on Agently, with a sidebar listing the four stages topic to outline, search and pick, browse and summarize, and render markdown report next to a news entry with source, date and summary
Daily News Collector, a public project built on Agently: a TriggerFlow pipeline that goes from a topic to an editable Markdown report.Agently website ↗

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.

bashbash
pip install -U agently

Configure 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.

pythonpython
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.

pythonpython
# 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.

pythonpython
@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.

bashbash
pip install -U agently agently-devtools
agently-devtools start
The Agently DevTools Runtime Observation console with scope filters, a connection panel pointing at a local endpoint, a search box, a selected completed workflow run named daily-news-topic-scan with its run ids and 126 ms duration, and an ObservationBridge code snippet
agently-devtools Runtime Observation: each run shows up with its ids, status and duration once an ObservationBridge is attached.Agently website ↗

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
An Agently Gradio chatbot controlling two cameras: it reports camera status, refuses a request to turn on a light as outside its capabilities, and executes a zoom request as a list of operations with their results
Talk to Control: the model plans operations over a fixed set of actions, executes them, and declines anything outside that set.Agently website ↗
  • 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.

ToolStarsWhat it does
LangChain★ 148kA widely used Python and JavaScript framework for building LLM applications by composing models, prompts, tools, retrievers, and memory into chains.
LlamaIndex★ 52.6kA data framework for connecting language models to your own documents and data sources, with built-in agent and retrieval (RAG) tooling.
Haystack★ 26.8kAn orchestration framework from deepset for building modular LLM pipelines and agents for search, RAG, and question answering.
Jina★ 21.9kJina-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.7kMIT-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.6kSimon 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.3kMicrosoft's toolkit for building LLM apps as executable flows that link prompts, Python code, and tools, with tracing, batch evaluation, and deployment.
Agently★ 1.7kPython framework for AI service backends with output contracts, observable actions and event-driven workflows