Building and Testing Production AI Applications at CircleCI

circleci · Tech · 2023 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.5 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Production testing for LLM developer tools

CircleCI needed to build AI-assisted developer tooling, such as an error summarizer for CI stack traces, while adapting CI/CD testing practices to LLM outputs that are probabilistic, subjective, potentially biased, costly, and difficult to validate with ordinary deterministic tests.

Constraints:

Architecture

CircleCI's concrete use case is an error summarizer that ingests long CI/CD stack traces and produces likely causes and recommendations, with an experimental path toward using the developer diff to propose fixes. Around that product path, the team describes a production testing architecture: model-graded evals for subjective LLM quality, table-driven and mutation-style test sets to offset evaluator bias, critical-user-journey selection instead of exhaustive replay, function-calling error handling and fallback paths, user-feedback capture for a data flywheel, and cost controls through usage reporting, fine-tuning, model routing, and dedicated-capacity decisions.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  ci-failure-context[CI failure context] --> error-summarizer[Error summarizer]
  error-summarizer --> llm-provider[LLM provider]
  error-summarizer --> function-calling-parser[Function-calling parser]
  error-summarizer --> evaluation-suite[Evaluation suite]
  error-summarizer --> feedback-collector[Feedback collector]
  evaluation-suite --> model-graded-evaluator[Model-graded evaluator]
  model-graded-evaluator --> llm-provider
  feedback-collector --> evaluation-suite
  evaluation-suite --> human-review[Human review]
  feedback-collector --> human-review
  llm-provider --> cost-router[Cost router]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
CI failure context Stack traces and optional developer diffs from failing CI/CD jobs. Error summarizer
Error summarizer LLM-powered feature that summarizes long stack traces and recommends likely fixes. CI failure context, LLM provider, Function-calling parser, Evaluation suite, Feedback collector
LLM provider Foundation model service used for summarization, grading, routing, or experimental automated fixes. Error summarizer, Model-graded evaluator, Cost router
Model-graded evaluator LLM-as-judge process that grades generated output for correctness, helpfulness, non-toxicity, style, or appropriateness. Evaluation suite, LLM provider
Evaluation suite CI/CD-oriented eval set built from table-driven cases, mutation-style rephrasings, adversarial prompts, and critical journeys. Error summarizer, Model-graded evaluator, Feedback collector
Function-calling parser Structured-output layer that handles invalid JSON, retries, and fallback paths for function-calling responses. Error summarizer
Feedback collector Data flywheel collecting explicit ratings and implicit user behavior such as reprompting or regeneration. Error summarizer, Evaluation suite
Cost router Cost-management layer for choosing fine-tuned, cheaper, expensive, shared, or dedicated model capacity based on query difficulty and economics. LLM provider
Human review Ongoing human review for subjective quality and edge cases not captured by automated evals. Evaluation suite, Feedback collector

Data flow

A CI failure produces a stack trace and, for experimental repair, a developer diff. The error summarizer sends that context to an LLM to summarize likely causes and recommendations. During development, generated outputs are evaluated with model-graded eval prompts that ask another model to judge quality, correctness, helpfulness, tone, or non-toxicity. Test suites use multiple table-driven examples and mutation-like rephrasings rather than a single golden answer. In production, explicit feedback such as thumbs up/down and implicit signals such as reprompting, regeneration, or asking for a human feed future evaluation datasets. Cost management watches model-level token bills and can route simple queries to cheaper models, fine-tune to shorten prompts, or reserve expensive models for harder requests.

4 supporting quotes
“we've got these really long stack traces can we kind of quickly give you uh recommendations of you know what what the problem is”transcript, stated
“absolutely I'll I'll throw in like a term for people to Google if they're interested so so model graded evals is sort of the the the catch all term for this you can usually you can find some good resources on this and so the the basic idea is okay we've trained this large language”transcript, stated
“use similar strategy with AI what what are the what are the important flows right what are what are the most critical sort of user Journeys that you care about um what are what are failure modes that you're particularly concerned about um if if you've got an application that's like”transcript, stated
“feedback could be a simple as thumbs up thumbs down could be behavioral if they reprompt if they regenerate a response”transcript, stated

Why this architecture

