Skip to main content

Lyzr AI + AxonFlow Integration

How to use this doc:

  • Understanding the problem? Read sections 1–4
  • Ready to implement? Jump to Integration Pattern

What Lyzr Does Well

Lyzr AI is an enterprise agent framework with built-in Responsible AI capabilities. Its strengths are compelling for enterprise deployment:

Agent Studio: No-code/low-code interface for building AI agents. Business users can create agents without engineering support.

Pre-Built Templates: Ready-to-use agents for HR, Sales, Support, Finance, and more. Deploy departmental agents in hours, not weeks.

HybridFlow Architecture: Blend LLMs with traditional ML models. Combine the reasoning of LLMs with the precision of specialized models.

Model-Agnostic Design: Avoid vendor lock-in. Swap between OpenAI, Anthropic, and other providers.

Responsible AI Modules: Built-in guardrails for bias detection and content safety.

Safe AI Modules: Patterns for human oversight and escalation.


What Lyzr Doesn't Try to Solve

Lyzr focuses on agent creation and deployment. These concerns are explicitly out of scope:

Production RequirementLyzr's Position
Real-time policy enforcementNot provided—relies on pre-configured guardrails
Cross-system audit trailsNot addressed—logging is agent-specific
Per-agent cost attributionNot tracked—requires external monitoring
PII blocking at inference timeRelies on Safe AI modules—not automatic
SQL injection preventionNot provided—must implement in agent logic
Centralized policy managementNot addressed—policies are per-agent
Token budget enforcementNot provided—agents can consume unlimited tokens

This isn't a criticism—it's a design choice. Lyzr handles agent creation. Governance at scale is a separate concern.


Where Teams Hit Production Friction

Based on real enterprise deployments, here are the blockers that appear after the prototype works:

1. The 50-Agent Sprawl

A company deploys 50 Lyzr agents across departments. Each has different configurations. Auditors ask:

  • Are all agents following the same policies?
  • Which agents have access to PII?
  • What's the total cost across all agents?

Lyzr deployed each agent successfully. Centralized governance wasn't in scope.

2. The Department Cost Surprise

Three departments use Lyzr agents heavily. The combined bill arrives. Who spent what? Lyzr has no built-in cross-agent cost attribution.

3. The Audit Request

Auditor: "Show me every request that touched customer data in the last 90 days."
Team: "We have logs from each agent, but they're in different formats..."
Auditor: "That's not a unified audit trail."

4. The Security Review Block

Security review: BLOCKED
- No centralized audit trail
- Policy enforcement varies by agent
- No unified PII detection
- Cost controls are per-agent
- Access control requires manual setup per agent

The Lyzr agents work perfectly. The governance story doesn't scale.

5. The "Who Changed What?" Question

An agent's behavior changed. Nobody knows when or who made the change. Lyzr provides agent versioning, but policy changes aren't tracked centrally.


How AxonFlow Plugs In

AxonFlow doesn't replace Lyzr. It sits underneath it—providing the governance layer that unifies all Lyzr agents:

┌─────────────────┐
│ Your App │
└────────┬────────┘

v
┌─────────────────┐
│ Lyzr Agents │ <-- HR, Sales, Support, Finance...
└────────┬────────┘

v
┌─────────────────────────────────┐
│ AxonFlow │
│ ┌───────────┐ ┌────────────┐ │
│ │ Policy │ │ Audit │ │
│ │ Enforce │ │ Trail │ │
│ └───────────┘ └────────────┘ │
│ ┌───────────┐ ┌────────────┐ │
│ │ PII │ │ Cost │ │
│ │ Detection│ │ Control │ │
│ └───────────┘ └────────────┘ │
└────────────────┬────────────────┘

v
┌─────────────────┐
│ LLM Provider │
└─────────────────┘

What this gives you:

  • Every agent action logged in a unified audit trail
  • PII detected and blocked across all agents
  • SQL injection attempts blocked regardless of agent
  • Cost tracked per agent, per department, per user
  • Full audit trail queryable across all agents at once

What stays the same:

  • Your Lyzr agents don't change
  • Agent Studio workflows work as before
  • No changes to agent configurations

Integration Pattern

Wrap Lyzr agent calls with AxonFlow governance:

import os
import time
from axonflow import AxonFlow, TokenUsage


class GovernedLyzrAgent:
"""Lyzr agent wrapper with AxonFlow governance."""

def __init__(
self,
lyzr_agent,
agent_type: str = "lyzr",
):
self.lyzr_agent = lyzr_agent
self.agent_type = agent_type

def run(
self,
user_token: str,
query: str,
context: dict = None,
) -> str:
"""Execute Lyzr agent with AxonFlow governance."""
start_time = time.time()

with AxonFlow.sync(
endpoint=os.getenv("AXONFLOW_ENDPOINT", "http://localhost:8080"),
client_id=f"lyzr-{self.agent_type}",
client_secret=os.getenv("AXONFLOW_CLIENT_SECRET"),
) as axonflow:
# 1. Pre-check
ctx = axonflow.get_policy_approved_context(
user_token=user_token,
query=query,
context={
**(context or {}),
"agent_type": self.agent_type,
"framework": "lyzr",
},
)

if not ctx.approved:
raise PermissionError(f"Blocked: {ctx.block_reason}")

try:
# 2. Execute Lyzr agent
response = self.lyzr_agent.run(query)
latency_ms = int((time.time() - start_time) * 1000)

# 3. Audit
axonflow.audit_llm_call(
context_id=ctx.context_id,
response_summary=response[:200] if len(response) > 200 else response,
provider="openai",
model="gpt-4",
token_usage=TokenUsage(
prompt_tokens=100, completion_tokens=50, total_tokens=150
),
latency_ms=latency_ms,
metadata={"agent_type": self.agent_type},
)

return response

except Exception as e:
latency_ms = int((time.time() - start_time) * 1000)
axonflow.audit_llm_call(
context_id=ctx.context_id,
response_summary=f"Error: {str(e)}",
provider="openai",
model="gpt-4",
token_usage=TokenUsage(
prompt_tokens=0, completion_tokens=0, total_tokens=0
),
latency_ms=latency_ms,
metadata={"error": str(e)},
)
raise


# Usage
governed_agent = GovernedLyzrAgent(
lyzr_agent=your_lyzr_agent,
agent_type="lyzr-hr",
)

response = governed_agent.run(
user_token="user-jwt-token",
query="What is our PTO policy?",
context={"department": "hr"},
)

More Examples

PatternLanguageLink
Multi-Department FactoryPythonlyzr/python
Decorator PatternPythonlyzr/decorator
TypeScript ServiceTypeScriptlyzr/typescript