All projects

Agentic Financial Data Analytics

An LLM analytics agent over ~54,000 Turkish banking series that verifies every figure it reports.

Role
Core architect, team of 4
Year
2026
Status
Shipped
Stack
Python, DuckDB, Qwen 3.8 27B

Sorunuzkonut kredilerinin faizi

“the interest rate on housing loans”

  • konut
  • kredilerinin→kredi
  • faizi→faiz
  1. 1 stems
  2. 2 lexical lane · 18
  3. 3 semantic top-20 · 20
  4. 4 guards · 4 struck
  5. 5 exact · 1

1 dot = 1 series · dashed = semantic neighbour, a candidate only · only the word-matched lane can earn exact

guards · qualifier word (“oran”) without a ratio unit · text in parentheses · currency or maturity word absent from the series name

The catalog the agent searches, one dot per series (counts measured 2026-09-23). Stems are Snowball Turkish; the candidates and where they sit are an illustration of the matching rules, not a real search result.

Overview

What it is

Built for the KKB Hackathon 2026: an agent that takes a question in Turkish and answers it over roughly 54,000 banking and macro time series from BDDK and EVDS. Every number in the answer is produced by a tool and re-checked by a separate verifier; if it can't be verified, the agent says so instead of guessing. Our 4-person team built it in two weeks without an agent framework. I architected the core of the agent.

localhost
Shot 3 · Answer box (green = built-in data) with the verified table and dual-axis chart · still
Draft: a capture of a finished run goes here.

Numbers

~54K
Banking series
14
Public tools
1,422
Test definitions
4
Team size
2 wk
Build time
0
Agent frameworks

Catalog search

Ranking is not deciding

People say "konut kredilerinin faizi" (the interest rate on housing loans), not a series ID, and the wrong series gives a plausible wrong answer. The matcher folds Turkish letters and stems every word with Snowball. Two stems match if they are equal, or if one is a prefix of the other with at least 4 shared letters and a suffix difference of at most 2; a reviewed list stops false collisions like kurum to kur. Qualifier words such as "oran" (rate) must be satisfied by the series' unit, and text in parentheses is never match evidence. An embedding index can rank up to 20 extra candidates, but only the word-matched lane can decide that a series is an exact match.

prefix rule

Snowball isn't consistent

kredisi
→ kredis
kredisinin
→ kredi
common prefix 5 ≥ 4suffix difference 1 ≤ 2stems match

literal_only

reviewed list

kurum
→ kur
literal_onlykurum matches only the word kurum, never the stem kurcollision stopped

parentheses

qualifier, not evidence

Tuketici kredileri toplam (ay sonu, kredi kartlari haric)

kredi kartı✕ parentheses are a qualifier, not match evidenceno false match
Stems are Snowball Turkish output; thresholds from config/catalog/series_matching.v1.json. The series name is a sample record from the shipped catalog.

How it works

Plan, execute, verify

The agent is a custom state machine, not a framework graph. The first turn must be a plan of at most 6 deliverables and 8 steps. After that the model picks one tool per turn, and an identical repeat call is refused. When a step is refused or verification fails, a revise-plan turn replaces it; a run gets 4 revisions, 18 tool calls and 900 seconds. A deterministic completion gate answers OK only when every required deliverable has verified evidence. If a budget runs out, the run ends INCONCLUSIVE with a fixed explanation and no invented answer.

question

faiz düştüğü halde kredinin artmadığı ayları işaretle

“flag the months where the rate fell but credit did not rise”

budget
tool calls5/18
revisions1/4
loop state
  1. NEEDS_PLAN
  2. PLAN_READY
  3. EXECUTING
  4. REVISION_REQUIRED
  5. COMPLETION_CHECK
  6. OK
planv2 · ≤ 8 steps · ≤ 6 deliverables
s1lakehousefetch both monthly seriesD1✓

→ t1 · D1 verified

s2acomputedelta of rate and creditD2✓

→ t2

s2bcomputeconditional_flag on the deltasD2✓

→ t3 · D2 verified

s3visualizedual-axis chartD3✓

→ c1 · D3 verified

revise_planreason_code: tool_refused, s2 replaced

○ pending · ▸ running · ✓ ok · ✕ refused · one tool per turn

