# Console

The AI agent Blue Onion customers use to ask about their own accounting data in plain English, and get answers, charts and tables they can trust in seconds.

- **Where**: Blue Onion
- **Status**: Shipped
- **Year**: 2026
- **My part**: Conceived it, chose the stack, wrote nearly all of it and set the patterns the team now extends

## The problem

Blue Onion closes the books for e-commerce brands. It reconciles their orders, payments, refunds and fees, and turns them into the journal entries they file into NetSuite or QuickBooks. One customer can have millions of orders, and every number has to tie out.

Customers had questions about their own data that only support could answer, and an investigation could take days. An answer that is almost right is worse than none when it lands in a CFO’s close.[^1] The agent had to be trusted before it could be useful.

## What a customer can do with it

- Ask about orders, payments, refunds, journal entries, receivables or unit economics, and get the answer as text, a table or a chart, with links to the pages that hold the numbers.
- Attach a report from another system, such as a Shopify export, and see where it matches Blue Onion’s data and where it doesn’t, row by row, with an export of the differences.
- Ask how the product works, answered from the help center.
- Ask for a report export or a support ticket. Console prepares the action, and the user confirms it.

Support uses it too. An investigation that took up to days now takes minutes, and the customer gets the full answer on first contact.

## How it answers

I designed the tool framework and built almost every tool. A tool reads through the app’s own GraphQL API, with the same permission rules as the page it mirrors, so Console shows the numbers the customer would see on that page. No tool takes a company as an argument. Each one is built for the signed-in user’s company, and a tool built without one refuses to run. Every tool is read-only: Console writes nothing to the books.

*Console · an illustrative run*

- ask: How do Shopify refunds in October compare with payouts?
- think: Plan: two queries, then compare (gemini-3.8-flash), 610ms
- tool: Query refunds (source: Shopify, period: October), 182ms
- tool: Query payouts (source: Shopify, period: October), 240ms
- check: Scoped to the user's company (set when the tool was built), 4ms
- answer: Streamed a table and a chart, with links to both pages, 1.9s

2 tool calls · 3.0s

A budget of tool calls per question makes Console stop searching and answer from what it already has. Other engineers now add tools on the patterns I set.

## Built to always answer

The web request never waits on the model. A background job runs each question and streams the answer to the browser as it is written. A watchdog makes sure every question ends with an answer or a clear “no answer”, never an endless spinner. A user can stop an answer, and an answer survives a closed tab.

Each answer starts on Gemini 3.8 Flash. When Vertex AI rejects a request, runs out of capacity, fails or returns nothing, Console retries, then falls back to Gemini 3.7 Flash and then 3.6 Flash, each with its own pool of capacity. If the whole chain fails, the job tries it again after a pause.[^2]

*The fallback chain (simplified)*

```ruby
class Agent::Client
  CHAIN = %w[gemini-3.8-flash gemini-3.7-flash gemini-3.6-flash].freeze

  def answer(turn)
    CHAIN.each do |model|
      reply = ask(model, turn)
      return reply if reply.present? # a blank answer counts as a failure
    rescue Vertex::Rejected, Vertex::NoCapacity, Timeout::Error
      next # each model draws on its own capacity pool
    end
    raise ChainExhausted # the job runs the chain again after a pause
  end
end
```

## Safe by design

- Read-only tools, each scoped to one company.
- Fixed refusals for questions outside its job and for manipulative requests.
- A guardrail checks every answer after it is sent: data from one company only, nothing of the system prompt leaked, tool calls within their limit.
- Telemetry never records what a tool returned, because that is customer data.
- Exports go only through an allowlist of reports.

## Evals, so the team can change it with confidence

I built the eval framework the team uses to measure Console. Each case is a question with checks: which tools Console must call and must not call, what it retrieves, whether it refuses, whether data stays inside one company, and whether a number is within a tolerance. An LLM judge scores the quality of the answer. More than a third of the cases are attacks: cross-company access, prompt extraction, instruction overrides, injected text, encoded tricks and write attempts. A real chat becomes a new case with one command.

So the team can change a prompt or move to a new Gemini model and see whether the answers got better or worse before a customer does.

## Cost and visibility

Every answer is traced with OpenTelemetry and records its tokens, tool calls, time and cost. Dashboards in Grafana and Cloud Monitoring show the cost of every answer, and alerts fire on model errors, unanswered questions and hourly spend. Leadership knows what the AI costs, and the team sees a problem as it happens. The dashboards and alerts are Terraform, like the rest of the AI stack. Help-center search runs on its own PgVector database, apart from the main one.

## What it changed

Console changed what Blue Onion sells. Leadership rebuilt the value proposition around it, made it a core product module, and is renaming the company because of it. With Console in the pitch, sales moved to a higher price point and average deal size nearly doubled.

- **Average deal size**: ~2×. Nearly doubled once Console was in the sales pitch.
- **A support investigation**: Minutes. It used to take up to days.
- **Writes to the books**: 0. Every tool is read-only. Actions wait for the user to confirm them.

## Built with

- RubyLLM
- Gemini (Vertex AI)
- Rails
- GraphQL
- PgVector
- OpenTelemetry
- Terraform

[^1]: So Console answers only from reconciled, auditable data. That constraint is what let sales take it to CFOs.
[^2]: Operators can switch the model without a deploy, and customers keep getting answers through provider outages.
