Review a Pull Request That Adds an LLM Call for Timeouts, Truncation, Validation, and Cost
You are reviewing a pull request that adds or changes a call to a large language model inside application code. Ignore style and naming unless they hide a bug. Review the diff specifically for the failure modes that LLM calls introduce and ordinary code review tends to miss. Check each of the following and report only concrete findings tied to specific lines: 1. Timeouts and cancellation: Is there an explicit request timeout? If the caller gives up (user navigates away, upstream deadline passes), is the model call cancelled or does it keep running and billing? 2. Output length and stop handling: Is a maximum output length set? Does the code check why generation stopped, and handle a truncated response differently from a complete one? 3. Output validation: Is the response parsed and validated against an explicit schema or expected format before anything downstream uses it? What happens on a parse failure: retry with the error, fallback, or crash? 4. Untrusted input: Is user-supplied or retrieved text clearly separated from instructions in the prompt? Could that text change what the model is told to do, or reach a tool call with side effects? 5. Retries and cost: Are retries bounded and limited to retryable errors? Could a loop, a batch job or a retry policy multiply calls unexpectedly? Is the call tagged so its cost can be attributed? 6. Logging and data: Are prompts and responses logged? If so, is personal or secret data redacted first? 7. Testability: Can this code path be tested without a live model call (recorded responses, an injected client)? Is there at least one test for the failure path, not just the happy path? For each finding give: the line or function, the concrete scenario that breaks, severity (blocking / should-fix / nit), and a minimal suggested fix. If a category has no issue, say "no issue found" in one line rather than inventing one. End with a one-sentence merge recommendation. Diff: <paste diff here> --- When to use it: on any PR that introduces a model call, changes a prompt's surrounding code, or alters retry/timeout settings for an LLM client. It complements a general review rather than replacing it. How to adapt it: delete categories that don't apply (for example, a pure offline batch job may not need cancellation) and add your team's own requirements, such as a mandatory cost tag or a specific schema library. If your stack has a standard client wrapper, tell the model so it can flag calls that bypass it. Example input: a 60-line diff adding a `summarize_ticket()` function that calls the model and returns `response.text` directly to the UI. What good output looks like: a short list such as "summarize_ticket, line 22: no timeout; if the provider stalls, the request handler holds a worker indefinitely. Blocking. Pass a timeout and surface a fallback message." followed by "Output validation: no issue found — plain text is displayed as-is and escaped by the template," and a merge recommendation. Weak output lists generic advice with no line references.
Sign in to upvote this prompt.