SkillAgentSearch skills...

Agently

[GenAI Application Development Framework] 🚀 Build GenAI application quick and easy 💬 Easy to interact with GenAI agent in code using structure data and chained-calls syntax 🧩 Use Event-Driven Flow *TriggerFlow* to manage complex GenAI working logic 🔀 Switch to any model without rewrite application code

Install / Use

/learn @AgentEra/Agently

README

<img width="640" alt="image" src="https://github.com/user-attachments/assets/c645d031-c8b0-4dba-a515-9d7a4b0a6881" />

Agently 4 🚀

Build production‑grade AI apps faster, with stable outputs and maintainable workflows.

English Introduction | 中文介绍

license PyPI version Downloads GitHub Stars Twitter Follow <a href="https://doc.weixin.qq.com/forms/AIoA8gcHAFMAScAhgZQABIlW6tV3l7QQf"> <img alt="WeChat" src="https://img.shields.io/badge/WeChat%20Group-Join-brightgreen?logo=wechat&style=flat-square"> </a>

<p align="center"> <a href="https://github.com/AgentEra/Agently/discussions"><img src="https://img.shields.io/badge/💬_Community-Join-blueviolet?style=for-the-badge"></a> <a href="https://agently.tech"><img src="https://img.shields.io/badge/🌐_Website-Docs-brightgreen?style=for-the-badge"></a> <a href="https://github.com/AgentEra/Agently/issues"><img src="https://img.shields.io/badge/🐛_Issues-Report-red?style=for-the-badge"></a> </p>
<p align="center"> <b>🔥 <a href="https://agently.tech/docs">Latest Docs</a> | 🚀 <a href="#quickstart">5‑minute Quickstart</a> | 💡 <a href="#-core-features">Core Features</a></b> </p>

Official Skills

Official installable Agently skills are now published at:

  • GitHub: https://github.com/AgentEra/Agently-Skills
  • Install: npx skills add AgentEra/Agently-Skills

What you get after installing:

  • Better implementation routing for real Agently work, from single-request design to TriggerFlow, multi-agent, MCP, tools, session, and FastAPI integration
  • Ready-to-use skill guidance for common production tasks instead of re-explaining framework concepts in every coding session
  • Migration playbooks for LangChain and LangGraph, so existing agent systems can be translated into Agently faster
  • A higher-quality coding-agent experience, because the skills package gives the agent concrete Agently patterns, boundaries, and recommended implementation paths

📚 Quick Links

  • Docs (EN): https://agently.tech/docs
  • Docs (中文): https://agently.cn/docs
  • Agent Systems Playbook (EN): https://agently.tech/docs/en/agent-systems/overview.html
  • Agent Systems Playbook (中文): https://agently.cn/docs/agent-systems/overview.html
  • Official Agently Skills: https://github.com/AgentEra/Agently-Skills
  • Install Agently Skills: npx skills add AgentEra/Agently-Skills

Optional Companion Package: Agently Devtools

agently-devtools is a separate companion package for runtime observation and developer tooling.

  • Install: pip install agently-devtools
  • Dependency direction: agently-devtools -> agently
  • Compatibility line: agently-devtools 0.1.x targets agently >=4.0.9,<4.1.0
  • Integration entrypoints: ObservationBridge and create_local_observation_app

The DevTools package is optional and does not add a reverse dependency from agently back to agently-devtools.

🤔 Why Agently?

Many GenAI POCs fail in production not because models are weak, but because engineering control is missing:

| Common challenge | How Agently helps | |:--|:--| | Output schema drifts, JSON parsing fails | Contract‑first output control with output() + ensure_keys | | Workflows get complex and hard to maintain | TriggerFlow orchestration with to / if / match / batch / for_each | | Multi‑turn state becomes unstable | Session (v4.0.8.1+) with session activation, context window control, custom memo strategy, and persistence | | Tool calls are hard to audit | Tool logs via extra.tool_logs | | Switching models is expensive | OpenAICompatible unified model settings |

Agently turns LLM uncertainty into a stable, testable, maintainable engineering system.

✨ Core Features

1) 📝 Contract‑first Output Control

Define the structure with output(), enforce critical keys with ensure_keys.

result = (
    agent
    .input("Analyze user feedback")
    .output({
        "sentiment": (str, "positive/neutral/negative"),
        "key_issues": [(str, "issue summary")],
        "priority": (int, "1-5, 5 is highest")
    })
    .start(ensure_keys=["sentiment", "key_issues[*]"])
)

2) ⚡ Structured Streaming (Instant)

Consume structured fields as they are generated.

response = (
    agent
    .input("Explain recursion and give 2 tips")
    .output({"definition": (str, "one sentence"), "tips": [(str, "tip")]})
    .get_response()
)

