最新资讯
bloomberg.com 科技股抛售后,Anthropic IPO 估值承压 dev.to 当“按设计工作”成为问题:Claude Code 与 .NET 用户机密 dev.to 用代理修复 3500 个 Sonar 问题花 44 美元,让结果可信花 520 美元 dev.to 底层陷阱:为何企业 AI 使用率跑赢其 EBIT 影响 thenewstack.io Cursor 推出全托管应用部署,对标 Lovable 与 Replit techrepublic.com METR 评估显示 Anthropic 模型进展近乎翻倍,IT 采购方需关注什么 bloomberg.com Nvidia AI 芯片出口成为民主党国会关注目标 computerworld.com Meta 撤回争议性企业 AI 条款 bloomberg.com 台积电据报考虑生产先进 AI 存储芯片 www.infoq.com Yelp 为 AI Assistant 融合原生与服务器驱动 UI computerworld.com 英国监管机构:企业须为自家 AI 代理的错误负责 siliconangle.com Atomicwork 推出面向企业 IT 与安全的认证 AI 同事市场
多元动态
登录 注册
智能体 hackernoon.com · @Nicholas Lisac

能否完全用 SQL 构建 Agent?几乎可以

原文 我的收藏

作者介绍个人项目 Tables:基于 SQLite,用 messages 表上的触发器驱动 ReAct 循环,模型回复与工具结果写回表内并递归触发,需开启 PRAGMA recursive_triggers;主工具为 execute_sql,另有 search_web、fetch_url 和 materialize。作者说明文件外仍需一次 HTTPS 模型调用、宿主渲染与 API key,因此称'几乎'而非完全。

AI推荐理由 作者以个人项目 Tables 展示用 SQLite 触发器实现 ReAct 循环、消息表与工具调用,属于有具体实现细节的技术分享;但为个人博客自述,无独立验证或性能数据,且明确承认仍需外部 HTTPS 调用与宿主代码,'几乎'的边界需保留。

62

正文

New Story Can You Build an Agent Entirely in SQL? Almost by Nicholas Lisac October 23rd, 2026 TLDR Your browser does not support the audio element. byNicholas Lisac@nicholaslisac byNicholas Lisac|@nicholaslisac I am a BI & Data Analyst turned AI Engineer. I use local models, research AI and adjacent topics, and want to share what I find interesting. Story's Credibility When you think of an agent, you think of the LLM - the back-and-forth with the model - but for it to be an agent, it has to do stuff. It has to have what is called a 'ReAct loop' in which the agent itself interacts with its environment, calls tools, and decides when its turn is done. That seems very complicated - you have to create the conditions for the loop, you have to provide tools, you have to interpret the responses and route the messages with logic. In addition to the ReAct loop, you need other things. You need chat history, the live working transcript, sessions, tool definitions, an environment in which to execute code, a way to compact the conversation, a place to store retrieved information. I wanted to see if I could build all of this in SQL. And I basically did. Its name is Tables. What is Tables? Tables is tables. Tables runs in a web app, but they don't have to. When you export from the web app, you get a single .sqlite file - a cartridge - and inside that file is the Python code that boots it: python3 your-agent.sqlite3 "What tables do I have?" and they talk back to you. Tables is built on SQLite. SQLite does need a small amount of external piping to come to life - in my case a bit of JavaScript for the web app, or a little Python for the CLI. To be honest about what "almost" means: what lives outside the file is one HTTPS call out to a model, the ferry that carries it, the thing that draws the results on screen, and your API keys. The agent's entire state and control flow are the file. Everything else is the HTTPS transportation layer. The loop is just a trigger. The core loop is a trigger. When a new row is written to the `messages` table, the trigger fires and the cascade starts: it hands the active context to the model, writes the model's answer back into `messages` as a new row, and that insert fires the same trigger again. If the answer contained a tool call, a second trigger runs the tool and its result lands in `messages` too, which continues the cascade. It repeats until the model stops asking for tools. That's the whole loop, and it needs one flag to exist at all: SQLite doesn't fire triggers from inside triggers by default, so the file sets `PRAGMA recursive_triggers = ON` and calls itself to life. The model's main tool is `execute_sql` - it thinks and acts inside a SQLite database, which is its whole environment. I did build out the rest of the tool set because I wanted something I could actually use: `search_web` and `fetch_url` because those are table stakes, `materialize` to turn raw JSON from a tool result into a real table with `json_each()` so the data doesn't have to be retyped through the model, and `search_documents` / `ingest_document` backed by an FTS5 table for recall. Messages are a table. Sessions are a table. The list of tools - a table. Approval rules? Table. The active context is a view that handles compaction. And as mentioned before, the loop is a trigger. Unexpected Outcomes There are some cool things that fall out of this when compared to other agent harnesses. Tables is literally one file. You can take your .sqlite3, send it to another computer, open tables.nicholaslisac.com, load the cartridge, and your agent is good to go - same conversation, same data, same identity - or run the Python that's sitting in the file and never open a browser. The API key never travels in the file; it gets paired once per machine for security. The chat history is native and easily explorable. Everything the agent has ever done or seen is in the SQLite database it operates from, and nothing is more than a SQL query away. Every write is journaled with who made it - the agent, you at the keyboard, or the interface on your behalf - so a turn can be undone without undoing your own work. Everything the agent learns ends up in the same place as everything you give it. Drop a CSV on the window, and it becomes a typed table; have it fetch a page and materialize the results, and that becomes a table too. After that they all swim the same way, because for the agent there is no difference between its own history and your data - it's all just rows and columns. Tables is naturally sandboxed to their database file, with the exception of their web capabilities. The agent can't touch your filesystem, can't install anything, can't notify you. It can't even break its own harness - the internal tables are protected from DDL and DML, on the agent's path and yours. You also get a scratchpad so Tables acts as your own SQL workbench: !SQL runs your query and shares the result with the agent, !!SQL runs it privately and the agent never sees it. And if you pin a query you like, it becomes an artifact. Is this the future of Agent harnesses?! Absolutely not. I wondered if I could build an AI agent loop with SQL as the engine and set out to see if it worked. I got a little carried away and made an entire web app to prove a point. It's part research project, part portfolio piece. And I like it. Tables is not a coding agent. It doesn't have access to other files on your computer. It can't do most things people want out of their AI in 2026. Tables is just tables. But those tables can talk back to you, do real work in a database, do analysis and gather information from around the internet, and prove that SQL is (almost) as powerful as languages like Python or TypeScript. The code is open - you can see it on GitHub, and you can check out the explainer here or go right to the app here: tables.nicholaslisac.com. You can use Tables, but you will need to BYOK, whether that is local or cloud. No guarantee of performance or success - but it will probably be fun to talk to Tables. About Author byNicholas Lisac|@nicholaslisac I am a BI & Data Analyst turned AI Engineer. I use local models, research AI and adjacent topics, and want to share what I find interesting. Read my storiesLearn More TOPICS Software Engineering #ai#sqlite#ai-agents#sql#tables#react-loop#react-loop-explained#agent-harness

来源报道 · 1 篇 · 以下链接均前往原始媒体

Nicholas Lisac 能否完全用 SQL 构建 Agent?几乎可以 10-24 · 原文发布
← 返回精选动态 原文

更多内容