Skip to content

fix(gateway): scope answers to the question's subject on both answer prompts - #176

Merged
officialCodeWork merged 1 commit into
mainfrom
fix/answer-prompt-subject-scoping
Jun 9, 2026
Merged

fix(gateway): scope answers to the question's subject on both answer prompts#176
officialCodeWork merged 1 commit into
mainfrom
fix/answer-prompt-subject-scoping

Conversation

@officialCodeWork

Copy link
Copy Markdown
Owner

fix(gateway): scope answers to the question's subject

Both answer system prompts now instruct the model that retrieved passages about a
different subject (person / product / entity) than the question must not be
presented as the answer — it must say the context doesn't contain the answer
instead. This reduces a class of confident-but-wrong answers when retrieval
surfaces near-miss passages.

Applied symmetrically to both answer surfaces:

  • _ANSWER_SYSTEM_PROMPT/v1/query
  • INJECTION_RESISTANT_SYSTEM_PROMPT — the injection-resistant surface (Step 7.3)

Also .gitignores .env.openai so the local OpenAI-demo secret can't be staged.

Verification (local)

  • ruff + ruff format ✅ · mypy --strict (gateway + injection) ✅
  • pytest injection + gateway + the red-team prompt-injection suite ✅ (the
    prompt still excludes the injection payload and retains the "untrusted" framing,
    so the 7.3 invariants hold)

Note: org-wide GitHub Actions startup failures (billing) are unrelated to this
change; verified locally.

🤖 Generated with Claude Code

…prompts

Harden both answer system prompts so retrieved passages about a *different*
subject (person / product / entity) than the question are not presented as the
answer — the model must say the context lacks the answer instead. Applied to
_ANSWER_SYSTEM_PROMPT (/v1/query) and INJECTION_RESISTANT_SYSTEM_PROMPT (the
injection-resistant answer surface). Also gitignore .env.openai.

Verified: ruff, ruff format, mypy --strict (gateway + injection), pytest
(injection + gateway + red-team prompt-injection suite).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@officialCodeWork
officialCodeWork merged commit cb36fa0 into main Jun 9, 2026
13 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant