Mehran Toosi · Principal Software Engineer · Copenhagen

Visma e-conomic · Nov 2025 – now · TypeScript, Cloudflare Workers, Durable Objects, Python · internal

ecoai

problem

An assistant that is useful inside a company has to act in its systems (code, tickets, docs, monitoring, the data warehouse), answer data questions correctly, and keep customer data away from model providers.

solution

One agent runtime on Cloudflare behind Slack, a desktop app and an admin dashboard, with about 160 tools, a curated knowledge graph over the warehouse, small routing models and a privacy layer.

results

Used by 246 colleagues across the company. I started it in November 2025 and wrote about 1,600 of its 1,700 commits.

Architecture

Every conversation is a pair of Durable Objects: a mailbox that orders turns and a processor that runs them. The agent loop loads tools on demand, and every model call from a private conversation goes through the privacy layer.

one question from Slack to an answer · components from the codebase · layout illustrative

data

A knowledge graph of the company’s data, built from the code

To answer business questions, the agent needs to know what the warehouse means, not just its schema. The graph is built from evidence in the repositories: the product schema, the ETL pipelines, and five layers of SQL transformations with their lineage read from the warehouse.

Meaning the evidence can’t provide (grain, time policy, warnings, reviewed joins, routes) is curated on top. At runtime a question ranks its sources in the graph, and the SQL is written from that prepared context and checked before it runs.

source → transform → curate → search → execute · names and counts from the public version, rounded

routing

Routing with four small models

Before the main model runs, four TF-IDF and logistic-regression models choose the model tier, the tools to load and a first step, in about 0.1 ms. Each stays silent unless it is confident. The confidence thresholds were tuned by a genetic algorithm on reviewed threads, with a wrong hint costing five times what a correct one earns.

When a hint is given, the first tool is right 93% of the time.

features → confidence gates → threshold tuning · request and scores illustrative, tuning run real

reliability

Turns that survive a crash

Each conversation’s processor checkpoints while it streams and records every tool result. If it dies mid-turn, a fresh processor resumes from the checkpoint and reuses the recorded results, so an action with side effects never runs twice.

a processor crashes during a tool call · timing compressed

analytics

Charts and forecasts from references

Query tools return a reference to their result, not the rows. The model passes the reference to the chart tool and the server fills in the values, so no number in a chart is typed by the model. Forecasts work the same way: TimesFM runs in a container on the referenced series and returns a p10–p90 band.

one monthly series, charted and forecast · values illustrative

privacy

Reversible aliasing of customer data

When a tool returns customer data, emails, IBANs, card and CPR numbers, company names and people are replaced with stable aliases from an encrypted vault before any model call. The user sees the real values, restored in the answer and in rendered artifacts.

one tool result on its way to the model and back · alias format simplified

ecoai is internal to Visma e-conomic · counts are rounded and examples are illustrative