AI Module
The AI Agents module is a first-class framework built into Zango for running Large Language Models directly inside your multi-tenant business applications. It handles provider credentials, prompt templating, tool execution, memory, cost tracking, and invocation history, all scoped per tenant and manageable from the App Panel without touching code.
This is what makes Zango a platform for Agentic AI business applications, not just a place to call an API. An agent here runs with the full context of your app: the right tenant schema, workflow state, permissions, secrets, and background processing. The model can read live data and act on it safely, because every tool it calls is your own audited Python code.
What the module provides
LLM Providers
Connect OpenAI or Anthropic by storing an encrypted API key once in the App Panel. Every tenant manages its own providers independently.
Agents
A named LLM configuration: provider, model, prompts, temperature, token limits, output format, and an attached set of tools. Resolved by name at runtime from the current tenant's schema.
Tools
Python functions decorated with @tool. The model invokes them to fetch live data, run
calculations, or update records, executed inside the correct tenant schema.
Structured Output
Configure an agent to return JSON that conforms to a schema you define, ready to feed into a pipeline.
Short-term Memory
Per-session conversation history so the agent keeps context across multiple agent.run()
calls using the same session_id.
Invocation History & Cost
Every run is logged with rendered prompts, tool calls, the final response, token counts, and USD cost. Cumulative spend is tracked per agent.
Attach guardrail rules to an agent to filter or block inputs and outputs that violate the constraints you define.
Architecture
Request / Task / Shell
└── get_agent("agent-name") # resolves AppLLMAgent from tenant schema
└── agent.run(variables={...}) # renders prompts, calls LLM
├── Tool call → @tool fn # executed in tenant schema
└── Returns AgentResponse
├── .content
├── .cost_usd
└── .usage (input_tokens, output_tokens)
Zango's tenant middleware sets the DB schema from the request hostname before your view runs.
get_agent() and all tool ORM queries automatically use that schema, so there is no manual
connection.set_tenant() in views or tasks.
What the platform gives the AI for free
| Integration point | What the AI module gains |
|---|---|
| Multi-tenancy | Agent tools run in the correct tenant schema automatically. |
| Workflow state | Tools read WorkflowTransaction history, the full audit trail of every status change. |
| Permissions | Agent endpoints are views; views are policy-gated. AI access uses the same role system as everything else. |
| Secrets | Provider API keys live in Secrets, accessed via get_secret(). |
| Async tasks | agent.run() inside a task becomes an autonomous background AI worker. |
| Communication | An agent can trigger an SMS or email by calling the Communication package from a @tool. |
Quick workflow
Describe the agent you want and the Claude plugin builds the whole chain for you through the platform API. Under the hood it sets up:
- An LLM Provider so the platform can reach OpenAI or Anthropic.
- The Prompts that define the agent's instructions.
- Tools written with
@toolin your app code, synced automatically. - An Agent that ties the provider, model, prompts, and tools together.
- The call site: run the agent from a view, task, or shell.
- Invocation logs for debugging and cost analysis.