by AgentGrade (LX AI)
We need to produce HTML fragment, starting with the opening block exactly as provided:EXACTLY as the first element? Wait: The instruction says: "Keep the provided opening
EXACTLY as the first element. Do not delete the direct answer." But the provided opening block is
. Possibly they meant opening block includes
after? The given opening block is just the h1. The "Existing thin body" includes after that h1 some content. But we must keep the opening block verbatim as first content. So we start with
| Tool | Data touched | Access type |
|---|---|---|
| File reader | /var/data/input.txt | Read |
| Database writer | PostgreSQL users table | Write |
| Email sender | SMTP server | Send |
| Web scraper | Public HTML pages | Read |
I review this table with a teammate before moving to the next step. The act of putting the information in a table makes gaps obvious.
Now section 2:I treat any content the agent reads from outside as untrusted. This includes emails, web pages, tool outputs, and even logs that might be fed back into the agent. I apply three layers of defense.
I wrap every external data fetch in a function that strips lines that look like instructions. For example I remove any sentence that starts with “Ignore previous” or “You must”. I do this with a simple regex that looks for imperative verbs at the start of a line.
I change each tool to return JSON with a fixed schema rather than free‑form text. The agent then parses the JSON and only uses the declared fields. This prevents the tool from sneaking in a command.
I keep a list of actions that are considered high‑risk, such as deleting a record or sending money. Before the agent can invoke one of these actions I check the request against the allow‑list. If the action is not on the list the call is blocked.
For more details on prompt‑injection defenses I refer to the OWASP cheat sheet: https://cheatsheetseries.owasp.org/cheatsheets/LLM_Prompt_Injection_Prevention_Cheat_Sheet.html.
Now section 3:I never place API keys, database passwords, or other secrets inside a prompt or a log line. Secrets live only in environment variables or a dedicated secret manager.
I inject secrets at container start‑up through the orchestration platform. The agent reads them via process.env (Node) or os.getenv (Python). I never hard‑code them.
Before each build I run a script that greps the repository for patterns that look like keys (e.g., AKIA[0-9A-Z]{16} for AWS). The script fails the build if it finds a match.
If a leak is detected I immediately rotate the affected secret and redeploy the agent with the new value. I keep a log of rotation events for audit.
For guidance on managing secrets I consult the OWASP Secrets Management cheat sheet: https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html.
Now section 4:I define high‑risk actions as those that can cause irreversible change or financial loss: deletions, money transfers, changes to access control lists. The EU AI Act calls for human oversight for such systems (Article 14).
I work with the product team to list every tool endpoint that performs a delete, a payment, or a privilege change. I mark these in tools.yaml with a flag high_risk: true.
Before the agent can call a high‑risk tool I pause the flow and send a notification to a designated Slack channel. A human must react with an approval emoji. Only after the approval does the agent proceed.
I store the Slack user ID, the timestamp, and the runId together with the action request. This creates an audit trail that satisfies the EU AI Act requirement for oversight.
Reference: EU AI Act Article 14 – human oversight.
Now section 5:I generate a unique identifier for each agent execution and attach the version of the ruleset that governed the run. This pair lets me trace a bad output back to the exact input and policy.
I use a UUID v4 generated at the start of the run. I store it in the request context and pass it to every logging call.
The ruleset is a YAML file that lives in the repository. I read its Git commit hash and include it as ruleset_version in the log entry.
I ship logs to a structured logging service (e.g., Elasticsearch) where I can query by runId or ruleset_version. I retain logs for at least six months to meet the EU AI Act technical documentation requirement (Article 11).
Reference: EU AI Act Article 11 – technical documentation.
Now section 6:I put a hard ceiling on the number of tokens the agent may consume in a single run and per day. Without this guard a buggy loop can run up the bill.
I count tokens as they are generated by the LLM provider. When the counter reaches the limit I return an HTTP 429 error to the caller and stop further generation.
I maintain a rolling counter stored in Redis. At midnight UTC I reset the counter. If the daily limit is hit the agent refuses to start new runs until the next day.
Instead of silently degrading quality I return a JSON payload with error: "token_limit_exceeded" and a helpful message. This makes the problem visible in monitoring and alerts.
Reference: OWASP LLM10 – unbounded consumption.
Now section 7:I store the policy that decides which tools may be called, which actions need approval, and the token limits in a YAML file. This file lives in the same repository as the agent code and is reviewed through pull requests.
The ruleset contains sections for allowed_tools, high_risk_tools, token_limits, and approval_required. Changing any of these values requires a code review.
I tag the repository with a semantic version whenever the ruleset changes. The agent reads the version from the Git tag at start‑up and logs it.
If a new version causes a failure I can run git diff between the two tags to see exactly what changed. This makes regressions easy to spot and fix.
Reference: EU AI Act Article 9 – risk management.
Now section 8: What this is NOTI want to be clear about the limits of this checklist. It is not a guarantee that an agent will never fail. It does not promise 100 % coverage of every possible threat. It is not a substitute for penetration testing, red‑team exercises, or continuous monitoring.
Even if you follow every step, a novel attack vector could still appear. Treat the checklist as a baseline, not the final word.
Run unit tests, integration tests, and manual reviews in addition to the checklist. Use the checklist to gate deployment, but keep testing alive.
Threats evolve. I review the checklist every quarter and update it when new OWASP guidance or EU AI Act clarifications appear.
Now References section:List the system prompt, the tools the agent can call, and the data each tool touches. You cannot guard what you have not enumerated. (OWASP LLM06 - over-reliance; LLM01 - prompt injection surface.)
Treat any external content the agent reads - emails, web pages, tool output - as untrusted. Strip instructions, require structured tool outputs, and keep a deterministic allow-list for sensitive actions. (OWASP LLM01.)
Secrets belong in env vars, never in prompts or logs. Scan env files and CI config for leaked keys before deploy, and rotate on hit. (OWASP LLM02 - sensitive information disclosure.)
Deletes, sends, and payments should be gated. The EU AI Act puts human oversight (Art. 14) at the center of high-risk obligations. (EU AI Act Art. 14.)
Want a fast, self-serve read on your own agent? Try AgentGrade