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 application/single_app/collaboration_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@
'cited_hybrid_citations',
'cited_web_search_citations',
'agent_citations',
'm365_citations',

Check warning on line 703 in application/single_app/collaboration_models.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.
'agent_display_name',
'agent_name',
'extracted_text',
Expand Down
4 changes: 2 additions & 2 deletions application/single_app/functions_chat_content_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
)
ANSWER_FIELDS = (
"hybrid_citations", "web_search_citations", "agent_citations",
"cited_hybrid_citations", "cited_web_search_citations",
"cited_hybrid_citations", "cited_web_search_citations", "m365_citations",

Check warning on line 45 in application/single_app/functions_chat_content_checks.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.

Check warning on line 45 in application/single_app/functions_chat_content_checks.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains secret or sensitive data source marker. Recommendation%3A Pair this source with any nearby network, logging, serialization, or process execution sink before approving.
"generated_artifacts", "generated_analysis_artifacts", "generated_tabular_outputs",
)

Expand Down Expand Up @@ -309,7 +309,7 @@
"done": True, "blocked": True, "role": "safety", "replace_content": True,
"reply": result.notice, "content": result.notice, "full_content": result.notice,
"conversation_id": conversation_id, "message_id": message_id,
"hybrid_citations": [], "web_search_citations": [], "agent_citations": [],
"hybrid_citations": [], "web_search_citations": [], "agent_citations": [], "m365_citations": [],

Check warning on line 312 in application/single_app/functions_chat_content_checks.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.

Check warning on line 312 in application/single_app/functions_chat_content_checks.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains secret or sensitive data source marker. Recommendation%3A Pair this source with any nearby network, logging, serialization, or process execution sink before approving.
}


Expand Down
14 changes: 13 additions & 1 deletion application/single_app/functions_citation_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from typing import Any, Dict, Iterable, List, Mapping, Optional
from urllib.parse import urlsplit, urlunsplit

from functions_m365_citations import rebuild_conversation_used_m365_items

Check warning on line 10 in application/single_app/functions_citation_tracking.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.


CITATION_TRACKING_VERSION = 1
USED_DOCUMENTS_TRACKING_VERSION = 1
Expand Down Expand Up @@ -669,9 +671,10 @@
) -> List[Dict[str, Any]]:
"""Rebuild exact usage after a retry, switch, deletion, or fork mutation."""
initialize_conversation_used_document_tracking(conversation)
messages = list(messages or [])
cited_hybrid_citations: List[Dict[str, Any]] = []
legacy_hybrid_citations: List[Dict[str, Any]] = []
for message in messages or []:
for message in messages:
if not isinstance(message, Mapping) or not _message_is_active_assistant(message):
continue
if _message_has_citation_tracking(message):
Expand All @@ -693,4 +696,13 @@
legacy_hybrid_citations,
source_document_tags=source_document_tags,
)
if conversation.get("conversation_kind") != "collaborative":

Check warning on line 699 in application/single_app/functions_citation_tracking.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.
# Microsoft 365 items are listed to their owner only, so a shared thread keeps none.
rebuild_conversation_used_m365_items(

Check warning on line 701 in application/single_app/functions_citation_tracking.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.
conversation,

Check warning on line 702 in application/single_app/functions_citation_tracking.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.
[
message for message in messages
if isinstance(message, Mapping) and _message_is_active_assistant(message)
],
)
return deepcopy(conversation["used_documents"])
5 changes: 5 additions & 0 deletions application/single_app/functions_collaboration.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@
'citation_tracking_version',
'cited_hybrid_citations',
'cited_web_search_citations',
'm365_citations',

Check warning on line 459 in application/single_app/functions_collaboration.py

View workflow job for this annotation

GitHub Actions / malicious-pr-security-review

Important - Changed line contains AI, plugin, agent, or workspace boundary marker. Recommendation%3A Check whether prompts, chat history, uploaded documents, embeddings, citations, settings, or identity can cross a new boundary.
):
if field_name in message_doc:
payload[field_name] = deepcopy(message_doc.get(field_name))
Expand Down Expand Up @@ -564,13 +565,16 @@
hybrid_citations = list(message_doc.get('hybrid_citations', []) or (source_message_doc or {}).get('hybrid_citations', []) or [])
web_search_citations = list(message_doc.get('web_search_citations', []) or (source_message_doc or {}).get('web_search_citations', []) or [])
agent_citations = list(message_doc.get('agent_citations', []) or (source_message_doc or {}).get('agent_citations', []) or [])
m365_citations = list(message_doc.get('m365_citations', []) or (source_message_doc or {}).get('m365_citations', []) or [])

if hybrid_citations:
generation_details['document_citation_count'] = len(hybrid_citations)
if web_search_citations:
generation_details['web_citation_count'] = len(web_search_citations)
if agent_citations:
generation_details['agent_citation_count'] = len(agent_citations)
if m365_citations:
generation_details['m365_citation_count'] = len(m365_citations)

return generation_details

Expand Down Expand Up @@ -815,6 +819,7 @@
'citation_tracking_version',
'cited_hybrid_citations',
'cited_web_search_citations',
'm365_citations',
):
if field_name in message_doc:
payload[field_name] = deepcopy(message_doc.get(field_name))
Expand Down
Loading
Loading