Community Blog With PostgreSQL Firmly in Place as the Data Foundation, What Else Do Agents Need to Truly Run?

With PostgreSQL Firmly in Place as the Data Foundation, What Else Do Agents Need to Truly Run?

This article introduces a unified AI Agent architecture built on RDS PostgreSQL that integrates Supabase, a Knowledge Graph, and an In-DB Agent Runtime behind a single gateway.

By Xin Qiu (Ri Jin)

Foreword: A Look Back at Part One — PostgreSQL as the Data Foundation for Agents

In our previous post, “What Kind of PostgreSQL Do We Need When 80% of Databases Are Automatically Created by AI?”, we explored a fundamental question: what should the data foundation look like in the era of AI agents?

Our answer can be summarized along three main themes.

• Multimodality — standard tables host business objects and states; jsonb handles unstructured inputs and outputs like prompts, tool parameters, and trace metadata; pgvector stores embeddings to build the agent’s semantic perception; and the AGE graph extension manages entities and relationships to weave the agent’s logical reasoning capabilities. A single PG instance can cover the vast majority of modalities in an agent’s data environment.

• Transactional guarantees — the ACID properties, constraints, Write-Ahead Log (WAL), and Point-In-Time Recovery (PITR) provided by the relational database foundation make conventional row-store data a reliable source of truth for agents, avoiding “partial successes,” state drift, and duplicate triggers.

• Cloud enhancements — from database-per-tenant isolation, PgBouncer, and SQL throttling, to data branching in seconds based on copy-on-write cloud disks, and further to kernel-level deep optimizations for vector and graph capabilities, ApsaraDB RDS for PostgreSQL (RDS PG) raises the benefits of open-source PG to production grade.

But as Part One noted at the end, the data foundation is not the finish line. A working agent system needs more than a database: it needs a set of data interfaces the agent can call directly instead of hardcoding SQL, a cognitive hub that accumulates enterprise knowledge and business semantics, and a runtime that executes code securely. If these three pieces are selected, operated, and wired up for authentication separately, engineering complexity quickly spirals out of control.

So we built these three pieces into a unified agent trio: Supabase + Knowledge Graph + In-DB Agent Runtime, all running on the same RDS PostgreSQL instance and exposed externally through a single Kong gateway. This post is a complete breakdown of these capabilities.

2 One Gateway, One Database: The Integration Blueprint for the Trio

What does an agent need in real-world production? It needs to access business tables, retrieve knowledge and memories, run Python analytics, and execute lightweight logic when events fire. In a traditional architecture, these four tasks map to four separate services, four authentication schemes, four SDKs, and four throttling policies — and the agent has to maintain separate credentials for each integration.

The path we chose is One Gateway, One Database —

• At the bottom, there is only one database: RDS PostgreSQL. It holds all structured, semi-structured, vector, graph, and file metadata, and leverages the extension ecosystem to cover retrieval, AI invocation, message queues, API exposure, and more. Data doesn’t move, SQL dialects don’t switch, and mental models don’t drift.

• At the top, there is only one gateway: a unified HTTP entry point based on Kong, exposing one stable address and one API key to the agent. REST / GraphQL, Auth, Storage, Realtime, RAG, Sandbox, and Edge Function are all routed through it — the agent never needs to know how many backend services sit behind it.

• In the middle sits the flexibly composable trio: Supabase is the agent’s data interface and the application backend for vibe coding; the Knowledge Graph is the agent’s brain and long-term memory, building a business semantic layer for enterprise data through Ontology; and the In-DB Agent Runtime is the agent’s hands, responsible for secure code execution and event-driven lightweight functions.

1

The trio is not three standalone modules that can only be “used separately” — they are interdependent and mutually empowering. All three share one PG instance, one set of permissions, and one gateway, which is exactly where the “1+1+1>3” synergy of this foundation comes from. The specific collaboration paths are covered in Section 6.

In practice, the agent only needs one gateway address and one API key to unlock the full capabilities of the trio.

