How Do You Close the Loop from Production Failures Back Into Your Eval Set

Published
Length
3 min read

Luis Felipe Dias

All posts

You close the loop by saving failed live runs and turning them into test cases. When teams ask how do you close the loop from production failures back into your eval set, they build a pipeline from live logs to test suites. AI agents fail in ways that static tests miss. Users send weird inputs, and live databases change every minute. A good feedback loop catches these bad runs right away. It strips out private data and adds the clean prompt to your golden test set. How do you close the loop f

Human-in-the-Loop Approvals + Customer Support Access to Production: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You close the loop by saving failed live runs and turning them into test cases. When teams ask how do you close the loop from production failures back into your eval set, they build a pipeline from live logs to test suites.

AI agents fail in ways that static tests miss. Users send weird inputs, and live databases change every minute. A good feedback loop catches these bad runs right away. It strips out private data and adds the clean prompt to your golden test set.

How do you close the loop from production failures back into your eval set in practice

First, your team must spot when an AI agent makes a mistake in a live app. You can flag bad runs through user thumbs-down clicks, tool errors, or high latency. You can also run a small judge model to score a sample of live replies.

Second, you capture the full context of the failed run. A prompt alone is not enough to reproduce a complex agent bug. You need the system prompt, the user input, the tool calls, and the database responses. Without the exact state, your test will not match the live failure.

Third, an engineer or a review queue checks the flagged trace. The reviewer writes down the right answer or the right tool call. Then the system formats the input, state, and expected output as a new test row. Every new code change must pass this test before going live.

Security and operational tradeoffs of using live data for evals

Moving live traces into a test database creates big security risks. Live prompts and tool outputs often hold private user data. If you copy raw logs into your test suite, you spread secrets into lower stages. Every developer and third-party eval tool might read those test files.

Static database roles and API keys do not fix this problem. A role only checks if the app can log in to the database. Once the session starts, static keys allow full queries and return raw rows. Static roles cannot stop an agent from pulling emails or card numbers into a trace.

Human-in-the-Loop Approvals + Customer Support Access to Production: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Before any failed run enters your eval set, you must clean the data. Data masking rewrites matched fields like emails, phone numbers, card numbers, and national IDs in results. This step keeps real user secrets out of your test files while keeping the test valid.

Keeping the eval set fast and clean over time

If you add every single failure, your test suite will grow too slow and costly. Group similar failures together and pick one clear example for each bug type. Tag each test case with the bug category and the date you found it.

Run the fast, high-value tests on every code commit. Run the full, heavy eval suite once a night or before major releases. When your product changes and old features go away, delete the outdated test cases. This keeps your feedback loop sharp and fast for the whole team.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

What signals show that a live AI run failed?

Look for explicit user feedback, such as a thumbs-down click or an edited reply. Also track system errors like failed tool calls, loops, timeouts, and blocked outputs.

How do we keep private data out of our eval set?

Scrub all logs before saving them to your test storage. Masking rewrites matched fields like emails, phone numbers, card numbers, and national IDs in results.

How many production failures should we add each week?

Add only one or two clean examples for each new bug pattern you find. Adding duplicates makes your test runs slow and raises your model bill.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.