Implementation guide OWASP AISVS v1.01

Model Behavior, Output Control & Safety Assurance · Output Format Enforcement

Limit how long outputs can run

AISVS 7.1.2 Level 1

Verify that model-generated output is bounded by length limits and termination controls.

OWASP AISVS v1.01, requirement 7.1.2

In plain English

Cap how long a response can be, and make sure generation always stops. Without limits, a manipulated or malfunctioning model can run until it exhausts your budget or ties up capacity other users need.

What good looks like

  • A maximum output length is set on every model call, sized for the use case.
  • Streaming responses have a time limit as well as a token limit.
  • The application checks why generation stopped and handles a cut-off response safely.
  • Loops that call the model repeatedly have their own cap (see 9.1.1).

How teams usually do it

  • Set the maximum output tokens parameter explicitly on every call. Do not rely on the provider default.
  • Add stop sequences where the output has a natural end.
  • Read the stop or finish reason in the response. Treat "hit the length limit" as incomplete output, particularly when the output is structured data.

Suggested evidence

  • Model call configuration showing the limits.
  • Code that checks the finish reason.
  • A test where an over-long generation is cut off and handled.

Common mistakes

  • Leaving the maximum unset, which leaves cost and response time open.
  • Parsing a truncated JSON response as though it were complete.
  • Setting the limit so high it never applies.

Not sure which requirements apply to your system? Take the assessment, or browse every guide in this chapter.

Requirement text from the OWASP AI Security Verification Standard, licensed under CC BY-SA 4.0. This guidance is shared under the same licence.