CircleCI maps LLM application testing back onto CI/CD habits without pretending LLMs are deterministic services. Model-graded evals provide automated signal for subjective output quality, but table-driven cases, randomized phrasing, mutation tests, and human review offset known biases. Critical user journeys bound cost and latency instead of replaying every possible production request. Function-calling and fallback handling preserve ordinary software resilience. The feedback collector turns real user behavior into use-case-specific eval data, which is more valuable than generic benchmarks for a production developer tool.

4 supporting quotes
“it doesn't really do you any good if a model does really well on like a kind of industry standard Benchmark that's good for comparing models against each other um If you're sort of producing the wrong outputs for your for your customers and so um yeah so”transcript, stated
“you don't want to test on a single example you might want to test on multiple examples tweak the wording a little bit there's kind of um I'm going to keep drawing an allergies to traditional software but you think of like mutation testing go in randomly”transcript, stated
“your test cases are not production right um and so I think some of that human review is still very very important”transcript, stated
“Cheaper uh quick quick uh quick way to check yeah but yeah absolutely 100% you need that that user feedback it's very valuable signal so we've talked a lot about how easy it is to get started and then some of the things to consider around just making sure”transcript, stated

Models used: GPT-4 · GPT-3.5 · OpenAI function calling · fine-tuned OpenAI models · Azure hosted GPT-4

Scale

Alternatives considered (roads not taken)

Evaluate with string matching or a single golden output

Rejected because: LLM output is probabilistic and language can be correct in many wordings and styles.

“string matching kind of thing which doesn't really work because of the the probabilistic nature of it and so the the the approach is like well we've we've got a thing that kind of understands text can can we ask it questions around about it about its own”transcript, stated
“language is subjective there's lots of right ways to answer the same question with different wording there's different styles that you might want to want to impose so that that probabilistic aspect of it and then I I also think kind of maybe an under look or”transcript, stated

Trust one model-graded evaluation result

Rejected because: Models have own-output and positional biases, so one comparison can be misleading.

“hugging face have tons of really good research um certain models prefer their own output right I think gp4 actually has a slight bias to to prefer output from gp4 over other models which is kind of not not super surprising right it's notion of correct and I I put notion in air quotes because there's”transcript, stated
“stats but it's like if you ask it uh compare left and right kind of if you think about it like there's a bias towards the left to always say like the left is correct so so that that creates this I mean again you kind of have to think about your risk tolerance for those sorts of things”transcript, stated

Test exhaustively against every possible or historical request

Rejected because: LLM evals are expensive and time-consuming, so the team recommends critical journeys and table-stakes datasets.

“if you attempts to retest every case possible Right like then then that will become prohibitively not even like cost uh expensive but like time expensive right I mean these these llm output these LM models are kind of they're not high throughput query”transcript, stated
“what are the core user Journeys what are the things you want to test what are the absolute minimums of your application”transcript, stated

Use only expensive models for all requests

Rejected because: At scale, cost can be managed by fine-tuning, shortening prompts, routing simple queries to cheaper models, or buying dedicated capacity.

“drive um and so yeah when you talk about cost right the cost management some of it is like do do you fine-tune an open AI model to make the prompts shorter right so you pay for tokens in and you pay for tokens out um is is typically the pricing model there um so yeah do do you”transcript, stated
“if it's a hard query use the expensive model if it's a simple query use a uh use use a cheaper model um the the trick there of course like with any type of scaling strategy right is the more knobs and paths you create through the system the more you kind of”transcript, stated

Assume function calling always returns valid JSON

Rejected because: Structured-output function calls can still fail and must be handled with retries or fallback paths.

“those function calls are not always 100% accurate right sometimes it doesn't give back valid Json and so like then it becomes like an error handling strategy um which again kind of falls back into a normal software development flow what what do you do do do”transcript, stated
“what what do you do do do you retry do you um do you just say like okay we'll go down a fallback path um that so so I would say yeah like understanding the the critical user Journeys identifying data sets that are sort of you know critical like table Stakes”transcript, stated

Patterns

llm-as-judge (evaluation)

CircleCI uses model-graded evals to judge generated LLM output for subjective quality and correctness when string matching is insufficient.

“model graded evals is sort of the the the catch all term for this”transcript, stated
“the prompts that people use they kind of use the analogy of a student and a teacher”transcript, stated

eval-driven-development (quality)

The team frames evals as part of CI/CD: prompts, model choices, and output behavior should be tested before production deployment.

“as I'm iterating and delivering I have a tool that can say this is good enough maybe not this one”transcript, stated
“um and and so sort of taking that Knowledge from research around evals and how do you apply the stuff and then bringing it into sort of you know applied software delivery if we will um feels like uh at least there's there's hope we we see signs we see approaches we're still learning from them or”transcript, stated

human-in-the-loop-gate (quality)

Human review remains important for subjective quality and edge cases even when model-graded evals are automated.

“there's not it's not a human actually evaluating it's it's not your test cases are not production”transcript, stated
“it's not a human actually evaluating it's it's not your test cases are not production right um and so I think some of that human review is still very very important yeah yeah well I mean I think that there's there's going to be some nervousness I can't can't think of a better word right now”transcript, stated

data-quality-loop (feedback)

User ratings, regenerations, reprompts, and abandonment signals feed future testing datasets and model-performance understanding.

“building a kind of the idea of a data flywheel where where as as people are using this application putting in a mechanism to provide feedback”transcript, stated
“everything the user does is some sort of feedback about how the model is performing”transcript, stated

fallback-degradation (resilience)

Structured-output and mediocre-answer failures are handled with retries, fallback paths, or graceful error handling rather than trusted blindly.

“gives kind of like a a mediocre answer can't really can't really solve the problem it's it's too too complicated making sure you have code to handle uh fallbacks and errors um when they when they produce you know so this really sorry this example comes up if you're using function calling which is a”transcript, stated
“those function calls are not always 100% accurate right sometimes it doesn't give back valid Json and so like then it becomes like an error handling strategy um which again kind of falls back into a normal software development flow what what do you do do do you retry do you um do you just say”transcript, stated

model-routing (cost)

CircleCI describes routing easy queries to cheaper models and reserving expensive models for hard queries as usage scales.

“this idea of like routing is if it's a hard query use the expensive model if it's a simple query use a uh use use a cheaper model”transcript, stated

cost-aware-routing (cost)

Cost reporting, token accounting, fine-tuning, routing, and capacity choices are treated as a future operational layer for successful AI features.

“look at the invoice like see see where the see where the costs are going”transcript, stated
“we need to we need to start start thinking around you know cost management and and Alternatives”transcript, stated

fine-tuning-adaptation (model-ops)

Fine-tuning is discussed as a way to encode repeated context and shorten prompts, lowering per-request token cost.

“do do you fine-tune an open AI model to make the prompts shorter”transcript, stated

Tradeoffs

Evaluation strategy

Chose model-graded evals plus human review over string matching or deterministic unit tests alone.

Rationale: LLM outputs can be semantically correct in many forms and require subjective quality judgment, but automated graders still need human oversight.

“can can we ask it questions around about it about its own output um and then have it have it graded”transcript, stated
“it's not a human actually evaluating it's it's not your test cases are not production right um and so I think some of that human review is still very very important yeah yeah well I mean I think that there's there's going to be some nervousness I can't can't think of a better word right now”transcript, stated

Test coverage

Chose critical journey and weighted scenario testing over exhaustive replay of every production request.

Rationale: Exhaustive replay would increase time and cost, while focused journeys target the flows with greatest user value and risk.

“know I I would imagine or not imagine the way I think about this it's kind of like testing with production right the goal of testing is not to test exhaustively if you wanted to test exhaustively you would log every single request your application ever gotten the output of it and you would replay it”transcript, stated
“Focus that energy because it's a hard problem on the things that are going to be of greatest value to your users”transcript, stated

Cost scaling

Chose routing and fine-tuning where justified over one expensive model for every path.

Rationale: Routing and fine-tuning can reduce per-request cost, but they add branching behavior and testing complexity.

“if it's a hard query use the expensive model if it's a simple query use a uh use use a cheaper model”transcript, stated
“the more knobs and paths you create through the system the more you kind of have to manage”transcript, stated

Provider infrastructure

Chose managed foundation model APIs over building a private AI system from scratch.

Rationale: Managed services provide fast startup and low operational overhead when internal AI-system experts are scarce.

“any manage service becomes very easy to get up and running very quickly low operational overhead”transcript, stated
“there's maybe 200 300 people who can like really give you your own AI system kind of going”transcript, stated

Feedback source

Chose production user behavior as eval data over generic benchmarks alone.

Rationale: Real reprompts, regenerations, thumbs, abandonment, and human requests reveal use-case-specific model performance.

