Prompts errors

Common error signatures

Errors in this module come from invalid inputs to build_augmented_prompt. Both are ValueError:

Where errors originate

How to diagnose

  1. Read the ValueError message directly. Both validation errors in build_augmented_prompt include the offending value and, for variant mismatches, the full list of valid options. You usually do not need a debugger — fix the argument shown in the message.

  2. Confirm query is a non-empty string before the call. If query is assembled dynamically (e.g. from user input or a retrieval pipeline), add an assertion or guard upstream:

    if not isinstance(query, str) or not query:
        raise ValueError("query must be provided before calling build_augmented_prompt")
    
  3. Check the variant value against the valid set. When the unknown-variant error fires, the message prints both the bad value and the accepted variants. Verify that any string passed as variant exactly matches one of those values (the comparison is case-sensitive).

  4. Inspect the hits iterable when context is empty or malformed. If the rendered prompt contains no passage content, confirm that join_context or join_context_numbered is receiving a non-empty iterable of RetrievalHit objects. An empty iterable produces an empty context string, which build_augmented_prompt will silently embed — no exception is raised, but the LLM receives no grounding passages.

  5. Verify prompt injection defence is not corrupting passage content. The <passage> sentinel wrapper includes an injection-defence clause. If downstream parsing breaks on the rendered prompt, check whether your hit contents themselves contain literal </passage> strings, which the module deliberately treats as documentation rather than closing tags.

Source files

Tags: prompts, templates, augmentation, citation