artifacts · immutable
  • t1 tablesha256 9c41e2f7…
  • t2 tablesha256 5b07d3a1…
  • t3 tablesha256 e82a64c9…
  • c1 chartsha256 17f0b5d3…
completion gate
  • ✓ D1 table
  • ✓ D2 table
  • ✓ D3 chart · optional

every required deliverable verified: gate open

answer · built-in catalog data

Rate fell, credit did not rise:

2021-032021-062 of 4 falling-rate months

INCONCLUSIVE

Tool-call budget used up (18/18) before D2 was verified. A fixed explanation is shown; no number is guessed.

An illustration of one run on the 6-month test table, with the loop's real limits and state names. The plan, step texts and hashes are examples; trimmed from the demo question “…faiz düştüğü halde kredinin artmadığı ayları işaretle”.

Structured outputs

Tools without native tool-calling

The model is open-weights (Qwen), and its serving endpoint offers neither JSON-schema output nor native tool calls. So each turn is one flat JSON action written in the prompt: an action name, a step id, the deliverables it serves and arguments that the tool's own typed model validates. I enabled structured outputs on top of it with a typed registry of 14 tools. A reply with a missing closing bracket gets a punctuation-only repair; a duplicate key is refused outright. I also built the EVDS ingestion pipeline, which uses LLM-assisted classification and anomaly detection, and covered it with regression tests.

turnvalid actionduplicate keyone action per turn
{
"action": "lakehouse",
"planned_step_id": "s1",
"outputs_for": ["D1"],
"thought_tr": "İki seriyi çekiyorum.",
"goal_tr": "Aylık tablo",
"arguments": { … }
}added by the repair: brackets balanced, punctuation only
  1. ✓valid JSON, no duplicate keys
  2. ✓action: one of 14 tools or plan · revise_plan · answer · stop · reply
  3. ✓no extra fields
  4. ✓thought_tr ≤ 400 · goal_tr ≤ 200 characters
  5. ✓arguments checked by that tool's own typed model

typed tool registry · 14 tools

  • lakehouse
  • catalog
  • sql
  • compute
  • describe
  • correlation
  • anomaly
  • change_detection
  • causality
  • visualize
  • web_search
  • web_url
  • document
  • ingest_series
  • plan
  • revise_plan
  • answer
  • stop
  • reply
Field names, caps and the tool list are the agent's own; the step id and the Turkish text are an example.

Verification

No LLM arithmetic

The model never calculates. Python tools compute, each result is stored as an immutable artifact pinned by SHA-256, and a separate verifier gets only that published table and recomputes the property by its own route. A verdict is pass, fail with a failure code, NOT_TESTABLE or NOT_APPLICABLE, and NOT_TESTABLE blocks like a failure: a check that did not run is never a pass. An optional narration step may rephrase the verified sentences, but if any number changes, the plain text is used instead. Expected values in the tests are worked out by hand, not by the production code. The repo has 1,422 test definitions across the agent, data, analytics and document code.

verdictspassfailNOT_TESTABLE
published table · frozen copysha256 d3b9a07c…
period2021-012021-022021-032021-042021-052021-06credit100110108108120118cpi100110120120125125

tool · deflate(credit, cpi), base 2021-01

produces a number

real_credit10010090909695

verifier · operator.deflate_recomputed

gets only the frozen copy and the arguments

sha256 d3b9a07c… ✓ matches

(credit ÷ credit₀) ÷ (cpi ÷ cpi₀) × 100

recomputed10010090909694.4compare✓✓✓✓✓✕
✕ failoperator_value_mismatchthe value is blocked and never reaches the answer
Oracle table and expected values from the test fixtures. The wrong value in the middle case is injected for the illustration; the verifier formulas are schematic and the hash is a placeholder.

SQL sandbox

The number the model can't type

The model can write SQL over verified tables, so the boundary matters more than the engine. Each query is parsed with SQLGlot and checked against an allow-list of node and function types, not a keyword blacklist: a string literal that says DROP TABLE is harmless, while read_csv on a file path is refused. A second rule, numeric provenance, says a projected number must derive from an input column; only -1, 0 and 1 may appear as constants, so SELECT 23122195 AS claimed_value is refused. Each call runs in a fresh in-memory DuckDB with a 30 s limit, 64 MiB of input and 100,000 output rows; hitting the row cap refuses instead of truncating.

