Key Points 5 min read
  • The core is a plan–execute–self-validate loop that decomposes complex questions into subtasks and iterates until the result is complete enough
  • Built-in loop detection and an execution step cap prevent autonomous agents from spiraling out of control
  • Every tool call is written to a JSONL scratchpad, so the agent's decision chain can be fully reconstructed
Table of Contents

“Analyze a company’s financial health over the past few years”—traditionally this means you go pull the financial statements yourself, break down the numbers, and cross-reference them. Dexter aims to turn it into: you drop the question in, and the agent plans out the research steps, fetches real-time market data, checks its own results, and finally hands you a data-backed conclusion.

Author virattt sums up its positioning in one line: “Think Claude Code, but built specifically for financial research.”—conceptually, an autonomous agent purpose-built for financial research that thinks, plans, and corrects itself along the way.

Agent Execution Architecture

Dexter isn’t just a RAG pipeline, nor is it “an LLM plus a search tool.” Its core is a plan–execute–self-validate loop: first it breaks a complex question into structured research steps, picks the right tools to fetch data, then checks whether its output is complete—and if not, keeps iterating.

flowchart TD
  Q["使用者問題"] --> P["任務規劃\nTask Planning"]
  P --> T1["Financial Datasets API\n損益表 / 資產負債表 / 現金流量表"]
  P --> T2["Exa 網路搜尋\nTavily fallback"]
  T1 --> V["自我驗證\nSelf-Validation"]
  T2 --> V
  V -- "結果不足" --> P
  V -- "結果充分" --> R["輸出結論"]
  R --> Log[".dexter/scratchpad/\nJSONL 稽核記錄"]

The official docs list five core capabilities:

  • Intelligent Task Planning: automatically decomposes complex queries into structured research steps.
  • Autonomous Execution: selects and runs the appropriate tools on its own to gather financial data.
  • Self-Validation: checks its own output and iterates repeatedly until the task is complete.
  • Real-Time Financial Data: can access income statements, balance sheets, and cash flow statements.
  • Safety Features: built-in loop detection and an execution step cap to prevent runaway execution.

A Few Design Decisions Worth Noting

Loop detection and a step cap

The most classic failure mode for an autonomous agent is that it keeps feeling like “I need more data,” calling tools endlessly and iterating forever, until API costs and time blow up. Dexter treats loop detection and a maximum step limit as built-in safety mechanisms rather than after-the-fact patches—this is the basic line of defense that lets an agent actually run in a real environment.

JSONL scratchpad: an auditable decision chain

Dexter logs all tool calls from each query to a scratchpad file, generating a new JSONL file (newline-delimited JSON) under .dexter/scratchpad/ for every query. Each line records one kind of event:

  • init: the original query.
  • tool_result: each tool call, including the arguments, the raw returned result, and the LLM’s summary of that result.
  • thinking: the agent’s reasoning steps.

Because every step leaves a trace, you can precisely reconstruct after the fact what data the agent actually fetched and how it interpreted it—especially useful for debugging “why did it reach this conclusion.”

LangSmith evaluation + LLM-as-judge

Dexter ships with an evaluation suite that tests the agent against a dataset of financial questions. Evaluation is traced with LangSmith and scores answer correctness using an LLM-as-judge approach. You can run it over all questions (bun run src/evals/run.ts) or sample (with --sample 10). While it runs, a live UI shows progress, the current question, and the running accuracy; results are logged to LangSmith for analysis. This turns “did quality improve after switching provider or changing the prompt” into something quantifiable rather than a gut feeling.

Multi-provider, switchable at the config layer

It defaults to OpenAI (OPENAI_API_KEY is required), but you can swap in Anthropic, Google, xAI, or route through OpenRouter; it also supports running locally via Ollama. Switching provider is an environment-variable-level configuration and doesn’t require touching agent logic—handy for anyone wanting to control cost or compare how different models perform.

WhatsApp gateway

Dexter offers a WhatsApp gateway: after connecting your phone to the gateway (log in by scanning a QR code), you send messages in your “chat with yourself,” and Dexter processes them and sends the reply back to the same chat. For situations where you’re used to your phone and don’t want to open a terminal, this lowers the barrier to use.

Tech Stack and Data Sources

