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
3 changes: 1 addition & 2 deletions application/single_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
EXECUTOR_TYPE = 'thread'
EXECUTOR_MAX_WORKERS = 30
SESSION_TYPE = 'filesystem'
VERSION = "0.240.066"
VERSION = "0.240.085"

SECRET_KEY = os.getenv('SECRET_KEY', 'dev-secret-key-change-in-production')

Expand Down Expand Up @@ -150,7 +150,6 @@ def get_allowed_extensions(enable_video=False, enable_audio=False):

Args:
enable_video: Whether video file support is enabled

Returns:
set: Allowed file extensions
"""
Expand Down
40 changes: 40 additions & 0 deletions application/single_app/functions_agent_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,46 @@ def is_new_foundry_agent(agent: Dict[str, Any]) -> bool:
return False


def get_agent_model_binding(agent: Dict[str, Any]) -> Dict[str, str]:
"""Return normalized saved model binding fields for an agent."""
if not isinstance(agent, dict):
return {
"endpoint_id": "",
"model_id": "",
"provider": "",
}

return {
"endpoint_id": str(agent.get("model_endpoint_id") or "").strip(),
"model_id": str(agent.get("model_id") or "").strip(),
"provider": str(agent.get("model_provider") or "").strip().lower(),
}


def has_complete_agent_model_binding(agent: Dict[str, Any]) -> bool:
"""Return True when the agent stores both endpoint and model identifiers."""
binding = get_agent_model_binding(agent)
return bool(binding["endpoint_id"] and binding["model_id"])


def has_agent_custom_connection_override(agent: Dict[str, Any]) -> bool:
"""Return True when a local agent stores explicit legacy connection values."""
if not isinstance(agent, dict):
return False

has_direct_fields = any(str(agent.get(field) or "").strip() for field in _GPT_FIELDS)
apim_enabled = agent.get("enable_agent_gpt_apim") in [True, 1, "true", "True"]
has_apim_fields = apim_enabled and any(
str(agent.get(field) or "").strip() for field in _APIM_FIELDS
)
return bool(has_direct_fields or has_apim_fields)


def can_agent_use_default_multi_endpoint_model(agent: Dict[str, Any]) -> bool:
"""Return True when a local agent should inherit the saved admin default model."""
return not is_azure_ai_foundry_agent(agent) and not has_agent_custom_connection_override(agent)


def _normalize_text_fields(payload: Dict[str, Any]) -> None:
for field in _TEXT_FIELDS:
value = payload.get(field)
Expand Down
5 changes: 3 additions & 2 deletions application/single_app/functions_personal_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get_personal_agent(user_id, agent_id):
debug_print(f"Error fetching agent {agent_id} for user {user_id}: {e}")
return None

def save_personal_agent(user_id, agent_data):
def save_personal_agent(user_id, agent_data, actor_user_id=None):
"""
Save or update a personal agent.

Expand All @@ -118,6 +118,7 @@ def save_personal_agent(user_id, agent_data):
dict: Saved agent data with ID
"""
try:
modifying_user_id = actor_user_id or user_id
cleaned_agent = sanitize_agent_payload(agent_data)
for field in ['name', 'display_name', 'description', 'instructions']:
cleaned_agent.setdefault(field, '')
Expand Down Expand Up @@ -159,7 +160,7 @@ def save_personal_agent(user_id, agent_data):
# New agent
cleaned_agent['created_by'] = user_id
cleaned_agent['created_at'] = now
cleaned_agent['modified_by'] = user_id
cleaned_agent['modified_by'] = modifying_user_id
cleaned_agent['modified_at'] = now

cleaned_agent['user_id'] = user_id
Expand Down
15 changes: 11 additions & 4 deletions application/single_app/functions_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ def get_settings(use_cosmos=False, include_source=False):
'multi_endpoint_migrated_at': None,
'multi_endpoint_migration_notice': {
'enabled': False,
'message': (
'Multi-endpoint has been enabled and your existing AI endpoint was migrated. '
'Agents using the default connection may need to be updated to select a new model endpoint.'
),
'message': '',
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the default settings dict, the multi_endpoint_migration_notice block has inconsistent indentation for the message key, which looks like an accidental mis-indent and makes the defaults harder to read/maintain. Align message with the other keys in that dict.

Suggested change
'message': '',
'message': '',

Copilot uses AI. Check for mistakes.
'created_at': None
},
'azure_apim_gpt_endpoint': '',
Expand Down Expand Up @@ -1041,6 +1038,9 @@ def get_user_settings(user_id):

if 'personal_model_endpoints' not in doc['settings']:
doc['settings']['personal_model_endpoints'] = []
if 'showTutorialButtons' not in doc['settings']:
doc['settings']['showTutorialButtons'] = True
updated = True

# Try to update email/display_name if missing and available in session
user = session.get("user", {})
Expand Down Expand Up @@ -1082,6 +1082,7 @@ def get_user_settings(user_id):
display_name = user.get("name")
doc = {"id": user_id, "settings": {}}
doc["settings"]["personal_model_endpoints"] = []
doc["settings"]["showTutorialButtons"] = True
if email:
doc["email"] = email
if display_name:
Expand Down Expand Up @@ -1343,6 +1344,12 @@ def sanitize_settings_for_user(full_settings: dict) -> dict:
str(full_settings.get('support_feedback_recipient_email') or '').strip()
)

if isinstance(sanitized.get('multi_endpoint_migration_notice'), dict):
sanitized['multi_endpoint_migration_notice'] = {
**sanitized['multi_endpoint_migration_notice'],
'enabled': False,
}

return sanitized

def sanitize_settings_for_logging(full_settings: dict) -> dict:
Expand Down
Loading
Loading