3. Supabase: The agent's Data Interface × Vibe coding's Application Backend

RDS Supabase fully inherits the capability stack of open-source Supabase — auto-generated REST and GraphQL APIs, Auth, Storage, Realtime subscriptions, Edge Function, and the Studio visual console — and swaps the underlying layer for RDS PG, connects object storage to Object Storage Service (OSS), plugs AI capabilities into Alibaba Cloud Model Studio, and extends authentication with localized channels such as WeChat, Alipay, and Alibaba Cloud SMS, with the entire pipeline running inside an Alibaba Cloud VPC.

Within the agent platform, it plays two roles at once.

Role 1: The agent's Data Interface

For an agent, the most reliable way to operate on data is not to improvise a SQL statement on the spot, but to be handed a set of self-describing, bounded interfaces it can call directly as tools. That is precisely Supabase’s value as a data interface: it automatically maps a PG database into a layer of structured interfaces, landing squarely in the tool calling paradigm where LLMs excel.

Schema is the interface, and the interface is the documentation. REST/GraphQL APIs are generated automatically from table structures, complete with OpenAPI descriptions and typed SDKs. The agent doesn’t need to understand the underlying tables — it loads these self-describing interfaces directly as tools. Field types, parameter ranges, and accessible tables are clear at a glance, and the output space is explicitly bounded by the schema — shifting from “guessing SQL from natural language” to “calling APIs from interface definitions.”

Row Level Security (RLS) provides the safety net at the database layer. Unauthorized-access blocking is pushed down to PG, and multi-tenant / multi-agent isolation is handled uniformly by the database — zero code at the application layer.

Complex business logic is exposed as RPC through Database Functions. The agent calls them by signature — no SQL to understand, no complex logic crammed into the prompt.

The benefits of this interface layer don’t stop there — it also closes off a high-risk path on the security side. Industry lists of security anti-patterns for LLM applications have long flagged “feeding LLM output straight into SQL/Shell” as extremely risky: natural language mixed into LLM output can easily be parsed as executable commands by the downstream SQL layer, and prompt-to-SQL injection and data poisoning have been reproduced repeatedly in real production applications — the bar for such attacks is not high. When an agent faces only a set of interfaces bounded by the schema and backstopped by RLS, the injection surface narrows significantly — security is guaranteed by structure and permissions, not by the model’s self-discipline.

2

Role 2: A One-Stop BaaS for Vibe coding Platforms

Database, Auth, Storage, Edge Function, Realtime — the five-piece suite, all in one place. AI-generated full-stack applications can go live as soon as they are generated, with no need to build a custom data access layer. By bringing open-source Supabase to Alibaba Cloud — re-based on RDS PG + OSS + Model Studio + localized authentication — users keep the complete mental model of the open-source stack while gaining cloud-native stability, performance, and compliance.

The two roles share the same underpinnings — the same APIs, the same PG kernel, the same permission model. One RDS Supabase supports both growth curves: the agent data interface and the vibe coding application backend.

4 Knowledge Graph: The agent's Brain and Long-Context Memory

If Supabase lets the agent “fetch data,” the Knowledge Graph lets it “understand, remember, and reason.”

The paradigm for building agent memory is shifting from fragmented access (splitting memory into key-value or embedding fragments and retrieving by vector similarity — the more fragments, the noisier retrieval gets) to structured cognition (memory carried in files, semantically indexed by an Ontology, and retrieved through RAG). Mainstream knowledge management tools and AI coding agents have already validated this path at a small scale with local setups like “project-level rule files + memory directories + semantic graphs.” What differentiates the Knowledge Graph is the enterprise-grade cloud capabilities built on top — multi-tenant isolation, fine-grained permissions, multi-version management, and cross-agent sharing — all while sharing the same PG with business data.

It consists of three sub-capabilities, mapping neatly onto the tripartite division of human memory.

Knowledge Base RAG — The agent's Episodic Memory