Dexter runs on the Bun runtime (v1.0 or above required). After installing, use bun start to enter interactive mode and bun dev to develop in watch mode.

  • Financial data: from the Financial Datasets API, officially positioned as “institutional-grade market data for agents,” providing income statements, balance sheets, cash flow statements, and more.
  • Web search: Exa is the first choice, with Tavily as a fallback (both are optional).

Licensed under the MIT License.

What to Know Before Using It

The project spells out a disclaimer right at the top of the README: for educational, entertainment, and informational purposes only—not for actual trading or investment. It is not financial, investment, tax, or legal advice; it makes no guarantee of accuracy, completeness, or fitness for purpose; its output may be wrong, incomplete, or outdated. The correctness of the financial data depends on the upstream API, and the LLM’s reasoning itself can also err.

In other words, it’s suited to exploratory research, understanding the structure of financial statements, or learning autonomous-agent design patterns—not to be taken directly into trading decisions.

References

Ask this article

Answers come from this article only. Click any prompt below or open the chat at the bottom right.

🇺🇸 English

"Analyze a company's financial health over the past few years." Traditionally, that means you're the one doing the grunt work—pulling the financial statements, breaking down the numbers, cross-referencing everything by hand. Dexter wants to flip that on its head. You drop in the question, and the agent plans out the research steps, fetches real-time market data, checks its own work, and hands you back a conclusion with the data to support it.

The author, virattt, sums up the whole positioning in one line: think Claude Code, but built specifically for financial research. In other words, an autonomous agent that thinks, plans, and corrects itself as it goes.

So let's talk about how it actually works, because this is the interesting part. Dexter isn't just a RAG pipeline, and it isn't just "an LLM with a search tool bolted on." Its heart is a loop with three beats: plan, execute, self-validate. First it takes a messy, complex question and breaks it into structured research steps. Then it picks the right tools to go fetch data—things like income statements, balance sheets, cash flow statements from a financial data API, or a web search when it needs context. And then comes the part most agents skip: it looks at its own output and asks, "Is this actually complete?" If the answer is no, it loops back and keeps going. If yes, it writes up the conclusion. And every step along the way gets logged to an audit trail.

The official docs frame this as five core capabilities: intelligent task planning, autonomous execution, self-validation, real-time financial data access, and safety features. But I want to zoom in on a few design decisions that I think are genuinely worth paying attention to, because they tell you this thing was built by someone who's watched agents fail in the wild.

First one: loop detection and a step cap. Here's the classic way an autonomous agent dies. It keeps feeling like "I need just a little more data," so it calls another tool, and another, and another—iterating forever while your API bill and your clock both spiral. Dexter bakes in loop detection and a hard maximum on execution steps as first-class safety mechanisms, not as a patch someone slapped on after things went wrong. That's the basic line of defense that lets an agent actually survive in a real environment.

Second: the JSONL scratchpad. Every single query Dexter runs, it writes out a fresh log file—newline-delimited JSON, one event per line. And each line captures a specific kind of moment. There's the init event, which is your original question. There's tool_result, which records every tool call: the arguments it passed, the raw result it got back, and the LLM's summary of that result. And there's thinking, which captures the agent's reasoning steps. The payoff here is huge. Because every step leaves a trace, you can go back afterward and reconstruct exactly what data the agent fetched and how it interpreted it. When you're staring at a conclusion asking "wait, why did it decide that?"—this is how you find out.

Third: it ships with a real evaluation suite. Dexter tests itself against a dataset of financial questions, traces the whole thing with LangSmith, and scores correctness using an LLM-as-judge approach—basically, one model grading another's answers. You can run it across every question or just sample, say, ten of them. And while it runs, there's a live UI showing progress, the current question, and your running accuracy. The point of all this is that it turns a fuzzy question—"did quality actually go up after I switched providers or tweaked the prompt?"—into a number you can look at, instead of a gut feeling.

Fourth: it's multi-provider, switchable at the config layer. It defaults to OpenAI, but you can swap in Anthropic, Google, xAI, route through OpenRouter, or even run it locally with Ollama. And switching is just an environment variable—you never touch the agent logic. That's really convenient if you want to control cost or compare how different models handle the same research.

