Prompts
Development & AI

Code Review for a System Integrating AI Models

A code review focused on failure modes unique to LLM integration: unexpected output handling, timeouts, cost, prompt injection, and data leakage.

Prompt

Review the following code, which integrates a language model. Focus on LLM-specific failure modes that ordinary code review misses.

Code: <code> [Paste] </code>

Context: [what the code does and what happens to the output]

Check in this order:

  1. Unexpected output — what happens when the model returns malformed JSON, a missing field, a wrong type, or prose before the JSON? Is there validation before use, or will a direct parse crash the flow?
  2. Network failures — is a timeout set? Retry with backoff? What happens on a 429 or 503? Would a retry on a partially completed action cause duplication?
  3. Cost and budget — is there an input token limit? What stops a loop that calls the model unbounded? Is cost measured?
  4. Prompt injection — does user input enter the prompt without delimitation? Can retrieved document content contain instructions the model will follow?
  5. Data leakage — what is sent to the external provider? Can secrets, keys, or client data enter the prompt? Are prompts logged with their content?
  6. Non-determinism — does the code assume a fixed format the model may break? Is temperature appropriate for the task?
  7. Failure experience — when the model fails, what does the user see? Does the system fabricate an answer instead of admitting failure?

For each finding: severity (blocker / important / improvement), a short explanation, and the fix as a code snippet. Do not report style issues.

Why this converts well

  • Ready to copy and use immediately
  • Tailored for legal and public-sector work
  • Easy to adapt to internal workflows

Tags

code-reviewllm-integrationreliabilitysecurity