One Apple, many tickers: asset matching and an agent that reads the error logs
MarketAlerts shows users one asset per company. Behind that one asset sit many: the same company from every data provider, each with its own name, ticker, exchange code, and metadata. Apple from one provider is Apple Inc, AAPL, NASDAQ, US. From another it is two rows, apple, US0378331005, AAPL on two exchanges. The product only works if all of these land on one internal asset, and only if Apple never gets merged with something that is not Apple.
The matching problem
The asset matcher has four hard parts:
- No false merges. Mapping two different companies together silently mixes their signals. Rules have to be strict.
- Metadata hierarchy. Once many external assets map to one internal asset, which one decides the country or the market cap? There is a ranking per field.
- Asset types. One company has common stock, ETFs, funds, and more. They are grouped into common and other.
- Update frequency. Name and ISIN rarely change. Market cap and release dates change daily.
Rules handle the bulk: exact ISIN matches, ticker plus exchange, banned pairs. They run in the Airflow pipeline, write to PostgreSQL, and only process new records, which mattered once some DAGs ran many times a day.
The matching agent
Rules leave a remainder: assets without an ISIN, names that differ after a merger, tickers reused on different exchanges. Before, these waited for manual adjustments.
The matching agent takes one unresolved external asset and a short list of internal candidates. Its tools:
- ISIN and ticker lookup across providers
- exchange-to-country and exchange-to-currency checks
- name normalisation (legal suffixes, share classes, punctuation)
- the list of banned pairs that must never match
It returns a structured verdict: match, no match, or needs review, with confidence and the evidence it used. Only high-confidence matches are applied automatically, and each one is logged as an adjustment so it can be recreated or undone. Everything else goes into the review list. The agent can never override the banned list or merge two internal assets. Those stay human decisions.
The ops agent: on call for the pipelines
The platform runs many jobs: crawlers, provider APIs, price aggregation, insider trades. Some failures repeat: a provider changes a field, memory runs out on a big day, a materialised view is rebuilt while an endpoint reads it.
The ops agent is event-driven. A Cloud Logging sink and Airflow failure callbacks send the error event, with task name, stack trace, and recent log lines. Then three agents hand off:
- Triage classifies the error: data issue from a provider, code bug, infrastructure, or flaky and transient. It also checks whether the same error was already reported.
- Fixer, only for code bugs with a clear cause. It reads the relevant files through the GitLab API, writes a minimal patch and a test that reproduces the failure, and opens a merge request on a new branch. It never pushes to main and never merges. The MR description explains the cause and links the logs.
- Reporter, for everything. It posts a short summary to the developer channel: what failed, since when, likely cause, what was done (MR link or "needs a human"), and how to reproduce.
I used the OpenAI Agents SDK with handoffs because these are separate roles with separate tools. Triage cannot write code. The fixer cannot post messages. The reporter cannot touch the repo. Each role gets only the permissions it needs.
Guardrails
- The GitLab token can create branches and MRs, nothing else.
- Max one MR per error fingerprint per day, so a noisy failure does not create twenty MRs.
- Patches are limited in size. Anything bigger becomes a report, not an MR.
- The CI pipeline runs on every MR, including the new test, before any human looks at it.
- Every agent run is traced with the triggering event, so a bad MR can be traced back to what the agent saw.
What I learned
The value was not that the agent fixes code. Most errors still need a human. The value was that the human starts with a clear summary, a reproduction, and often a draft fix, instead of a stack trace in a log viewer. For matching, the lesson was the reverse: the agent is useful only because the rules around it are strict. It works the remainder, never the core.