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.
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
literal_only
reviewed list
parentheses
qualifier, not evidence
Tuketici kredileri toplam (ay sonu, kredi kartlari haric)
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.
faiz düştüğü halde kredinin artmadığı ayları işaretle
“flag the months where the rate fell but credit did not rise”
- NEEDS_PLAN
- PLAN_READY
- EXECUTING
- REVISION_REQUIRED
- COMPLETION_CHECK
- OK
→ t1 · D1 verified
→ t2
→ t3 · D2 verified
→ c1 · D3 verified
revise_planreason_code: tool_refused, s2 replaced
○ pending · ▸ running · ✓ ok · ✕ refused · one tool per turn
- t1 tablesha256 9c41e2f7…
- t2 tablesha256 5b07d3a1…
- t3 tablesha256 e82a64c9…
- c1 chartsha256 17f0b5d3…
- ✓ 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.
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.
{"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
- ✓valid JSON, no duplicate keys
- ✓action: one of 14 tools or plan · revise_plan · answer · stop · reply
- ✓no extra fields
- ✓thought_tr ≤ 400 · goal_tr ≤ 200 characters
- ✓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
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.
tool · deflate(credit, cpi), base 2021-01
produces a number
verifier · operator.deflate_recomputed
gets only the frozen copy and the arguments
sha256 d3b9a07c… ✓ matches(credit ÷ credit₀) ÷ (cpi ÷ cpi₀) × 100
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
SQLGlot, DuckDB dialect: node and function types, not keywords
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
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 ✕
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.
- 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
- PDF ≤ 200 pages
- image ≤ 40M px
- text ≤ 2,000,000 chars
- CSV ≤ 10,000 rows × 256 cols
- archive ratio ≤ 1,000
text layer: straight through
no text layer: OCR
5 / 5 pages
OCR layout tokens are stripped; only verified image bytes go in.
- 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
Product
In the app
- localhostShot 2 · Live progress: plan, catalog search, lakehouse, compute labels advancing · 8 s recording
Draft: 8 s screen recording of a run. - localhostShot 5 · Trace expander open: plan, tool steps, per-step status and error codes · still
Draft: the plan and tool-step trace.