Skip to content
Merged
2 changes: 1 addition & 1 deletion infra/scripts/agent_scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
aiohttp==3.14.0
aiohttp==3.14.1
azure-identity==1.25.2
azure-ai-projects==2.1.0
1 change: 0 additions & 1 deletion infra/scripts/index_scripts/03_cu_process_data_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from azure.identity.aio import AzureCliCredential as AsyncAzureCliCredential
from azure.identity import AzureCliCredential, get_bearer_token_provider
from azure.search.documents import SearchClient
from azure.search.documents.indexes import SearchIndexClient
from azure.storage.filedatalake import DataLakeServiceClient

from agent_framework_foundry import FoundryAgent
Expand Down
2 changes: 1 addition & 1 deletion infra/scripts/index_scripts/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ azure-ai-projects==2.1.0
azure-ai-inference==1.0.0b9
agent-framework-core==1.3.0
agent-framework-foundry==1.3.0
pypdf==6.12.0
pypdf==6.13.3
tiktoken==0.12.0
azure-identity==1.25.2
azure-ai-textanalytics==5.3.0
Expand Down
243 changes: 118 additions & 125 deletions src/App/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/api/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pydantic[email]==2.13.2
azure-core==1.39.0
requests==2.33.1
types-requests==2.33.0.20260408
aiohttp==3.14.0
aiohttp==3.14.1

# Azure Services
azure-identity==1.25.3
Expand Down
17 changes: 9 additions & 8 deletions src/api/services/_patches/agent_framework_search_citations.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

logger = logging.getLogger(__name__)

_PATCH_APPLIED = False # prevents reapplying patch in apply() guard
_PATCH_MARKER = "_kmsa_search_citations_patched"
_CACHE_ATTR = "_kmsa_search_get_urls_cache"
_TARGET_METHOD = "_parse_chunk_from_openai"
_TARGET_CLASS = "RawOpenAIChatClient"
Expand All @@ -49,10 +49,6 @@ def apply() -> None:
Logs a warning (does not raise) if upstream has renamed the target,
so app startup still succeeds with degraded citations.
"""
global _PATCH_APPLIED
if _PATCH_APPLIED:
return

try:
from agent_framework_openai import _chat_client as _cc
except ImportError:
Expand All @@ -72,6 +68,11 @@ def apply() -> None:
)
return

# Idempotency guard: the marker travels with the patched class, so a
# second call (or a re-import) is a no-op even across module reloads.
if getattr(target_cls, _PATCH_MARKER, False):
return

_original = getattr(target_cls, _TARGET_METHOD)

def _patched(self: Any, event: Any, *args: Any, **kwargs: Any) -> Any:
Expand Down Expand Up @@ -162,14 +163,14 @@ def _patched(self: Any, event: Any, *args: Any, **kwargs: Any) -> Any:
return result

setattr(target_cls, _TARGET_METHOD, _patched)
_PATCH_APPLIED = True # marks patch as applied (checked in apply() guard)
setattr(target_cls, _PATCH_MARKER, True) # marks patch as applied (checked in apply() guard)
logger.info(
Comment thread
VishalSh-Microsoft marked this conversation as resolved.
"Applied Azure AI Search citation patch on %s.%s (workaround for %s)",
_TARGET_CLASS, _TARGET_METHOD, _UPSTREAM_ISSUE,
)


# Apply on import so a single
# `import services._patches.agent_framework_search_citations`
# from chat_service.py is enough.
# `import services._patches.agent_framework_search_citations` (or the
# equivalent importlib.import_module call) from chat_service.py is enough.
apply()
10 changes: 6 additions & 4 deletions src/api/services/chat_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import asyncio
import importlib
import json
import logging
import os
Expand All @@ -24,15 +25,16 @@

from agent_framework import AgentSession
from agent_framework_foundry import FoundryAgent
# Restore Azure AI Search per-document URL enrichment on streaming citations
# (regression at agent-framework GA; tracked upstream as microsoft/agent-framework#5995).
# Must be imported BEFORE the first FoundryAgent.run() call.
import services._patches.agent_framework_search_citations # noqa: F401 - patch applied for side effects on import

from cachetools import TTLCache

from common.config.config import Config

# Restore Azure AI Search per-document URL enrichment on streaming citations
# (regression at agent-framework GA; tracked upstream as microsoft/agent-framework#5995).
# Imported for its import-time side effects; must run BEFORE the first FoundryAgent.run() call.
importlib.import_module("services._patches.agent_framework_search_citations")

# Constants
HOST_NAME = "CKM"
HOST_INSTRUCTIONS = "Answer questions about call center operations"
Expand Down
Loading