A project by Muhammad Khan · Building safer AI systems

Your AI works in a test.
What happens when something goes wrong?

AgentHub is a project for testing and running AI assistants. It checks new versions, limits what they can do, and helps you find and undo a bad change.

01 · Test before use02 · Watch for problems03 · Check that the fix worked

01 / The starting point

The answer is only the beginning.

An AI agent is software that can answer questions and use tools to do a task. A small change to its settings can make a good answer wrong or slow. Who made the change? Which version handled the request? Can we go back?

The problem

One good answer does not prove an AI assistant is ready for people to use. We need to test it, check its access, and keep records that help us fix problems.

The project

AgentHub brings these checks into one place. It uses three store assistants to show the full process, from saving a new version to fixing a failed update.

02 / The demo assistants

Three useful jobs. The same safety checks.

Inventory

Checks store stock without changing it. For example: which Toronto stores may run low on snow shovels?

Knowledge

Looks up store rules and shows where its answer came from. For example: can I return an unopened product after 20 days?

Shopping

Finds products that match what a shopper needs, using the store catalogue. For example: find a snow shovel under $60.

03 / The failure story

One setting changed. The whole request slowed down.

In the repeatable demo, a Knowledge assistant goes from looking up 5 results to 50. The model takes the same time, but retrieval gets much slower. An injected guardrail signal opens an incident while the new version is still at 5% of traffic.

04 / Step by step

Check a new version before more people use it.

  1. 01Save a version

    Record its settings and who owns it. Keep that record unchanged.

  2. 02Run tests

    Stop a new version if it fails a required check.

  3. 03Check access

    Let code decide which tools the AI is allowed to use.

  4. 04Start small

    Compare the new version with the old one. Send it only a small share of requests.

  5. 05Watch results

    Track response time, errors, and cost.

  6. 06Find and fix problems

    Read the saved records, switch back to a working version, and check the results.

Try each step →

05 / Engineering choices

The decisions behind the screens.

Saved versions stay the same

Once a version is saved, its settings cannot be replaced under the same version number. Tests and release records still point to the exact version they checked.

See the version test ↗

One app, separate parts

The app runs as one service, with separate code for tests, access rules, releases, and repairs. PostgreSQL transactions save related changes together, so a half-finished update does not become the new state.

See the full lifecycle test ↗

The AI cannot give itself access

The AI can ask to use a tool. Separate code checks whether it is allowed. Changing the AI's instructions does not give it more access.

See the access tests ↗

No data means no wider release

The new version must have enough test results and recent measurements before it gets more requests. Missing data does not count as a pass.

See the canary tests ↗

Finding a cause does not grant control

The part that explains a failure points to saved records. It cannot change a running release. Separate code checks whether switching back is allowed and carries out that change.

See the rollback checks ↗

A completed change is not a proven fix

Switching back to an older version is called a rollback. That step can finish while the service still has problems. New measurements must show that it is working again.

See the recovery test ↗

06 / How it is built

Where a request goes.

User sends a request→Check who sent it→Check access and spending limits→AI uses allowed tools
Save a version→Run tests→Try a small release→Find problems and switch back

PostgreSQL is the database. It keeps the version history and records of what changed and why.

OpenTelemetry collects measurements→Prometheus stores counts and timingsTempo stores the steps of each requestGrafana shows the results

07 / When things break

What if part of the system stops working?

The access check is down

The request stops. The system does not assume that a missing check means permission was granted.

The test version is too slow

During a background comparison, the user still gets the current version's answer. A slow test version is recorded as a failure instead of breaking that answer.

The database is down

The service reports that it is not ready to handle work. A separate check shows whether the app itself is still running. Database connections have limits.

Someone asks for the same fix twice

The system checks what has already happened before changing where requests go. Repeating a rollback request should not create a second, conflicting change.

08 / What is real

What this demo does and does not show.

Working software

The app runs real code for tests, access checks, releases, and rollback. It saves records in PostgreSQL and measures requests handled by the running app.

Made-up demo data

The store data, sample AI answers, and staged failure are made for this demo. The same inputs give the same results, so you can repeat the test without paying for an AI service.

Cloud setup still needs testing

The repo includes code and setup files for Azure. This page shows the local project, not a live cloud service or proof that it can handle a large number of real users.

09 / Common questions

Why build it this way?

Why use fixed sample AI answers?

They let you repeat the same test and see the same failure without paying for an AI service. A real model can give different answers. Its accuracy, speed, and cost would need separate tests.

Why build this instead of using an existing platform?

The goal is to show how the checks work underneath the screens. You can read the code that blocks a release, checks access, and handles a failed update. This project is for learning and testing these ideas; it does not claim to replace a hosted platform.

What is the hardest part of the design?

Keeping every record tied to the right version. A test result is only useful if it describes the version being released. Saved version records cannot be replaced, and related database changes are saved together.

Could it handle more users?

That needs testing. The local demo runs one app process. Before adding more users, I would test real AI services, set database connection limits, connect user accounts, and measure where the system slows down.

What is needed before a company could use it?

The team would need its own access rules, people responsible for running the service, tests based on real tasks, and practice recovering from failures. The current project shows the process on a local machine.

How do I add another AI assistant?

Write its task code and a settings file that lists its model and tools. Add sample questions and rules for passing the tests. Save a version, then run it through the same access checks and release steps.

10 / Explore further

Try it on your computer.

Python · FastAPI · PostgreSQL · SQLAlchemy · Alembic · OPA · OpenTelemetry · Prometheus · Tempo · Grafana · Docker · Helm · Terraform