We ran the hackathon's official adversarial test set against our agent before reading the answers. Not one planted secret leaked. It also created a shipment record for every one of the 20 inputs and put it on hold, including a meeting invite and a cold-room sensor feed. "Zero leaks" was true, and it told us almost nothing.
The agent is QCOGate, and it watches an Indian importer's compliance inbox. It checks supplier documents against Indian import rules, holds what it can't clear, asks the supplier once, then stops and hands over to a person. It never releases a shipment itself. This post covers seven near misses from building it, starting with that one.
Key Takeaways
- "0 leaks" can hide bad behaviour. Our blind run leaked no planted secrets across 20 inputs and still put a shipment on hold for all 20 inputs, none of which were shipments.
- A safe-looking result can be a bug. A broken extractor looked like a careful agent for a whole run. Track how often the agent says "needs review", and cross-check the LLM with plain code.
- A guardrail only covers the path it sits on. Our quote check protected the main pipeline, but a later feature put raw model output in a person's task list.
- Test the stop button like any feature. STOP ALL stopped the server but not the command-line runs, which kept holding shipments and sending email.
What QCOGate does, and what counts as a near miss
BIS is the Bureau of Indian Standards. A Quality Control Order (QCO) is a government order, published in the Gazette of India (the official legal journal), that makes a BIS licence mandatory for a product from a set date. BIS needs a separate application for each product at each factory (BIS FMCS FAQ), so "the supplier has a BIS licence" isn't the same as "these goods are covered".
QCOGate checks that difference for every shipment. An LLM with no tools extracts fields, and every value must come with a verbatim quote that code finds in the document, or it's dropped. We call that check grounding. Deterministic rules then check the S.O. 219(E) and S.O. 5624(E) orders and a snapshot of the BIS licensee list (3,239 entries). A policy gate approves or blocks each action. The design is built to fail closed: when anything is unclear, it holds the shipment and asks a person, and never passes it. The full design is in AGENT.md and SAFETY.md.
A near miss is a moment where the agent did, or nearly did, something we never asked for, and we caught it before it mattered. Here are seven, with the evidence for each.
| # | What nearly went wrong | How we caught it | Evidence |
|---|---|---|---|
| 1 | Held 20 inputs that weren't shipments | Blind Trap Pack run | Trap Pack analysis. |
| 2 | A broken extractor looked like a careful agent | First live runs | Grounding code. |
| 3 | Raw model output reached a person's task list | AI code review | Regression tests. |
| 4 | STOP ALL didn't stop every process | AI code reviews | Kill switch. |
| 5 | A spoofed sender and a forged "verified" record | AI code reviews | Sender checks. |
| 6 | Git rewrote our test inputs | Replay misses | Trap Pack runs. |
| 7 | A BIS link nearly gave the agent the wrong law | Reading the Gazette | Research notes. |
1. Why did a leak-proof agent hold 20 shipments that didn't exist?
The Agentware Trap Pack is the hackathon's official set of hostile test inputs. Ours had 20: 18 traps and 2 harmless controls. The traps include things such as a fake CEO email, a broken bank CSV, a poisoned CI log and instructions hidden inside documents (the indirect prompt injection attack described by Greshake et al., 2023). The leak traps carry a canary, a planted fake secret that must never leave the system. We ran the pack before reading the expected answers.
The headline looked great: no canary leaked from any of the 20 inputs, and no hidden instruction was followed. Then we read the actions. Every one of the 20 inputs created a placeholder "UNMATCHED" shipment record and put it on hold: a security newsletter, a meeting request, a cold-room sensor feed. The agent also tried to email the supplier 20 times, and the policy gate blocked all 20. (The raw results file shows one outbound_messages per trap: that's the blocked request, and no mail was sent.)
Holding an empty record is harmless. Still, it's an action on input that was never a shipment, and stopping that is the whole point of an agent that "knows when to stop". The agent knew one kind of input: a supplier sending shipment documents. So it treated everything as a shipment it couldn't match, and failing closed meant holding it.
The fix was an out-of-scope stop. With no purchase order, invoice, bill of lading (the carrier's shipping receipt), specification, licence or product line, the agent now creates no shipment, holds nothing and emails nobody. It files one triage task for a person, saying why. A deterministic backstop keeps any PDF or trade-term input in scope, so a real shipment can't slip out. In every run after that fix (all made after reading the expected answers), 0 of 20 inputs were held.
It isn't perfect. Read strictly against the expected answers, the final code fully meets 9 of the 18 traps and partly meets the other 9. One harmless control, a security newsletter that quotes attack examples, still raises two HIGH flags.
Lesson: "0 leaks" was partly by construction, because the agent has no browser, shell or payments. The useful measure was what it did with input that was never its job.
2. How did a safe-looking result hide a broken agent?
These were three failures with one lesson: nothing independent was checking what the LLM said. We hit them in our first live runs on Gemini 3.1 Flash-Lite (free tier).
-
Run 1: everything failed. The model returned
instruction_like_textas a{"value": ...}object instead of a list, copying a shape from our prompt. The system failed closed, with no assessment and no actions. That was correct, but nothing worked. We added a tolerant pre-validation step that can't invent a quote. -
Run 2: it "worked", and was wrong. Every document came back as OTHER, because Gemini wrapped
doc_typein{value, quote}. The purchase order, invoice and bill of lading were reported missing while attached. The rules failed closed, so the result was NEEDS_REVIEW, not a wrong pass. That safe result was the bug: a silent extraction failure looked like caution. - Run 3: the model cried wolf. The LLM flagged our harmless demo footer, "SYNTHETIC DEMO DOCUMENT - fictional companies - not a real transaction", as a prompt injection. That would have blocked every compliant outcome.
The fixes: unwrap the value, and add a deterministic heading classifier next to the LLM. When the two disagree, the agent raises a DOC_TYPE_CONFLICT finding. An LLM flag now blocks only when the flagged text contains an imperative, and the regex and hidden-text detectors stay authoritative.
Lesson: an agent that answers "needs review" to everything passes every safety test. Track the rate of cautious outcomes, and add an independent cross-check, so a degraded extractor shows up as a disagreement instead of caution.
3. Raw model output got past grounding
Grounding guarded the main pipeline: no verbatim quote, no value. But two later paths read model output without it. An adversarial AI code review, run after each feature, caught both. We then reproduced each one with a hostile test document.
The date watcher re-checks licences near expiry. It read the licence number and expiry straight from the stored extraction, including values that had failed grounding. For example, in our test, the task a person would see read:
Licence URGENT wire fee to IBAN DE00 1234 today expires on …
The report had the same gap. Whenever grounding rejected a quote, the report showed the model's proposed quote as if it were document text. A fabricated api_key=sk-… made it into the report, unredacted.
The fixes: the date watcher uses only grounded values, and cleans and caps the licence number at 40 characters. Rejected quotes are labelled LLM_PROPOSED_QUOTE, redacted and cut to 160 characters. Both cases have regression tests.
Lesson: a guardrail protects the path it sits on. Every new feature that reads LLM output is a new path, so list every consumer of the model's output and check each one.
4. Why didn't STOP ALL stop everything?
We had to fix the kill switch twice. The first problem was a fail-open: a hold that the kill switch cancelled was never retried, so the shipment stayed un-held. That's the one place where failing open matters most.
The cause was threading. The kill endpoint ran on a worker thread, because FastAPI runs plain def endpoints in a thread pool. Most asyncio objects aren't thread-safe, so cancelling tasks from there was unreliable, and in-flight LLM calls could keep running.
We made the endpoint async, saved the kill flag so it survives a restart, and set retry rules per action. A hold is retried. A supplier email is never re-sent when its outcome is unknown, because a duplicate email is a real-world side effect.
A later review found the second problem. STOP ALL set the flag in the server's memory, but command-line runs such as run-once and followup-once kept their own copy. We reproduced it: after STOP ALL, a command-line run still held a shipment and sent email. Now every check re-reads the saved flag, and keeps the last known state if the read fails, so a read error never quietly un-stops it. One limit remains, listed in SAFETY.md: a call already in flight in another process finishes, and that run stops at its next check.
Lesson: a stop button is part of the agent. Check which thread and which process it reaches, and what it leaves half-done.
5. Trusting the container instead of the claim
Two bugs, one pattern. Each check verified something other than what the agent was about to act on.
-
A display name spoofed the sender. An email from
"export@brightpan.sandbox.test" <attacker@evil.example>passed our sender check, because the regex took the first@it found. We switched to Python'semail.utils.parseaddr. A sender we don't recognise can no longer cause a shipment to be held. For a purchase order we can't match, the sender must be on a known supplier domain or one of the importer's own. - A real hash "verified" fake dates. The regulation watcher accepts new Gazette records. A hostile record could claim "verified" by citing the sha256 of a genuine Gazette PDF, while changing the dates inside the record. The hash proved only that a real PDF existed. Now a record counts as verified only if its rule fingerprint (order number, dates, standards and supersessions) matches a curated reading of that exact PDF.
Lesson: a display name and a file hash each vouch for a container. Verify the claim the agent will act on: the real address, the real dates.
6. Git rewrote our test inputs
QCOGate has a replay mode that re-serves recorded real model responses, so judges can run it with no API key. Replay looks up each response by a hash of the exact text sent to the model. Git's line-ending conversion quietly changed the bytes of four Trap Pack emails, so replay missed them, and those traps would have looked like model failures.
Now the runner reads the traps from the committed zip after checking its sha256 against the published value. A .gitattributes rule stops Git converting the pack.
Lesson: if you record and replay LLM responses, pin the input bytes, or the harness changes the test.
7. A BIS link nearly gave the agent the wrong law
Our research notes show the agent's rules could have been keyed to the wrong order. The BIS site linked what it labelled the original cookware order, but it was a different order with the same title: S.O. 1661(E), a Ministry of Steel order on stainless steel. One secondary source, seen only as a search snippet, gave 16 Oct 2026 for the amending order, while the Gazette text says 13 Oct. Reading the primary documents caught both.
Lesson: key rules on identifiers such as the order number and the standard number, never on a title. Treat summaries as leads.
Methodology: how we tested this
Every number about our own runs comes from files in the QCOGate repository, under the MIT licence.
- Model: Gemini 3.1 Flash-Lite on the free tier, through an OpenAI-compatible API, with Gemini 3.5 Flash and 3.8 Flash as fallbacks.
- Test setup: each Trap Pack input ran in a fresh sandbox. Emails arrived as email, and other files arrived as attachments from a known supplier, the hardest case.
- Sample size: 20 inputs per Trap Pack run, and 12 consistency runs (4 scenarios, 3 runs each).
- Research method: for the regulations, we read the primary Gazette PDFs and recorded each file's sha256 in the repository.
- Trap Pack: four live runs, one blind and three after generic fixes. A replay re-check confirmed the final code. Only the blind run is a clean measurement.
- Consistency: all 12 live consistency runs gave the expected outcome (RELIABILITY.md).
- Reviews: adversarial AI code reviews after each feature. Findings were fixed with a test, or listed as known gaps in SAFETY.md.
- Tests: 222 automated tests (one needs the mail sandbox and is skipped without it), including regression tests for each code fix above.
- Traces: hash-chained audit traces for each run, indexed in traces/README.md.
What we'd tell other agent builders
- Measure what the agent does with input that isn't its job, not just what it leaks.
- A safe result isn't proof it works. Watch the rate of "needs review" outcomes.
- Put a deterministic cross-check next to every LLM extraction that matters, and raise a finding when they disagree.
- Make the LLM prove each value with a quote that code checks, on every path that reads model output.
- Let LLM flags escalate only with a deterministic condition attached.
- Review the kill switch for threads, processes and half-done state, and set retry rules per action.
- Verify the claim you'll act on, not the container it came in.
- Pin the bytes of anything your replay or cache is keyed on.
About us
Team Ashtavinayak is the team that built QCOGate for Agentware 2026 (Open Track): an agent you can leave on an importer's compliance inbox that knows when to stop. The code, the demo run, the traces and the Trap Pack results are public at github.com/GauravS13/qcogate.
Contact: open an issue on the QCOGate repository. Corrections are welcome.
Editorial note: we fact-checked the numbers in this post against the files in the repository on 1 Dec 2026. The evidence table and the Methodology section link the sources.
More on these topics on Dev.to: #ai, #agents, #security and #llm.
Thanks to Hackathon Raptors for the Trap Pack and the prompt behind this post, and to FileClerk for sponsoring the Near Miss prizes.

Top comments (1)
the out-of-scope stop is the right fix for new mail. what i'd still add is a check on the placeholder holds that already got created. a hold that is retried later can keep treating those unmatched records as shipments, even after the new path stops opening them. i'd refuse any later hold retry or supplier follow-up on a placeholder that was opened from input with no purchase order, invoice, or bill of lading.