for msg in response.get_generator(type="instant"):
    if msg.path == "definition" and msg.delta:
        ui.update_definition(msg.delta)
    if msg.wildcard_path == "tips[*]" and msg.delta:
        ui.add_tip(msg.delta)

3) 🧩 TriggerFlow Orchestration

Readable, testable workflows with branching and concurrency.

(
    flow.to(handle_request)
    .if_condition(lambda d: d.value["type"] == "query")
    .to(handle_query)
    .elif_condition(lambda d: d.value["type"] == "order")
    .to(check_inventory)
    .to(create_order)
    .end_condition()
)

4) 🧠 Session (Multi‑turn Context, v4.0.8.1+)

Built-in SessionExtension with activate_session/deactivate_session, context window control, custom memo strategies, and JSON/YAML persistence.

from agently import Agently

agent = Agently.create_agent()

# Activate per-user session (reused by session_id)
agent.activate_session(session_id="demo_user_1001")

# Optional: default window trimming by max length
agent.set_settings("session.max_length", 12000)

# Optional: custom strategy (analysis -> resize)
session = agent.activated_session
assert session is not None

def analysis_handler(full_context, context_window, memo, session_settings):
    if len(context_window) > 6:
        return "keep_last_six"
    return None

def keep_last_six(full_context, context_window, memo, session_settings):
    return None, list(context_window[-6:]), memo

session.register_analysis_handler(analysis_handler)
session.register_resize_handler("keep_last_six", keep_last_six)

5) 🔧 Tool Calls + Logs

Tool selection and usage are logged in extra.tool_logs.

@agent.tool_func
def add(a: int, b: int) -> int:
    return a + b

response = agent.input("12+34=?").use_tool(add).get_response()
full = response.get_data(type="all")
print(full["extra"]["tool_logs"])

6) 🌐 Unified Model Settings (OpenAICompatible)

One config for multiple providers and local models.

from agently import Agently

Agently.set_settings(
    "OpenAICompatible",
    {
        "base_url": "https://api.deepseek.com/v1",
        "model": "deepseek-chat",
        "auth": "DEEPSEEK_API_KEY",
    },
)

🚀 Quickstart

Install

pip install -U agently

Requirements: Python >= 3.10, recommended Agently >= 4.0.7.2

5‑minute example

1. Structured output

from agently import Agently

agent = Agently.create_agent()

result = (
    agent.input("Introduce Python in one sentence and list 2 advantages")
    .output({
        "introduction": (str, "one sentence"),
        "advantages": [(str, "advantage")]
    })
    .start(ensure_keys=["introduction", "advantages[*]"])
)

print(result)

2. Workflow routing

from agently import TriggerFlow, TriggerFlowEventData

flow = TriggerFlow()

@flow.chunk
def classify_intent(data: TriggerFlowEventData):
    text = data.value
    if "price" in text:
        return "price_query"
    if "feature" in text:
        return "feature_query"
    if "buy" in text:
        return "purchase"
    return "other"

@flow.chunk
def handle_price(_: TriggerFlowEventData):
    return {"response": "Pricing depends on the plan..."}

@flow.chunk
def handle_feature(_: TriggerFlowEventData):
    return {"response": "Our product supports..."}

(
    flow.to(classify_intent)
    .match()
    .case("price_query")
    .to(handle_price)
    .case("feature_query")
    .to(handle_feature)
    .case_else()
    .to(lambda d: {"response": "What would you like to know?"})
    .end_match()
    .end()
)

print(flow.start("How much does it cost?"))

✅ Is Your App Production‑Ready? — Release Readiness Checklist

Based on teams shipping real projects with Agently, this production readiness checklist helps reduce common risks before release.

| Area | Check | Recommended Practice | | :--- | :--- | :--- | | 📝 Output Stability | Are key interfaces stable? | Define schemas with output() and lock critical fields with ensure_keys. | | ⚡ Real‑time UX | Need updates while generating? | Consume type="instant" structured streaming events. | | 🔍 Observability | Tool calls auditable? | Inspect extra.tool_logs for full arguments and results. | | 🧩 Workflow Robustness | Complex flows fully tested? | Unit test each TriggerFlow branch and concurrency limit with expected outputs. | | 🧠 Memory & Context | Multi‑turn experience consistent? | Define Session/Memo summary, trimming, and persistence policies. | | 📄 Prompt Management | Can logic evolve safely? | Version and configure prompts to keep changes traceable. | | 🌐 Model Strategy | Can you switch or downgrade models? | Centralize settings with OpenAICompatible for fast provider switching. | | 🚀 Performance & Scale | Can it handle concurrency? | Validate async performance in real web‑service scenarios. | | 🧪 Quality Assurance | Regression tests complete?

View on GitHub
GitHub Stars1.5k
CategoryDevelopment
Updated12h ago
Forks173

Languages

Python

Security Score

100/100

Audited on Mar 28, 2026

No findings