The problem
Running AI agents against a production system is easy to start and very hard to do responsibly. The interesting problems are not about model quality.
An agent with tools is an unbounded process. Nothing about a language model naturally stops. A reasoning loop that fails to converge will keep calling tools, keep spending tokens, and keep taking actions until something external stops it. Without an explicit ceiling, the ceiling is your bill or your incident.
"What is this agent allowed to do?" had no authoritative answer. Capabilities were implied by whatever tools happened to be wired up. Adding a tool silently expanded what every agent could do.
Agents duplicate work at scale. Several agents observing the same signal generate the same finding repeatedly. Without deduplication, an operator's queue fills with the same problem stated fifteen ways, and the real second problem is buried.
Multiple workers reach the same conclusion simultaneously. Which is fine for observation, and a serious problem the moment any of them can act.
Agents confidently reason from wrong assumptions. An agent that infers architecture from directory names will be wrong in a plausible, well-argued way. Ours had real material to be wrong about: several components share names, and a substantial subtree in the repository does not run at all.
The dangerous middle ground is autonomy without a rollout path. Either agents only observe, which is safe but low value, or they act, which is valuable and frightening. There was no defined route between the two.
Previous workflow
Before: agents as scripts with API keys
Each of these was fine in isolation. Together they meant nobody could answer 'what can this thing do?'
- Human action
Engineer wires up an agent for a task
- Problem: Capabilities implied by whichever tools were connected
- Problem: No registry of what any agent was permitted to do
- AI / LLM
Agent reasons over the system
- Problem: Context assembled ad hoc per invocation
- Problem: Inferred architecture from names, and names collide in this codebase
- Problem: No grounding in the actual documented invariants
- External service
Model API calls
- Problem: No token ceiling — a non-converging loop ran until someone noticed
- Problem: No runtime ceiling
- Problem: Cost visible only after the fact
- Automated software
Agent produces findings
- Problem: Identical findings from parallel agents
- Problem: No deduplication window
- Problem: Signal buried in repetition
- Human action
Someone reads the output
Decision point: Is this real, already known, or a repeat of the last three?
- Problem: Triage cost grew faster than agent value
- Problem: No record of what had already been decided
- Human action
- Automated software
- AI / LLM
- External service
Goals and non-goals
Goals
- Every agent job runs under an explicit token, tool-call and runtime ceiling.
- Every action names a capability that must exist in a registry, and the check fails closed.
- Capabilities roll out through observe, then assist, then autofix — never straight to acting on production.
- Deploy and migration capabilities are denied from autofix by default, as pattern-matched rules rather than case-by-case judgment.
- Duplicate findings are collapsed within a time window.
- Exactly one worker acts on a given job, even when several reach the same conclusion.
- Agents retrieve grounded context from real documentation rather than inferring architecture.
Non-goals
- Not an autonomous operations platform. Production mutation requires human approval; autofix is a narrow, per-capability grant.
- Not a general agent framework. It governs agents against one platform.
- No agent in the sending path. Stated explicitly, permanently.
- Not a replacement for monitoring. Agents explain and propose; deterministic monitoring detects.
My role
- Problem framing — argued that the constraint on agent value was governance and triage cost, not model capability. That reframing shaped everything after.
- Governance design — the three-mode rollout, the capability registry, the budget model and the fail-closed posture are the design decisions I own.
- Policy authoring — the default-deny patterns for deploy, migration and security-adjacent capabilities.
- Architecture — leader election, deduplication windows, rate limiting and the job and attempt record structure.
- Knowledge engine requirements — hybrid retrieval combining vector and keyword search, per-space collections, and an ingestion pipeline that keeps documentation current.
- Grounding strategy — established that agents read curated, verified documents rather than exploring source freely.
- Test planning — including the tests that assert denial on registry failure and correct budget enforcement.
- Honest status reporting — this project is partially operational and is labeled that way. Some capabilities observe; a small set assist; production mutation still requires a human.
Product solution
A job is the unit. An agent job carries a capability key, a budget, and a deduplication key. Each execution attempt is recorded with its status, timings, metrics and artifacts, so an agent's history is auditable rather than reconstructed from logs.
The capability registry is the authority. Before an action runs, its capability key is checked against a registry. If the check cannot complete — a database problem, a network fault — the action is denied. An outage cannot become an authorization bypass.
Three modes, escalated deliberately. In observe, the agent reports what it would do. In assist, it prepares a change for a human to apply. In autofix, it acts. The global default is observe. Escalation is per capability, and deploy, migration and security-adjacent capabilities are denied from autofix by pattern.
Budgets are ceilings, not guidance. Each job has a maximum token spend, a maximum number of tool calls and a maximum runtime. A loop that does not converge hits a wall instead of a bill.
Deduplication within a window. Findings that repeat inside the window collapse into one, so the operator queue reflects distinct problems.
Leader election for action. Several workers may reach the same conclusion; one lease-holder acts. Leases expire, so a dead leader does not block progress permanently.
The knowledge engine grounds it. Curated documents are ingested, chunked, embedded and indexed into per-space collections. Retrieval merges vector similarity with keyword matching, because the questions agents ask are often exact-term questions — a service name, an invariant, an error string — where pure semantic search underperforms.
Workflow
Agent job — request to outcome
Six gates between an agent deciding to act and anything changing in production.
- Automated software
Job scheduled
On a fixed tick with jitter, so parallel workers do not synchronize into a thundering herd.
- Approval gate
Deduplication window
Decision point: Has an equivalent job been seen inside the window? If so, collapse rather than run it again.
- Approval gate
Rate limit
Decision point: Is this capability within its allowed rate? If not, defer.
- Approval gate
Capability registry check
Decision point: Is this capability key registered? On any error, deny — the check fails closed.
- Approval gate
Policy mode resolution
Decision point: Observe, assist or autofix for this capability? Deploy, migration and security patterns are denied from autofix by default.
- Approval gate
Leader election
Decision point: Acquire the lease, or stand down. Exactly one worker acts; leases expire so a dead leader does not block progress.
- Data store
Grounded context retrieved
Hybrid vector and keyword search over curated internal documentation, scoped to the relevant space.
- AI / LLM
Agent reasons within budget
Bounded by maximum tokens, maximum tool calls and maximum runtime. Exceeding any ceiling ends the attempt.
- Automated software
Attempt recorded
Status, timings, metrics and artifacts persisted against the job.
- Human action
Human review
Decision point: Observe mode reports. Assist mode prepares a change for a person to apply. Autofix acts only where explicitly granted.
- Monitoring / feedback
Outcome fed back
Findings and their dispositions inform both the policy and what gets documented next.
- Human action
- Automated software
- AI / LLM
- Data store
- Approval gate
- Monitoring / feedback
Architecture
AgentOS and the knowledge engine — sanitized view
Governance and retrieval are separate concerns with separate stores. Neither is on the sending path.
Governance
Capability registry
Approval gate
Registered capability keys. The authority on what may be attempted. Denies on any lookup failure.
Autofix policy
Approval gate
Global mode plus per-capability overrides, with pattern-based deny rules for deploy, migration and security-adjacent actions.
Budget enforcement
Automated
Per-job maximum tokens, tool calls and runtime seconds.
Rate limiter
Automated
Per-capability rate control, independent of budgets.
Coordination
Scheduler
Automated
Fixed tick with jitter so parallel workers do not synchronize.
Deduplication
Automated
Time-windowed collapsing of equivalent jobs.
Leader election
Automated
Expiring leases so exactly one worker acts and a dead leader cannot block progress.
Job and attempt records
Data store
Status, timings, metrics and artifacts per attempt — an auditable history rather than log archaeology.
Knowledge engine
Ingestion
Automated
Curated source documents chunked with versioning and previews.
Embedding provider
External service
Chunk embeddings generated through an external model API.
Vector store
Data store
Per-space collections keyed to chunk identity.
Relational index
Data store
Documents, chunks and embedding records tracking what is indexed and where.
Hybrid search
Automated
Vector similarity merged with keyword matching, because agents often ask exact-term questions.
Agents
Diagnostic agents
AI / LLM
Delivery flow, lane health, delivery evidence and bounce backoff analysis.
Drift and documentation agents
AI / LLM
Detect divergence between documentation and code.
Operator review queue
Human
Deduplicated findings with their proposed actions and current mode.
Diagram is sanitized for publication: it shows responsibilities and data flow, not hostnames, addresses or credentials.
Where AI is used — and where it is not
AI / LLM responsibilities
- Reasoning over a diagnostic signal and proposing an explanation.
- Summarizing and prioritizing findings for the review queue.
- Drafting a remediation for a human to review in assist mode.
- Detecting drift between documentation and code.
- Semantic retrieval over the knowledge base.
- Explaining an anomaly a deterministic monitor has already detected.
Deterministic responsibilities
- Whether an agent is allowed to act at all.
- Capability existence — a registry lookup that fails closed.
- Budget enforcement, in tokens, tool calls and runtime.
- Rate limiting and deduplication windows.
- Leader election and lease expiry.
- The deny patterns for deploy, migration and security capabilities.
- Anomaly detection itself — monitoring detects, agents explain.
- Every metric and count an agent reasons over.
- Audit trail persistence.
Decisions and tradeoffs
Fail closed when the capability registry is unreachable
- Options considered
- Allow on error to preserve availability · Retry then allow · Deny on any error
- Chosen
- Deny on any error, and log the denial
- Reason
- Availability of an agent is worth far less than the guarantee that an outage cannot become an authorization bypass. Fail-open turns every database blip into a permission grant.
- Cost and risk accepted
- Agents stop working during database problems — exactly when diagnostic help would be useful.
- Result
- Accepted deliberately. An agent that cannot verify its own authority should not act.
Three modes rather than an autonomy toggle
- Options considered
- On or off per agent · A trust score · Observe, assist, autofix per capability
- Chosen
- Three modes, per capability, defaulting to observe
- Reason
- A binary toggle forces an all-or-nothing decision with no evidence. Three modes let a capability earn escalation by demonstrating correct behavior in a lower mode first.
- Cost and risk accepted
- More configuration surface, and capabilities that sit in observe indefinitely because nobody drives the escalation.
- Result
- Escalation became a reviewable decision with evidence behind it rather than an act of faith.
Pattern-based deny for deploy, migration and security capabilities
- Options considered
- Case-by-case review · An explicit deny list · Pattern matching
- Chosen
- Pattern matching, denied by default
- Reason
- An explicit list is only correct until someone adds a capability that matches the spirit but not the entry. A pattern covers the capability that does not exist yet.
- Cost and risk accepted
- Occasional false positives where a benign capability matches a denied pattern and needs an explicit override.
- Result
- The categories that should never self-heal are structurally excluded rather than reviewed.
Hybrid retrieval instead of vector search alone
- Options considered
- Vector only · Keyword only · Hybrid merge
- Chosen
- Hybrid, merging vector similarity with keyword matching
- Reason
- Agents ask exact-term questions — a service name, an invariant, a specific error string. Pure semantic search returns things that are about the right topic instead of the exact thing.
- Cost and risk accepted
- Two indexes to maintain and a merge strategy to tune.
- Result
- Retrieval quality on operational questions improved materially. Those are the questions that actually get asked.
Ground agents in curated documents, not free source exploration
- Options considered
- Let agents read the repository freely · Generate context automatically · Curate documents deliberately
- Chosen
- Curated, verified documents with limited source exploration
- Reason
- This codebase has colliding component names and a large subtree that does not run. An agent exploring freely reaches confident, wrong conclusions and argues for them well.
- Cost and risk accepted
- Curation is ongoing work, and curated documents can go stale.
- Result
- Drift detection became a first-class agent capability precisely because staleness is the cost of this choice.
What is running, and what is only declared
This is the section I would most want a technical interviewer to read, because the honest answer is more interesting than a clean one.
The declarative catalog is complete and unexecuted. Thirty-eight agent workflows are declared as capability graphs — ordered steps, parallel groups, named tools, an autonomy mode, required evidence — alongside 41 capabilities, 15 tools, 36 cron schedules each carrying its own token, tool-call and runtime budget, six event trigger rules with dedup windows, and two predefined chains. All of it version-controlled and reviewable in a pull request.
None of it runs. The definitions were never seeded into the database, and every run path checks an environment flag that is unset, so the orchestrator refuses to start a workflow at all.
Meanwhile agents are doing real work through a simpler path. The same worker runs a second route that takes a free-text task and a mode, executes it, and records the result with no workflow key attached. That path has completed more than 53,000 runs across over 125,000 steps, spread across a knowledge agent, a code agent and a runtime agent, and it is still producing runs today. Its event mapping covers incident detection, configuration drift, run failure and post-run distillation.
The governance gate is ahead of the thing it governs. The gate is wired and has emitted several hundred audited events, and its live policy rows sit at the strictest possible settings — concurrency of one, ten runs per hour, with both verification and canary required. But it has recorded no job-level allow or deny, because the runtime it protects is switched off. The guard was built before the door.
Retrieval is currently degraded. The hybrid retriever is designed to merge vector similarity with keyword search by reciprocal rank fusion. Right now the vector store holds no collections, so retrieval has fallen back to keyword search alone, and the document sync against the upstream source is erroring. The corpus itself is intact — over 8,300 documents and nearly 23,000 chunks across four spaces — but semantic retrieval is not currently happening.
Challenges
Budgets alone do not bound cost. A job that terminates cleanly at its token ceiling and is then immediately rescheduled costs the same as an unbounded loop, just in installments. Budgets needed rate limiting and deduplication next to them before the ceiling meant anything.
Deduplication keys are subtle. Too broad and genuinely distinct problems get collapsed into one, which is worse than duplication — you lose a real finding. Too narrow and near-identical findings all come through. Getting this right took several iterations against real finding streams, and it is still tuned rather than solved.
Leader election without lease expiry deadlocks. The first implementation had a worker acquire leadership and die holding it. Nothing errored; the capability simply stopped running. Expiring leases fixed it — the same lesson the enrichment queue taught, learned separately, which says something about how easy it is to forget that the holder of a lock can die.
Agents are confidently wrong when ungrounded. Early diagnostic agents produced well-argued analyses of a component that does not run in production. Not hallucination in the usual sense — correct reasoning from a directory that plausibly looked like the live system. This is why grounding is curated.
Escalation stalls without a driver. Three modes give a safe path from observe to autofix. They also make it very comfortable to leave everything in observe forever. Escalation needs someone to own it, and I have not solved that with process yet.
This project is genuinely partially operational — which is why the status on this page says so. The governance layer works. Retrieval works. The set of capabilities actually escalated beyond observe is small, and production mutation still goes through a human.
Testing and validation
| Layer | What it covers | Evidence |
|---|---|---|
| Acceptance criteria | Fail-closed authorization, budget enforcement, single-actor guarantee, deduplication within window. | Written as testable statements before implementation. |
| Unit | Budget enforcement, policy resolution, capability checking, deduplication keys, limiter behavior, scheduler jitter. | Package test suites covering each governance component. |
| Fail-closed | Registry unreachable must produce denial, not permission. | Test asserting denial on database error. |
| Concurrency | Leader election under contention, and lease expiry after a leader dies. | Tests that kill the lease holder and assert recovery. |
| Integration | End-to-end job lifecycle through every gate to a recorded attempt. | Integration suite in the governance package. |
| Retrieval evaluation | Hybrid search quality against known question and answer pairs. | Evaluation harness in the knowledge engine. |
| Production observation | Capabilities run in observe mode and are compared against what a human would have done, before any escalation. | This comparison is the gate for escalating a capability. |
| Monitoring | Job outcomes, budget exhaustion rate, denial rate, deduplication ratio. | Counters exported per capability. |
Results
| Measure | Before | After | How it is measured |
|---|---|---|---|
| Agent authorization | Implied by whichever tools were wired up. | A registry check per action that denies on any lookup failure. | Fail-closed behavior asserted by a dedicated test. |
| Cost bounding | A non-converging loop ran until someone noticed. | Per-job ceilings on tokens, tool calls and runtime, plus rate limiting. | Budget defaults defined in runtime configuration and enforced per attempt. |
| Autonomy rollout | Binary: observe only, or act. | Observe, then assist, then autofix — per capability, defaulting to observe. | Escalation requires evidence from the lower mode. |
| Dangerous capabilities | Governed by reviewer judgment. | Deploy, migration and security patterns denied from autofix structurally. | Pattern-based rules, so unwritten future capabilities are covered. |
| Finding quality | Parallel agents produced repeated findings; real signal buried. | Time-windowed deduplication and single-actor leader election. | Deduplication ratio tracked per capability. |
| Agent grounding | Architecture inferred from names, in a codebase where names collide. | Hybrid retrieval over curated, verified documentation. | Drift detection runs as its own capability because curation can go stale. |
No agent-volume or cost figures are published. The capability changes below are verifiable from the system's own code and policy.
Evidence
Capability policy configuration
Global mode, per-capability overrides and the pattern-based deny rules.
Placeholder — evidence pending sanitization review before publication. Agent finding review queue
Deduplicated findings with proposed actions and current mode.
Placeholder — evidence pending sanitization review before publication. Job attempt record
Status, timings, budget consumption and artifacts for a single attempt.
Placeholder — evidence pending sanitization review before publication. Retrieval evaluation output
Hybrid search results against known question and answer pairs.
Placeholder — evidence pending sanitization review before publication.
Lessons
What worked. Treating authorization as a deterministic, fail-closed lookup that no model participates in. Everything else about agent safety follows from that being true and unarguable.
What failed. I shipped budgets before rate limiting and thought the cost problem was solved. A bounded job rescheduled immediately is an unbounded job with extra steps. Bounding a single execution is not the same as bounding a system.
What changed. Grounding moved from automatic to curated. Free exploration produced confident, well-argued analyses of code that does not run — and the counter-measure had to be curation, with drift detection as its own capability to manage the cost.
What I would do differently. I would have designed the escalation process, not just the escalation mechanism. Three modes make the safe path available; without someone owning the decision to escalate, everything stays in observe and the value never arrives.
What this demonstrates about AI-product leadership. The hard part of agent systems is not making them capable — it is deciding what they are permitted to do, proving that boundary holds when things fail, and building a route from observation to action that an operations team will actually accept. That is product and governance work, not prompt work, and it is the difference between an agent demo and an agent you can leave running.
Next milestone
- Drive capabilities out of observe. Define what evidence justifies escalating a specific capability to assist, and give that decision an owner.
- Deduplication tuning from outcomes. Use human dispositions on findings to tune the window and key, rather than tuning by hand.
- Cost attribution per capability, so budget policy is set from observed spend rather than from an initial guess.
- Retrieval freshness guarantees. Track document age against the code it describes and surface staleness before an agent relies on it.