Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ and this project adheres to
- ✨(dev) setup Tilt for local development
- 🐛(front) project modal now respects document-upload feature flag
- 🐛(back) self-doc tool no longer triggers on generic or document questions
- 🐛(backend) improve url hallucination instruction

## [0.0.15] - 2026-03-31

Expand Down
16 changes: 11 additions & 5 deletions src/backend/chat/agents/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@
logger = logging.getLogger(__name__)

PREVENT_URL_HALLUCINATION_INSTRUCTION = (
"Never invent or guess URLs. "
"Only include URLs explicitly found in tool outputs (e.g., web search results) "
"or in provided documents when available. Do not introduce new URLs."
"If you need to reference a web page that was not returned by a tool, "
"use a descriptive placeholder such as [official link] instead of a URL."
"URL POLICY (STRICT): Only include a URL if it appears verbatim in a tool result "
"or the user's current message. "
"Never write a URL in any other context — not in direct answers, "
"suggestions, examples, templates, "
"code blocks, or resource recommendations. "
Comment thread
maxenceh marked this conversation as resolved.
"Never write a URL to well-known websites you know from training. "
"When no verified URL is available, refer to resources "
"by plain text name only (e.g., 'the ANSSI website'). "
"When you cannot access a linked document, do not generate "
"fictional templates or mock examples of "
"its content — ask the user to share the relevant content directly."
)

MOCKED_RESPONSE = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def assert_base_instructions(instructions, date_str=None, language_str=""):
assert instructions[2].__name__ == "enforce_response_language"
assert instructions[2]() == language_str
assert instructions[3].__name__ == "prevent_url_hallucination"
assert "Never invent or guess URLs" in instructions[3]()
assert "URL POLICY" in instructions[3]()


@pytest.fixture(autouse=True)
Expand Down
Loading