model-written SQLquery 4 of 4

SELECT 23122195 AS claimed_value FROM t1

gate 1 · AST allow-list✓ pass

SQLGlot, DuckDB dialect: node and function types, not keywords

gate 2 · numeric provenance✕ refused

a projected number must derive from an input column

sql_constant_numeric_output_unsupported

result

✕ nothing runs, nothing is returned

valid SQL, but the number did not come from an input column

  • fresh in-memory DuckDB per call
  • 30 s runtime cap
  • 64 MiB in
  • 100,000 rows out: refuses, never truncates
Queries and error codes are the policy tests' own. The stack is a simplification of the checks in lakehouse/sql.py.

Frequency rules

Never upsample

BDDK publishes some flows as year-to-date running totals, and EVDS mixes daily to monthly series. Each reviewed series record declares how it aggregates, and the model never chooses: stocks take the period end, flows the sum, year-to-date flows successive differences that restart each January, rates and indices the mean or the period end. Conversion only goes coarser. The policy allows ten transitions from daily up to yearly and has no entry in the other direction, so a monthly series can't become weekly. Series that can't be classified safely stay native-only: findable, but closed to conversion. The verifier re-applies the declared rule to the finer rows itself.

01 Flow, year-to-date → monthly

BDDK publishes some flows as running totals; each month is the difference to the one before.

  • ytd_successive_difference@1

02 Same dots, different rule

The series record picks the rule: a stock takes the period end, a rate the mean. Averaging a stock gives a wrong number with the right shape.

  • calendar_period_end@1
  • calendar_period_mean@1

03 Only coarser, never finer

The policy lists no entry in the finer direction, so a monthly series can't be turned into a weekly one.

  • weekly → monthly ✓
  • monthly → weekly ✕
Rule names and the YTD sample (10, 25, 45) from the policy and the brief; the weekly values in panel 02 are illustrative.

Documents

Hostile input

A user can paste a URL or upload a PDF, spreadsheet or image, and its content becomes data in the analysis, so we treat it as hostile. The fetcher accepts only HTTPS to a public IP, pins the connection to it, follows at most 2 redirects and stops at 10 MiB. Parsing runs in a separate worker process with no network and no keys, under hard limits on pages, pixels, rows and archive size. Only pages without a text layer go to OCR, at most 5 per run. Tables without ruling lines are rebuilt from word positions, ambiguous cells never become exact numbers, and a source total row is flagged so it isn't counted twice. Document text is data, never instructions.

1 Fetch gateHTTPS, public IP
  • http://…✕ plain HTTP: refused
  • https://… → private address✕ resolved IP must be global: refused
  • https://… → public address✓ connection pinned to the resolved IP
  • ≤ 2 redirects
  • 15 s
  • 10 MiB
  • no cookies
2 Isolated parserno network, no keys
separate worker processnetwork✕keys✕
  • PDF ≤ 200 pages
  • image ≤ 40M px
  • text ≤ 2,000,000 chars
  • CSV ≤ 10,000 rows × 256 cols
  • archive ratio ≤ 1,000
3 OCR, only where neededscanned pages, 5 max

text layer: straight through

no text layer: OCR

5 / 5 pages

OCR layout tokens are stripped; only verified image bytes go in.

4 Tableragged → grid
row 1▬▬▬▬▬▬row 2▬▬▬?row 3▬▬▬▬▬▬TOPLAM▬▬▬▬▬▬
  • TOPLAM (total) row is flagged, so it isn't summed twice
  • an ambiguous cell never becomes an exact number

doc1→t2a temporary working table, not the core lakehouse

Limits from web/fetch.py, web/parsers.py and the runtime config. Pages and table cells are schematic.

Product

In the app

  • localhost
    Shot 2 · Live progress: plan, catalog search, lakehouse, compute labels advancing · 8 s recording
    Draft: 8 s screen recording of a run.
  • localhost
    Shot 5 · Trace expander open: plan, tool steps, per-step status and error codes · still
    Draft: the plan and tool-step trace.

Next project

EnabledScience

A macOS app that lets blind students point at a printed page and ask questions about it by voice.

In progress
  • Swift
  • Apple Vision
  • OpenCV
  • Whisper
  • React

© 2026 Emre Tutal