“it doesn't really do you any good if a model does really well on like a kind of industry standard Benchmark”transcript, stated
“everything the user does is some sort of feedback about how the model is performing”transcript, stated

Gotchas (what bit them)

Traditional deterministic tests do not map cleanly to LLM outputs.

Root cause: Language-model outputs are probabilistic, non-deterministic, and can be correct in many styles.

Resolution: Use evals, multiple scenarios, subjective criteria, and statistical confidence instead of exact expected strings.

“the output of these of these large language models in particular are you know probabilistic and non-deterministic”transcript, stated
“you really don't have a lot of those guarantees with uh with with language models”transcript, stated

Model-graded evals can contain hidden evaluator bias.

Root cause: Some models prefer their own outputs, and comparison prompts can have positional bias.

Resolution: Randomize, run multiple examples, use table-driven cases, and understand evaluator behavior before trusting scores.

“certain models prefer their own output right I think gp4 actually has a slight bias”transcript, stated
“sometimes the bias is isn't even model specific sometimes it's like position specific”transcript, stated

Testing every possible production case is impractical.

Root cause: LLM calls cost money and time, and high-volume exhaustive replay would be prohibitive.

Resolution: Focus eval spend on critical user journeys, invariants, table-stakes datasets, and differentiated flows.

“these llm output these LM models are kind of they're not high throughput query systems”transcript, stated
“what are the most critical sort of user Journeys that you care about”transcript, stated

Function calling does not eliminate structured-output failures.

Root cause: The model can fail to return valid JSON even when asked to call a function with a JSON payload.

Resolution: Treat it as normal error handling: retry, fall back, or route down an alternate path.

“this function that accepts a Json payload and you you kind of tell the llm to call your function”transcript, stated
“sometimes it doesn't give back valid Json and so like then it becomes like an error handling strategy”transcript, stated

Cost optimization adds system complexity.

Root cause: Fine-tuning, routing, model selection, and capacity choices create more knobs and more paths to test.

Resolution: Do not over-optimize prematurely, but understand that successful AI usage creates a future cost-management workload.

“the more knobs and paths you create through the system the more you kind of have to manage and make sure it's worked properly”transcript, stated
“if I'm succeed I'm signing up for this kind of work down the road”transcript, stated

Evaluation

CircleCI recommends model-graded evals, table-driven test cases, randomized or weighted scenarios, mutation-style rephrasings, adversarial prompt cases for open chat, critical user journeys, fallback/error testing for function calling, human review, and a production feedback flywheel. The goal is not deterministic proof, but enough confidence to deploy while understanding evaluator bias, model behavior, and use-case-specific failure modes.

Metrics: correctness · helpfulness · non-toxicity · tone/style fit · model-graded score · scenario-weighted aggregate score · positional-bias checks · adversarial prompt handling · valid JSON rate · retry/fallback rate · thumbs up/down · reprompt/regeneration rate · cost by model · token input/output cost

4 supporting quotes
“there's non-toxicity but there's also a sort of like you might think of it around like helpful”transcript, stated
“table driven testing right so they just like give it multiple scenarios right waight them”transcript, stated
“mutation testing go in randomly change the code and see how it fails um you you can do that with with these lenss take take the output and use like maybe a cheap model or or GT4 if you if you got the got the cach um and have have it reward the question then ask it again to to evaluate um and sort”transcript, stated
“could be a simple as thumbs up thumbs down could be behavioral if they reprompt if they regenerate a response”transcript, stated

Outcomes

The transcript is an engineering discussion rather than a metrics-heavy case study. It names long Java stack traces, GPT-4 evaluator bias, per-token input/output pricing, possible 50% price savings from routing when a cheaper model is good enough, and managed/dedicated capacity decisions such as Azure-hosted GPT-4 deployments.

4 supporting quotes
“long stack traces can we kind of quickly give you uh recommendations”transcript, stated
“eyeball through a very deep you know Java Java stack Trace um also looking at the idea of using AI to sort of just fix the bugs for you right if we have a thing that can write code can understand errors and and explain and come up with suggestions if we give it some extra context of you know what”transcript, stated
“you can get some dedicated capacity for for certain Foundation models”transcript, stated
“that have been formed around Cloud cost optimization and I feel like we just predicted a whole category of like Foundation model cost optimization like that's probably if you're listening to this podcast and you like just you know quit your job and you're not sure what to do with yourself this”transcript, stated