It is not just a RAG retrieval pipeline — it is the agent’s private knowledge filing cabinet plus versioned memory store. Enterprise core documents and the agent’s structured memories (Markdown / JSON) are hosted in one place, with tenant-level isolation plus fine-grained permissions. A multimodal parsing engine covers PDF / Word / PPT / images / audio and video / code repositories. Uploading a file automatically triggers parsing, chunking, embedding, and ingestion. On the retrieval side, it fuses three-way recall — vector semantics, BM25 keywords, and structured filtering — topped with reranking. Multi-version file management lets the agent’s memory roll back to any historical version just like git, for rollback, A/B testing, or auditing.

One key engineering detail: file metadata, vectors, full-text indexes, and structured tags all live in the same PG instance — a single SQL statement can run a hybrid search of “vector similarity + keyword matching + permission filtering” with no cross-system stitching. And with RLS, multi-tenant / multi-agent permission isolation is pushed down to the database, so the application layer never re-implements it.

Ontology Modeling — The agent's Semantic Memory

RAG helps the agent “find relevant documents”; Ontology helps it understand how data relates — think of it as a semantic map of enterprise data. A raw database has only tables and fields (“customer table,” “order table”). On top of them, an Ontology defines a complete semantic network of entities, attributes, relationships, and rules. The database is the library’s bookshelves; the Ontology is the classification system + index cards + borrowing rules. With it, the agent can navigate the business instead of rummaging through tables one by one.

Ontology delivers three kinds of value:

• Consensus — eliminating semantic ambiguity. A “customer” is a “potential lead” in the sales system, a “paying account” in the finance system, and a “ticket initiator” in the customer service system; the Ontology defines it once and aligns it globally. Vast amounts of tacit knowledge in an enterprise (business rules, approval chains, metric definitions) move from “veteran employees’ heads” into machine-readable, explicit definitions. And when multiple agents collaborate on the same ontology, upstream and downstream never talk past each other about the same entity.

• Boundaries — constraining agent behavior. The Ontology defines the complete set of legitimate relationships, so the LLM cannot conjure out-of-bounds ones like “an intern approving the CEO’s expense report.” An agent can only access and modify the entities and fields its role permits in the ontology — a semantic-level permission layer above RLS. Every operation maps back to an ontology rule, forming a complete “decision path → rule basis” audit trail.

• Determinism — replacing probabilistic reasoning. Knowing “Zhang San → department manager” and “department manager → has approval authority” deterministically yields “Zhang San has approval authority” — no LLM call, no probabilistic bias, no token cost. Ask an LLM to do multi-hop reasoning over long relationship chains and it starts to “invent relationships” as hops accumulate — hallucinating connections that don’t exist from mere linguistic correlation. An Ontology graph query, by contrast, walks precisely along edges that actually exist, naturally supporting multi-hop traversal at any depth without fabricating anything. The agent first digests every deterministically solvable question with the Ontology, and hands the LLM only the parts that genuinely require creative judgment — significantly cutting LLM invocation costs.

This deterministic reasoning matters most in complex data analysis. BIRD, the authoritative Text-to-SQL benchmark (an end-to-end evaluation across nearly a hundred real business databases), shows human experts at 92.96% execution accuracy, the strongest model on the leaderboard at only 81.95%, and the general-purpose GPT-4 baseline at just 54.89% — and the more complex the query, with more nesting and joins, the lower the odds of writing the SQL correctly in one shot. The Ontology approach doesn’t gamble on getting that complex SQL right. It decomposes a complex analytical question into a set of small, deterministic, semantic atomic computations: walking hop by hop along entities and relationships that actually exist in the ontology, deducing deterministically by rule — every step simple, verifiable, and reusable. Moving from “generating one complex SQL statement” to “orchestrating a set of atomic computations,” accuracy no longer depends on model luck, and token consumption drops with it.