And fifth, a fun one: there's a WhatsApp gateway. You scan a QR code to connect your phone, then you message yourself in your own "chat with yourself," and Dexter picks it up, processes it, and replies right there in that same chat. If you live on your phone and don't want to open a terminal, that drops the barrier way down.

Quick word on the stack. Dexter runs on the Bun runtime—you'll want version 1.0 or higher. Once it's installed, you type "bun start" to jump into interactive mode, or "bun dev" for watch mode while developing. Financial data comes from the Financial Datasets API, which bills itself as institutional-grade market data for agents. For web search, Exa is the first choice with Tavily as a fallback, and both of those are optional. The whole thing is MIT licensed.

Now—and this matters—there's a disclaimer sitting right at the top of the README, and it's not boilerplate you should ignore. This is for educational, entertainment, and informational purposes only. Not for actual trading or investment. It is not financial, investment, tax, or legal advice. It makes no guarantee that its output is accurate, complete, or fit for any purpose. The output can be wrong, incomplete, or outdated. And there are two separate places that can go wrong: the financial data depends on the upstream API being correct, and the LLM's own reasoning can slip up. So realistically, this is a tool for exploratory research, for understanding how financial statements are structured, or for learning how to design autonomous agents—not something you take straight into a trading decision.

So let me leave you with three things to hold onto. First, the real architecture here isn't the data fetching—it's the plan, execute, self-validate loop, where the agent checks its own completeness and iterates instead of just answering once. Second, the safety and observability features are what make it real: loop detection and a step cap keep it from running away, and that per-query JSONL audit trail means you can always reconstruct why it concluded what it concluded. And third, keep the guardrail in mind—this is a fantastic way to learn agent design and explore financial data, but the disclaimer is doing honest work. The data can be wrong and the reasoning can be wrong, so treat its conclusions as a starting point, never as a verdict.

🇹🇼 中文

「幫我看看某家公司這幾年的財務狀況到底健不健康」——這種事情,傳統上你得自己去把財報翻出來、一個個數字拆開、再交叉比對。而 Dexter 想做的是:你把問題丟進去,agent 自己規劃研究步驟、自己去抓即時的市場數據、還會回頭檢查自己的結果,最後給你一個真的有數據撐腰的結論。

作者 virattt 用一句話幫它定位:把它想成 Claude Code,只是專門為金融研究打造的版本。概念上就是一個會思考、會規劃、也會在過程中修正自己的自主 agent。

先講它的執行架構。Dexter 不是那種單純的 RAG pipeline,也不是「LLM 外掛一個搜尋工具」這麼簡單。它的核心是一個「規劃、執行、自我驗證」的迴圈:先把複雜問題拆成有結構的研究步驟,再挑對的工具去拿資料,然後檢查自己的產出夠不夠完整——不夠,就繼續往下迭代。

整個流程走下來大概是這樣:使用者的問題進來,先做任務規劃,接著分頭去呼叫工具。一邊是 Financial Datasets API,去抓損益表、資產負債表、現金流量表;另一邊是網路搜尋,優先用 Exa,Tavily 當備援。拿到資料之後進到自我驗證這一關:如果結果不夠,就退回去重新規劃;如果夠了,就輸出結論。而且每一步都會寫進 scratchpad 做稽核記錄。

官方列的核心能力有五項:智慧任務規劃,自動把複雜查詢拆成結構化步驟;自主執行,自己挑工具、自己跑;自我驗證,反覆迭代直到任務完成;即時金融數據,能取用三大財務報表;還有安全機制,內建迴圈偵測跟執行步數上限,防止它失控。

接下來聊幾個我覺得比較值得注意的設計決策。

第一個是迴圈偵測跟步數上限。自主 agent 最典型的翻車方式,就是它一直覺得「我還需要更多資料」,於是不停呼叫工具、無限迭代,最後 API 帳單跟時間一起爆掉。Dexter 把迴圈偵測跟最大步數限制當成內建的安全機制,而不是事後才補的補丁——這其實是讓 agent 能在真實環境跑起來的基本防線。

