Ferhat RudvanoğullarıData Engineer
← All work

AI systems

Procurement AI Service

Turned a rule-driven procurement agent into a fixed pipeline behind a private API on Cloud Run, with a predictable output, capped model calls and evidence for every claim.

Backend & AI integration. Teammates built the procurement logic and the original agent; I built the fixed flow, the API, the deployment and the platform integration.

Oct–Nov 2026

In numbers

model calls/company
≤ 2
model calls/company
token cap, in / out
32K / 8K
token cap, in / out
offline tests, re-run on every release
80+
offline tests, re-run on every release

The problem

The team had built an AI agent (Brain) that reasons like a procurement specialist. Its behaviour was described as a long list of instructions: search the taxonomy first, then check this source, in this case do that. It could take a different route to the same question every time, and there was no telling how many model calls it would make or what shape the answer would come back in. Wiring that into a paid platform was a risk for both cost and reliability.

What I did

  1. 1

    Instructions became fixed operations

    I didn't carry the old reasoning module over. Instead I wrote operations that each do one job, with a defined input and output. The first version (26 October) had three checks, none of which called a model: brief check, company fit and RFQ preparation. I then folded them into two endpoints and retired the old three. Company evaluation compares the buyer's approved requirements with a company's source texts. Brief source review checks that the buyer's requirement list actually matches the original document.

  2. 2

    Outcomes, not rules

    Every operation returns the same structure. In a company evaluation, each requirement ends up in one of three states: supported by a source, contradicted by a source, or unknown. The company gets a provisional verdict that is also one of three: fit, needs review, not a fit. Every result carries the quoted source, the reasoning, any warnings and the tokens spent. There's no score, no auto-approval and no action taken on anyone's behalf. Missing technical evidence doesn't rule a company out on its own; it stays unknown.

  3. 3

    The model judges, Python checks

    Gemini 2.5 Flash does the evaluation, through Vertex AI in the EU. It gets no search tool: the platform sends the sources, and the model only reads and interprets them. Python then checks every claim it makes. Does the quote really appear in that company's source? Do the product and part scope line up? Are the numbers and units comparable? Do the sources contradict each other? Certification claims always go to review. After the first real test I also fixed a country-matching bug, the kind where "Oman" turns up inside "Romania".

  4. 4

    Capped cost, no double charges

    The model is called once per company, twice at most with a retry. Input is capped at 32K tokens and output at 8K, and a request that would go over is split before the model is ever called. Repeated requests are recognised so the same work is never billed twice, and the platform doesn't blindly resend an uncertain request when a connection drops.

  5. 5

    Private by default

    The service ships as a Docker image running as a non-root user on Google Cloud Run (managed containers, no servers to look after) in an EU region. Only the platform's staging and production service accounts can call it; on top of that every request is signed, and each operation needs its own per-workspace permission. On the first release, 10 signed test calls from both identities went through, while calls from another workspace and unsigned calls were rejected.

  6. 6

    Production stayed untouched

    Live users stayed on the previous, verified version throughout; the new operations were only switched on for a test workspace in staging. Each release kept the one before it available for rollback. The same image was then tried on a real case (air filter suppliers) in both staging and production.

Result

In five days and eight releases, an agent whose behaviour nobody could predict became a private API that follows the same steps every time, with a hard cap on model calls and cost, a test suite and a fixed output format. The platform can only reach it with authenticated calls, and live users never noticed the switch.

How it works

  1. Platform

    Buyer requirements and company source texts, sent with a service account, a signed request and a workspace permission

  2. Cloud Run, private API

    EU region, max 2 instances. Validates input and checks the token budget

  3. Gemini 2.5 Flash (Vertex AI, EU)

    No search tool, at most 2 calls per company

  4. Python checks

    Quotes, scope, numbers and units, conflicting sources

  5. Fixed-format result

    Status per requirement, quote, reasoning, provisional verdict, token usage

What I learned

Fixing the steps and asking the model only to judge, instead of telling an agent what to do and what to look at, made the output predictable, testable and safe to put in a product. The model interprets; the code checks.

Stack

  • Python
  • Gemini 2.5 Flash (Vertex AI)
  • Google Cloud Run
  • IAM
  • Docker
  • Gunicorn
  • GitHub Actions
  • TypeScript