On the implementation side, Ontology is built on the Apache AGE extension for native in-PG graph storage and Cypher queries; the ontology schema, instance data, and reasoning rules all live in PG. As mentioned in Part One, the RDS PG team has made kernel-level enhancements to AGE — engineering optimizations on graph-query and DML hot paths that deliver 100x query and 10x DML performance gains while staying openCypher-compatible, with the optimizations continuously contributed back to the community. These graph capabilities are already in production across intelligent driving data mining, financial operations analysis, retail business diagnostics, real estate data governance, and AIOps fault diagnosis.

Skill Hub — The agent's Procedural Memory

What’s hardest to accumulate in an enterprise is usually not data but “how the seasoned experts do things.” Skill Hub stores atomic analysis templates, operations runbooks, and industry best practices as structured Skills, with semantic recall, similarity-based recommendation, and multi-version management — so a new agent knows how to do the job out of the box instead of reasoning from scratch every time. The protocol layer is compatible with mainstream Skill definitions, so skills accumulated in existing ecosystems migrate in at low cost.

The three sub-capabilities chain into a clear cognitive path for the agent: knowing what (RAG retrieval) → understanding why (Ontology reasoning) → knowing how (Skill Hub accumulation and invocation).

3

5. In-DB Agent Runtime: Execution Hands Close to the Data

The third piece of the trio is the runtime, and its job sounds plain: run code securely. But in agent scenarios, this plain job picks up several new requirements: concurrent spin-up in seconds (every session spins up its own sandbox), data proximity (avoid shuttling large datasets back and forth between the agent, the runtime, and the DB), strong isolation (agent-generated code is untrusted), multi-language support (Python / TypeScript / Bash / Java all need coverage), and a lifecycle bound to the conversation (the sandbox is reclaimed automatically when the conversation ends, or can stay resident 24/7).

The defining trait of the In-DB Agent Runtime is data proximity — it works hand in hand with the PG data modules to minimize cross-service data movement. Underneath, it achieves strong isolation with Alibaba Cloud secure containers; on top, it exposes two sets of interfaces through the Kong gateway:

• Sandbox (long-running): for complex data processing, code execution, and workflow orchestration. The Sandbox connects directly to the PG data modules inside the same VPC, so large datasets never shuttle between the agent and the database — naturally close to the data. File System provides the full Read/Write/Upload/Download/Watch suite; Templates cover common cases like AI coding, Computer Use, Browser Use, script running, and data processing, plus user-defined images; Lifecycle supports concurrent spin-up in seconds, auto-hibernation, and checkpoint recovery.

• Edge Function (lightweight trigger): for event-driven lightweight functions, with a development experience consistent with mainstream Edge Functions. It supports HTTP / WebSocket / database-function triggers, is written in TypeScript / JavaScript, and deploys in seconds. Underneath, it shares the same isolation and scheduling implementation as the Sandbox — only the lifecycle and trigger method differ.

Data proximity also has a network-topology dimension. Agent Runtime instances, PG instances, and OSS storage are deployed in the customer’s own VPC; when the Sandbox and Edge Function read or write PG data, they go directly over the VPC intranet — no public endpoint for the database, and the entire path never touches a public network exit. For industries sensitive to data sovereignty — finance, government, healthcare — sensitive business data stays inside the enterprise’s own network boundary throughout agent code execution. Hard requirements like data residency, audit trails, and regulatory compliance are satisfied by the network architecture itself.

4

6. Synergy: How the Trio Delivers 1+1+1>3

The previous three sections covered what each piece does: Supabase handles data interfaces and application backends; the Knowledge Graph handles semantics, memory, and skill accumulation; the Agent Runtime handles code execution and event response. What makes the whole system compound is not just their individual capabilities, but an architecture that lets them combine flexibly and chain arbitrarily.

Here are the pairwise enablement paths:

Capability Area Obtained from Supabase Obtained from Knowledge Graph Obtained from Agent Runtime
Supabase – Ontology gives RPCs/Functions semantic addressability;
Skill Hub accumulates BaaS best practices
Underlying execution engine for Edge Function;
Code runtime for vibe coding applications
Knowledge Graph Storage hosts knowledge base files; Auth and RLS provide permissions; Realtime feeds PG data changes to Ontology in real time – Sandbox executes Skills and analysis scripts; Edge Function hosts callbacks for automatic knowledge base updates
Agent Runtime Auth and JWT provide identity;
RLS backstops permissions;
Storage provides file read/write;
Database provides business data
Ontology provides the semantic map;
Skill Hub provides reusable execution templates;
RAG provides context and knowledge
–

As the table shows, mutual enablement paths exist between any two pieces of the trio. When all three are orchestrated together, the capability space is no longer the union of three modules but the scenario space their combinations open up.

5

Here are a few combinations already running in production:

• SaaS-style agent platform: one database per tenant. Auth decides “who you are,” RLS decides “which rows you can see,” and Ontology decides “what you can do to which entities” — and when the Agent Runtime executes code with the agent’s JWT, it gets end-to-end isolation automatically. Cross-tenant access violations are blocked at the database layer, with zero application code.

• Autonomous agent data analysis: Ontology decomposes business metrics → Skill Hub provides analysis templates → Sandbox executes atomic computations → Supabase stores and pushes the results. One prompt from a business user completes analysis that used to take a data team weeks of scheduling.

• Vibe coding platform: the LLM generates front-end and back-end code from the user’s description → the front end runs in the browser or on static hosting, the back end runs directly on the Supabase five-piece suite, Edge Functions land on the Agent Runtime, and multi-version iteration rides on RDS PG’s data branching in seconds — going live as soon as it’s generated.

Behind all three examples is the same foundation — one RDS PG instance, one Kong gateway, and the trio. And the agent never needs to see this structure: one endpoint, one key, and a few REST paths are all it takes.

7. Conclusion: From Capabilities to Real-World Practice

Time to tie the series together. Part One covered the data foundation — why PostgreSQL is the core data foundation of the AI agent era, and RDS PG’s kernel enhancements across multi-tenancy, data branching, and multimodal retrieval. This post covered capabilities — how the agent trio of Supabase + Knowledge Graph + In-DB Agent Runtime, on the same Kong gateway and the same RDS PG, gives the agent its data interface, brain, and hands, and how mutual enablement turns them into a complete development platform.

With the capability skeleton in place, what’s worth watching next is how it behaves in real scenarios. The next post is the hands-on installment: we’ll wire the trio together end to end around one complete intelligent marketing analysis scenario — two tracks, analysis and presentation, two sides of the same application:

• The analysis track: the agent does the modeling and analysis autonomously. Running in the In-DB Agent Runtime’s Sandbox, the agent uses the Knowledge Graph and Ontology to complete business modeling, data import, and analysis, autonomously producing customer profiles, churn alerts, and attribution analysis — one prompt from a business user replaces weeks of scheduled report development by the data team. Results land in two places: structured conclusions are written back to PG, while charts and other unstructured artifacts go to Supabase.

• The presentation track: vibe-code a results dashboard. The dashboard needs no hand-written data access layer — inside an Edge Function it calls the SDK Supabase auto-generates, queries the data and charts accumulated in PG and Supabase in the previous step, and renders them — going live as soon as it’s generated.

The two tracks share the same RDS PG, the same permissions, the same Kong gateway — analysis and presentation are no longer two disconnected demos but one marketing analysis application closing the loop from “computing the conclusion” to “seeing the conclusion.” From the data foundation, to the development platform, to real-world business adoption — this series walks the entire path.

If Part One answered “what data foundation do agents need” and this post answered “what else the foundation needs to truly run,” the hands-on installment answers what it looks like once it actually runs: how one prompt replaces weeks of scheduled reporting by a data team.

The trio is no longer three boxes on an architecture diagram, but a system that gets work done on its own — see you in the next post.

0 0 0
Share on

ApsaraDB

666 posts | 189 followers

Comments