Agentic: Production-Ready AI Agent Framework with Event-Driven Observability
This article analyzes the Agentic framework's architecture, showing how its event-driven design, Ray-based runtime, and typed event streams solve production challenges like hallucination, debugging, and human-in-the-loop that first-generation agent frameworks ignore.
Introduction: From Demo to Production
Developers building AI agents often experience a gap: demos run smoothly on laptops with a few tools, but production exposes concurrency, network complexity, and stability demands. Common failures include agents hallucinating answers instead of querying databases, tool timeouts freezing the agent without retries, and opaque execution traces that hide which step failed or why.
First-generation frameworks like LangChain and AutoGen prioritize quick demos over production hardening. They treat agents as black boxes that return final text, lacking observability, configuration management, and multi-agent collaboration primitives.
Core Pain Points Agentic Addresses
Black-box problem : Agents return only final text; intermediate tool calls, latencies, and failure reasons are invisible.
Configuration problem : Tool parameters and API keys hardcoded in source, requiring code changes and redeploys per environment.
Collaboration problem : No built-in inter-agent communication or human-in-the-loop approval flows; developers must build custom orchestration.
Agentic Core Architecture
The Agentic team states their agent loop is only a few hundred lines directly calling LLM APIs, avoiding opaque abstractions. The architecture makes three deliberate choices:
Minimal abstractions : Only four core concepts — Agent, Tool, Run, Thread — no complex DAG assembly required.
Event-driven : Agents emit typed events ( ToolCallEvent, ToolResultEvent, LLMResponseEvent, TextEvent) enabling streaming UIs, background notifications, and observability.
Built on Ray : Each agent runs as a Ray Actor with isolated state and message queue, providing native concurrency and fault tolerance.
Engineering Enhancements in the ReAct Loop
Agentic augments the standard ReAct (Reasoning + Acting) loop with three engineering features:
Async, configurable tool execution : Tools are independent components with configurable timeout, retry, and authentication — not bare functions.
Typed event stream : Every step emits structured events ( ToolCallEvent, ToolResultEvent, LLMResponseEvent), forming the basis for tracing and debugging.
Native human-in-the-loop : Agents can pause indefinitely awaiting human approval (via email or webhook) instead of blocking or erroring.
Building a "No-Hallucination" Assistant: Step-by-Step
4.1 Define Tools with Strict Descriptions
from agentic.common import Agent, Tool
# Strict description forces model to use this tool for sales data
def query_db(sql_query: str) -> str:
"""
Query sales database.
When answering questions about sales, orders, or amounts, you MUST call this tool.
"""
# Simulated DB query
return "Yesterday's sales were 12000 CNY."
sales_tool = Tool(
name="query_sales_db",
description="售商数据的唯一工具",
function=query_db
)4.2 Construct Agent with System Instructions
sales_agent = Agent(
name="销售助手",
instructions="""
You are a data analysis assistant.
Rules:
1. For any question involving specific sales data, you MUST first call query_sales_db.
2. NEVER fabricate data without calling the tool.
3. If the tool fails, reply "Data retrieval failed" — do not invent.
""",
tools=[sales_tool],
model="gpt-4o" # Backed by LiteLLM, swap models freely
)4.3 Run and Consume Event Stream
run = sales_agent.run("昨天销售额多少?")
for event in run.stream_events():
if event.event_type == "ToolCallEvent":
print(f"[System Log] Agent decided to call tool: {event.tool_name}")
elif event.event_type == "ToolResultEvent":
print(f"[System Log] Tool returned: {event.result}")
elif event.event_type == "TextEvent":
# Stream to user
print(event.content, end="", flush=True)If the model hallucinates and skips the tool, the event stream will lack a ToolCallEvent, making the violation immediately visible in logs. This is the essence of engineering control .
Debugging Agent Failures with Structured Traces
Because Agentic emits structured event logs, you can feed a failed trace to an LLM for root-cause analysis.
Step 1: Provide Trace to AI
"This is a failed Agent execution record. Help me analyze why it did not call query_sales_db before answering."
Step 2: AI Analyzes and Locates Root Cause
"In the log, the first LLM response did not trigger a ToolCallEvent ; the agent directly emitted a TextEvent . This indicates the model ignored the system prompt's mandatory tool-use rule. Suggested fixes: Your tool description may not be compelling enough for the model. Strengthen the system prompt, e.g., 'Failure to call the tool will cause system crash.'"
Step 3: Generate Regression Test
"Write a pytest test that simulates the model not calling the tool, ensuring the agent raises an exception."
The AI produces a test case that catches this regression in CI/CD.
Pros and Cons
Pros
Minimal, transparent abstractions : Four core concepts; loop code is readable for debugging.
Event-driven streaming : Typed events enable multi-channel, background, and streaming UIs.
Native human-in-the-loop : Agents pause for approval via email/webhook without custom loops.
Built-in engineering primitives : Logging, tracing, context management, tool auth included.
Ray Actor runtime : Native async and concurrency for complex multi-agent teams.
Cons
Newer ecosystem : Fewer third-party integrations than LangChain.
Ray learning curve : Understanding Actor model and distributed execution takes time.
Python version constraints : Stable on Python 3.12; 3.13+ unsupported due to Ray compatibility.
Mindset shift required : Developers used to imperative if/else or chain calls must adopt event-subscription async patterns.
Applicability Matrix
Production-grade agent services — ✅✅✅ Strongly recommended: Event streams, tracing, human-in-the-loop are essential.
Enforcing agent behavior (anti-hallucination) — ✅✅✅ Strongly recommended: Configurable tools + prompts prevent fabrication.
Multi-agent collaboration teams — ✅✅✅ Strongly recommended: Ray Actors provide natural concurrency and state isolation.
Streaming / background notifications — ✅✅✅ Strongly recommended: Multi-channel event flow built-in.
Quick demos / prototypes — ⚠️ Evaluate: LangChain may produce results faster.
Heavy third-party plugin needs — ⚠️ Evaluate: Ecosystem still catching up.
Conclusion
First-generation frameworks solved "can it run?" Agentic solves "once running, can I see what it's doing, control it, and keep it stable?" Event streams make every step visible; traces enable post-mortem analysis; human-in-the-loop allows intervention at critical points.
References:
GitHub: https://github.com/supercog-ai/agentic Docs:
https://supercog-ai.github.io/agentic/Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Su San Talks Tech
Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
