AAK-LLM-NO-MAX-TOKENS-001: A web route or agent tool calls a model with no output cap
- Severity
- LOW
- Category
- Trust Boundaries (
trust-boundary) - Scanner
agent_audit_kit/scanners/llm_call_shapes.py- Auto-fixable
- No.
- SARIF name
LlmCallNoOutputCap
What it detects
A function decorated as a web route or an agent tool calls a chat completion with no max_tokens or max_completion_tokens, so each request can spend up to the model's own limit and a caller can repeat it. A cost ceiling has to hold before the call. **kwargs on the call is taken to set the cap.
How to fix
Pass max_tokens or max_completion_tokens on every call a request can reach, cap the length of the input as well, and check a per-request or per-caller budget before the call. Accounting after the call is useful for dashboards but stops nothing.
To confirm the finding is gone, report only this rule:
agent-audit-kit scan . --rules AAK-LLM-NO-MAX-TOKENS-001
Limitations
Reads a Python function decorated get, post, put, patch, delete, route, api_route, websocket, tool, function_tool or call_tool that itself calls chat.completions.create, ChatCompletion.create or acreate, or litellm.completion or acompletion. So a helper the handler calls and a script with no route are not read. Read on every call the rule fired on 105 of 194 public OpenAI callers, batch scripts included, and read this way on 4 of them. The Responses API, Gemini and LangChain are not read, and the Anthropic SDK requires the parameter. A budget or a rate limit elsewhere is not seen. Paths with a tests, fixtures, examples, samples or demos directory, and test_*.py and conftest.py, are skipped. A source file over 512 KB is not read.
References
- OWASP Agentic Top 10: ASI08 (Cascading Failures)
All rules. This page is generated from the rule registry when the documentation is built; to change it, change the rule in agent_audit_kit/rules/builtin.py. To give the rule a hand-written write-up, add docs/rules/AAK-LLM-NO-MAX-TOKENS-001.md: the page then shows that text, with the registry reference appended under it.