第二個,是它用 JSONL scratchpad 做可稽核的決策鏈。Dexter 會把每次查詢的所有工具呼叫都記錄下來,每一次查詢都在專屬資料夾底下生成一個新的 JSONL 檔,也就是每行一筆 JSON。而每一行記錄一種事件:init 是原始查詢;tool_result 是每次工具呼叫,包含參數、原始回傳、還有 LLM 對結果的摘要;thinking 則是 agent 的推理步驟。因為每一步都留了痕跡,你事後可以精準重建它到底抓了哪些資料、又是怎麼解讀的。要 debug「它為什麼會得出這個結論」的時候,這特別好用。

第三個是評估這塊。Dexter 附了一整套 evaluation suite,拿一組金融問題的資料集去測 agent,用 LangSmith 做追蹤,再用 LLM 當裁判去替答案的正確性打分。你可以全部問題都跑,也可以抽樣個十題。跑的時候有即時 UI 顯示進度、目前在處理哪一題、還有累積的正確率,結果全部記到 LangSmith 供分析。這件事的價值在於:換 provider、或改了 prompt 之後,品質到底有沒有變好,變成一個可以量化的東西,而不是靠感覺。

講到 provider,Dexter 預設走 OpenAI,這是必要條件,但你可以換成 Anthropic、Google、xAI,或透過 OpenRouter,甚至用 Ollama 在本地跑。而且切換 provider 是環境變數層面的設定,完全不用動 agent 邏輯——對想控制成本、或想比較不同模型效果的人來說很實用。

還有一個滿有意思的:WhatsApp gateway。你把手機掃 QR code 連上 gateway 之後,在「跟自己的對話」裡發訊息,Dexter 就會處理,再把回覆送回同一個對話。對那種習慣用手機、不想開終端機的情境,門檻降低不少。

技術棧的部分,Dexter 跑在 Bun runtime 上,需要 1.0 以上版本。金融數據來自 Financial Datasets API,官方定位是「給 agent 用的機構級市場數據」;網路搜尋則是 Exa 優先、Tavily 備援。授權是 MIT。

最後一定要提的,是使用前你得知道的事。專案在 README 一開頭就把免責聲明講得很清楚:這東西僅供教育、娛樂跟資訊用途,不能拿去做真實交易或投資。它不是財務、投資、稅務或法律建議,不保證正確、完整或適用,輸出有可能是錯的、不完整的、或過時的。畢竟財務數據的正確性取決於上游 API,而 LLM 的推理本身也會出錯。換句話說,它適合拿來做探索性研究、理解財報結構、或學習自主 agent 的設計模式,但不適合直接拿去做交易決策。

好,收尾幫你抓三個重點。第一,Dexter 的核心不是搜尋,而是「規劃、執行、自我驗證」這個迴圈,會自己拆步驟、自己修正。第二,它的安全跟可觀測性是內建的——迴圈偵測、步數上限防失控,JSONL scratchpad 讓每個決策都可以事後追。第三,它多 provider、有量化評估、還附 WhatsApp 入口,但定位很誠實:拿來學 agent 設計、探索財報結構很好,別拿它做真實投資決策。

Tags

Related Articles

RAG's Five Stages: From Pipeline to Reasoning Retrieval, and the Naive RAG on My Own Site

Over the past two years RAG evolved from a 'linear pipeline' to 'loop-based reasoning'. It maps cleanly to five stages: Naive, Advanced, Modular, Graph, Agentic. The real inflection point is control moving from pipeline to agent — a System 1 → System 2 shift. Looking back at engineer-news's own RAG stack, it's stuck at the Naive edge — so this post also lays out what to fix next.

Building a Real RAG: 5 Infra Lessons from InfiniFlow's 2024 Year-in-Review

The previous post zoomed out for a five-stage panorama of RAG. This one zooms in on the five infra lessons any real RAG has to face: document ingestion, contextualized chunking, three-lane hybrid search, tensor reranker, and GraphRAG's semantic gap. Each lesson is checked against engineer-news's current stack, ending with a priority list for a personal site.

J-lens: Anthropic's New Interpretability Tool for Reading Claude's Inner Thoughts via a 'Global Workspace'

Anthropic proposes J-lens, an interpretability tool that captures the 'verbalizable' representations inside a Transformer, and uses it to show that Claude contains a privileged subspace analogous to the neuroscientific 'global workspace' — a small set of vectors that broadcast, drive reasoning, respond to external steering, and even leak signals during deception and evaluation awareness.