This commit is contained in:
mika-lt 2026-10-31 10:21:12 +00:00 • committed by GitHub
commit 6db09b29e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 1411 additions and 224 deletions

View file

@ -4120,6 +4120,21 @@
},
"title": "Agent Ids",
"type": "array"
},
"previous_agent_ids": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"description": "The public agent list the caller started from. When set, only the agents added or removed relative to it change, so agents another admin published or unpublished meanwhile keep that change. When omitted, agent_ids replaces the stored list.",
"title": "Previous Agent Ids"
}
},
"required": [
@ -43529,6 +43544,21 @@
},
"title": "Mcp Server Ids",
"type": "array"
},
"previous_mcp_server_ids": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"description": "The public MCP server list the caller started from. When set, only the servers added or removed relative to it change, so servers another admin published or unpublished meanwhile keep that change. When omitted, mcp_server_ids replaces the stored list.",
"title": "Previous Mcp Server Ids"
}
},
"required": [

View file

@ -1579,7 +1579,17 @@ from litellm.models.mcp_server import ( # noqa: E402
class MakeMCPServersPublicRequest(LiteLLMPydanticObjectBase):
model_config = ConfigDict(frozen=True)
mcp_server_ids: list[str]
previous_mcp_server_ids: tuple[str, ...] | None = Field(
default=None,
description=(
"The public MCP server list the caller started from. When set, only the servers added or removed "
"relative to it change, so servers another admin published or unpublished meanwhile keep that change. "
"When omitted, mcp_server_ids replaces the stored list."
),
)
class MCPUserCredentialRequest(LiteLLMPydanticObjectBase):

View file

@ -456,8 +456,9 @@ class AgentRegistry:
return hashlib.sha256(json.dumps(agent_config, sort_keys=True).encode()).hexdigest()
def ids_for_agent(self, agent_id: str) -> frozenset[str]:
stable_id: Final = self.stable_agent_id(agent_id)
return frozenset(
{agent_id, *(legacy for legacy, stable in self.config_agent_legacy_ids.items() if stable == agent_id)}
{stable_id, *(legacy for legacy, stable in self.config_agent_legacy_ids.items() if stable == stable_id)}
)
def stable_agent_id(self, agent_id: str) -> str:

View file

@ -1022,7 +1022,7 @@ async def delete_agent(
"""
await check_feature_access_for_user(user_api_key_dict, "agents")
from litellm.proxy.proxy_server import prisma_client
from litellm.proxy.proxy_server import prisma_client, proxy_config
_check_agent_management_permission(user_api_key_dict)
@ -1040,6 +1040,13 @@ async def delete_agent(
if existing_agent is None:
raise HTTPException(status_code=404, detail=f"Agent with ID {agent_id} not found in DB.")
await proxy_config.remove_from_list_setting(
section_name="litellm_settings",
key="public_agent_groups",
item=agent_id,
on_written=_set_public_agent_groups,
aliases=AGENT_REGISTRY.ids_for_agent,
)
await AGENT_REGISTRY.delete_agent_from_db(agent_id=agent_id, prisma_client=prisma_client)
AGENT_REGISTRY.deregister_agent(agent_name=existing_agent.get("agent_name"))
@ -1120,6 +1127,10 @@ async def _resolve_agent_kill_switch(agent_id: str) -> tuple[str, AgentKillSwitc
return agent.agent_id, agent.kill_switch
def _set_public_agent_groups(public_agent_groups: tuple[str, ...]) -> None:
litellm.public_agent_groups = list(public_agent_groups)
@router.post(
"/v1/agents/{agent_id}/make_public",
tags=["[beta] A2A Agents"],
@ -1163,7 +1174,6 @@ async def make_agent_public(
try:
# Update the public model groups
import litellm
from litellm.proxy.agent_endpoints.agent_registry import (
global_agent_registry as AGENT_REGISTRY,
)
@ -1188,24 +1198,19 @@ async def make_agent_public(
if agent is None:
raise HTTPException(status_code=404, detail=f"Agent with ID {agent_id} not found")
config: Final = await proxy_config.get_config()
current_public_agent_groups: Final = list(litellm.public_agent_groups or [])
if not AGENT_REGISTRY.ids_for_agent(agent.agent_id).isdisjoint(current_public_agent_groups):
stored_public_agent_groups: Final = await proxy_config.append_to_list_setting(
section_name="litellm_settings",
key="public_agent_groups",
item=agent.agent_id,
listed_as=AGENT_REGISTRY.ids_for_agent(agent.agent_id),
on_written=_set_public_agent_groups,
)
if stored_public_agent_groups is None:
raise HTTPException(
status_code=400,
detail=f"Agent with name {agent.agent_name} already in public agent groups",
)
updated_public_agent_groups: Final = [*current_public_agent_groups, agent.agent_id]
if "litellm_settings" not in config or config["litellm_settings"] is None:
config["litellm_settings"] = {}
config["litellm_settings"]["public_agent_groups"] = updated_public_agent_groups
await proxy_config.save_config(new_config=config)
litellm.public_agent_groups = updated_public_agent_groups
updated_public_agent_groups: Final = list(stored_public_agent_groups)
verbose_proxy_logger.debug(
"Updated public agent groups to: %s by user: %s", updated_public_agent_groups, user_api_key_dict.user_id
@ -1275,8 +1280,6 @@ async def make_agents_public(
)
from litellm.proxy.proxy_server import proxy_config
# Load existing config
config: Final = await proxy_config.get_config()
# Check if user has admin permissions
if user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN:
raise HTTPException(
@ -1286,9 +1289,6 @@ async def make_agents_public(
},
)
if litellm.public_agent_groups is None:
litellm.public_agent_groups = []
for agent_id in request.agent_ids:
agent = AGENT_REGISTRY.get_agent_by_id(agent_id=agent_id)
if agent is None:
@ -1300,6 +1300,23 @@ async def make_agents_public(
if agent is None:
raise HTTPException(status_code=404, detail=f"Agent with ID {agent_id} not found")
if request.previous_agent_ids is not None:
stored_public_agent_groups: Final = await proxy_config.apply_list_setting_delta(
section_name="litellm_settings",
key="public_agent_groups",
requested=request.agent_ids,
previous=request.previous_agent_ids,
on_written=_set_public_agent_groups,
aliases=AGENT_REGISTRY.ids_for_agent,
)
return {
"message": "Successfully updated public agent groups",
"public_agent_groups": list(stored_public_agent_groups),
"updated_by": user_api_key_dict.user_id,
}
# Load existing config
config: Final = await proxy_config.get_config()
litellm.public_agent_groups = request.agent_ids
# Update config with new settings

View file

@ -129,6 +129,10 @@ def does_mcp_server_exist(mcp_server_records: Iterable[_HasServerId], mcp_server
return False
def _set_public_mcp_servers(public_mcp_servers: tuple[str, ...]) -> None:
litellm.public_mcp_servers = list(public_mcp_servers)
DEFAULT_MCP_REGISTRY_VERSION: Final = "1.0.0"
if TYPE_CHECKING:
@ -2624,6 +2628,14 @@ if MCP_AVAILABLE:
},
)
from litellm.proxy.proxy_server import proxy_config
await proxy_config.remove_from_list_setting(
section_name="litellm_settings",
key="public_mcp_servers",
item=server_id,
on_written=_set_public_mcp_servers,
)
# try to delete the mcp server
mcp_server_record_deleted: Final = await delete_mcp_server(prisma_client, server_id)
@ -3374,8 +3386,6 @@ if MCP_AVAILABLE:
)
from litellm.proxy.proxy_server import proxy_config
# Load existing config
config: Final = await proxy_config.get_config()
# Check if user has admin permissions
if user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN:
raise HTTPException(
@ -3393,6 +3403,22 @@ if MCP_AVAILABLE:
detail=f"MCP Server with ID {server_id} not found",
)
if request.previous_mcp_server_ids is not None:
stored_public_mcp_servers: Final = await proxy_config.apply_list_setting_delta(
section_name="litellm_settings",
key="public_mcp_servers",
requested=request.mcp_server_ids,
previous=request.previous_mcp_server_ids,
on_written=_set_public_mcp_servers,
)
return {
"message": "Successfully updated public mcp servers",
"public_mcp_servers": list(stored_public_mcp_servers),
"updated_by": user_api_key_dict.user_id,
}
# Load existing config
config: Final = await proxy_config.get_config()
# Update config with new settings
if "litellm_settings" not in config or config["litellm_settings"] is None:
config["litellm_settings"] = {}

View file

@ -24,7 +24,7 @@ from types import MappingProxyType
from typing import TYPE_CHECKING, Annotated, Final, Literal, Protocol, TypeAlias, TypeVar, cast, runtime_checkable
from fastapi import APIRouter, Depends, Header, HTTPException, Request, status
from pydantic import BaseModel, ConfigDict, Field, TypeAdapter, ValidationError, field_validator
from pydantic import BaseModel, ConfigDict, Field, JsonValue, TypeAdapter, ValidationError, field_validator
import litellm
from litellm._logging import verbose_proxy_logger
@ -223,8 +223,16 @@ class UpdatePublicModelGroupsRequest(LiteLLMBaseModel):
"""Request model for updating public model groups"""
model_groups: list[str] = Field(description="List of model group names to make public")
previous_model_groups: tuple[str, ...] | None = Field(
default=None,
description=(
"The public model group list the caller started from. When set, only the model groups added or removed "
"relative to it change, so model groups another admin published or unpublished meanwhile keep that "
"change. When omitted, model_groups replaces the stored list."
),
)
model_config = ConfigDict(extra="forbid")
model_config = ConfigDict(extra="forbid", frozen=True)
class _ProxyModelRow(Protocol):
@ -3484,6 +3492,10 @@ async def update_model(
raise proxy_exception_for(e, default_status_code=status.HTTP_400_BAD_REQUEST) from e
def _set_public_model_groups(public_model_groups: tuple[str, ...]) -> None:
litellm.public_model_groups = list(public_model_groups)
@router.post(
"/model_group/make_public",
description="Update which model groups are public",
@ -3530,6 +3542,20 @@ async def update_public_model_groups(
detail={"error": "Set `'STORE_MODEL_IN_DB='True'` in your env to enable this feature."},
)
if request.previous_model_groups is not None:
stored_public_model_groups: Final = await proxy_config.apply_list_setting_delta(
section_name="litellm_settings",
key="public_model_groups",
requested=request.model_groups,
previous=request.previous_model_groups,
on_written=_set_public_model_groups,
)
return {
"message": "Successfully updated public model groups",
"public_model_groups": list(stored_public_model_groups),
"updated_by": user_api_key_dict.user_id,
}
# Load existing config first (this may overwrite in-memory litellm settings
# from DB values via _update_config_from_db), so set the in-memory value AFTER
config: Final = await proxy_config.get_config()
@ -3571,6 +3597,14 @@ async def update_public_model_groups(
)
_USEFUL_LINKS: Final = TypeAdapter(Mapping[str, JsonValue])
_PUBLIC_MODEL_GROUPS_LINKS: Final = TypeAdapter(dict[str, str | dict[str, object]])
def _set_public_model_groups_links(public_model_groups_links: Mapping[str, JsonValue]) -> None:
litellm.public_model_groups_links = _PUBLIC_MODEL_GROUPS_LINKS.validate_python(public_model_groups_links)
@router.post(
"/model_hub/update_useful_links",
description="Update useful links",
@ -3597,6 +3631,20 @@ async def update_useful_links(
},
)
if request.previous_useful_links is not None:
stored_useful_links: Final = await proxy_config.apply_mapping_setting_delta(
section_name="litellm_settings",
key="public_model_groups_links",
requested=_USEFUL_LINKS.validate_python(request.useful_links),
previous=_USEFUL_LINKS.validate_python(request.previous_useful_links),
on_written=_set_public_model_groups_links,
)
return {
"message": "Successfully updated useful links",
"useful_links": dict(stored_useful_links),
"updated_by": user_api_key_dict.user_id,
}
# Load existing config first (this may overwrite in-memory litellm settings
# from DB values via _update_config_from_db), so set the in-memory value AFTER
config: Final = await proxy_config.get_config()

View file

@ -307,7 +307,7 @@ def generate_feedback_box():
import contextlib
from collections import defaultdict
from contextlib import AsyncExitStack, asynccontextmanager
from functools import lru_cache, partial
from functools import lru_cache, partial, reduce
import litellm
import litellm._redis
@ -5486,6 +5486,90 @@ _CONFIG_PERSISTED_SECTIONS: Final = ("general_settings", "router_settings", "lit
_CONFIG_UNMANAGED_EXCLUSIONS: Final = frozenset(("environment_variables", "model_list"))
_CONFIG_SECTION_VALUES: Final = TypeAdapter(Mapping[str, JsonValue])
_CONFIG_SECTION_LOCK_SQL: Final = "SELECT 1 AS locked FROM pg_advisory_xact_lock(hashtext($1))"
_STRING_LIST: Final = TypeAdapter(list[str])
_CONFIG_MAPPING: Final = TypeAdapter(Mapping[str, object])
def _listed_items(section: Mapping[str, JsonValue], key: str) -> tuple[str, ...]:
return tuple(_STRING_LIST.validate_python(section.get(key) or []))
def _with_list_item(
section: Mapping[str, JsonValue], *, key: str, item: str, listed_as: frozenset[str]
) -> Mapping[str, JsonValue]:
current: Final = _listed_items(section, key)
if not listed_as.isdisjoint(current):
return section
return MappingProxyType({**section, key: [*current, item]})
def _listed_only_as_itself(item: str) -> frozenset[str]:
return frozenset((item,))
def _with_list_delta(
section: Mapping[str, JsonValue],
*,
key: str,
requested: tuple[str, ...],
previous: frozenset[str],
aliases: Callable[[str], frozenset[str]],
) -> Mapping[str, JsonValue]:
current: Final = _listed_items(section, key)
requested_ids: Final = frozenset(chain.from_iterable(aliases(item) for item in requested))
previous_ids: Final = frozenset(chain.from_iterable(aliases(item) for item in previous))
removed: Final = previous_ids.difference(requested_ids)
kept: Final = tuple(item for item in current if item not in removed)
added: Final = tuple(
item
for item in _first_of_each_alias_set(requested, aliases)
if aliases(item).isdisjoint(previous_ids) and aliases(item).isdisjoint(kept)
)
if (*kept, *added) == current:
return section
return MappingProxyType({**section, key: [*kept, *added]})
def _first_of_each_alias_set(items: tuple[str, ...], aliases: Callable[[str], frozenset[str]]) -> tuple[str, ...]:
return tuple(
item
for index, item in enumerate(items)
if all(aliases(item).isdisjoint(aliases(earlier)) for earlier in items[:index])
)
def _with_mapping_delta(
section: Mapping[str, JsonValue],
*,
key: str,
requested: Mapping[str, JsonValue],
previous: Mapping[str, JsonValue],
) -> Mapping[str, JsonValue]:
current: Final = _CONFIG_SECTION_VALUES.validate_python(section.get(key) or {})
changed: Final = {
name: value for name, value in requested.items() if name not in previous or previous[name] != value
}
removed: Final = frozenset(previous).difference(requested)
kept: Final = {name: value for name, value in current.items() if name not in removed and name not in changed}
merged: Final = {**kept, **changed}
if merged == dict(current):
return section
return MappingProxyType({**section, key: merged})
def _settings_db_client() -> PrismaClient | None:
stores_settings_in_db: Final = general_settings_view().get("store_model_in_db", False) is True or store_model_in_db
return prisma_client if stores_settings_in_db else None
@dataclass(frozen=True, slots=True)
class _SectionRewrite:
before: Mapping[str, JsonValue]
after: Mapping[str, JsonValue]
@property
def changed(self) -> bool:
return self.after != self.before
class _ConfigParamWhere(TypedDict):
@ -5506,6 +5590,37 @@ class _ConfigParamUpsert(TypedDict):
update: ReadOnly[_ConfigParamUpdate]
async def _rewrite_config_section(
prisma_client: PrismaClient,
*,
section_name: str,
rewrite: Callable[[Mapping[str, JsonValue]], Mapping[str, JsonValue]],
) -> _SectionRewrite:
async with prisma_client.tx() as tx:
await tx.query_raw(_CONFIG_SECTION_LOCK_SQL, section_name)
config_table: Final = cast("TableActions[_ConfigParamRow]", tx.litellm_config)
config_where: Final[_ConfigParamWhere] = {"param_name": section_name}
existing_row: Final[_ConfigParamRow | None] = await config_table.find_first(where=config_where)
existing_value: Final[object] = cast(object, existing_row.param_value) if existing_row is not None else None
existing_section: Final[Mapping[str, JsonValue]] = (
_CONFIG_SECTION_VALUES.validate_json(existing_value)
if isinstance(existing_value, str)
else _CONFIG_SECTION_VALUES.validate_python(existing_value)
if isinstance(existing_value, Mapping)
else MappingProxyType({})
)
section_rewrite: Final = _SectionRewrite(before=existing_section, after=rewrite(existing_section))
if not section_rewrite.changed:
return section_rewrite
serialized_section: Final = json.dumps(dict(section_rewrite.after))
config_data: Final[_ConfigParamUpsert] = {
"create": {"param_name": section_name, "param_value": serialized_section},
"update": {"param_value": serialized_section},
}
await config_table.upsert(where=config_where, data=config_data)
return section_rewrite
class _EnvironmentVariablesConfigData(TypedDict):
environment_variables: ReadOnly[object]
@ -6018,20 +6133,10 @@ class ProxyConfig:
removed_keys: frozenset[str],
prisma_client: PrismaClient,
) -> Mapping[str, JsonValue] | None:
async with prisma_client.tx() as tx:
await tx.query_raw(_CONFIG_SECTION_LOCK_SQL, section_name)
config_table: Final = cast("TableActions[_ConfigParamRow]", tx.litellm_config)
config_where: Final[_ConfigParamWhere] = {"param_name": section_name}
existing_row: Final[_ConfigParamRow | None] = await config_table.find_first(where=config_where)
existing_value: Final[object] = cast(object, existing_row.param_value) if existing_row is not None else None
existing_section: Final[Mapping[str, JsonValue]] = (
_CONFIG_SECTION_VALUES.validate_json(existing_value)
if isinstance(existing_value, str)
else _CONFIG_SECTION_VALUES.validate_python(existing_value)
if isinstance(existing_value, Mapping)
else MappingProxyType({})
)
merged_section: Final[Mapping[str, JsonValue]] = MappingProxyType(
section_rewrite: Final = await _rewrite_config_section(
prisma_client,
section_name=section_name,
rewrite=lambda existing_section: MappingProxyType(
{
key: value
for key, value in chain(
@ -6039,16 +6144,114 @@ class ProxyConfig:
changed_keys.items(),
)
}
)
if merged_section == existing_section:
return None
serialized_section: Final = json.dumps(dict(merged_section))
config_data: Final[_ConfigParamUpsert] = {
"create": {"param_name": section_name, "param_value": serialized_section},
"update": {"param_value": serialized_section},
}
await config_table.upsert(where=config_where, data=config_data)
return merged_section
),
)
return section_rewrite.after if section_rewrite.changed else None
async def append_to_list_setting(
self,
*,
section_name: Section,
key: str,
item: str,
listed_as: frozenset[str],
on_written: Callable[[tuple[str, ...]], None],
) -> tuple[str, ...] | None:
section_rewrite: Final = await self._rewrite_setting(
section_name=section_name,
key=key,
rewrite=lambda section: _with_list_item(section, key=key, item=item, listed_as=listed_as),
on_written=lambda section: on_written(_listed_items(section, key)),
)
return _listed_items(section_rewrite.after, key) if section_rewrite.changed else None
async def apply_list_setting_delta(
self,
*,
section_name: Section,
key: str,
requested: Sequence[str],
previous: Sequence[str],
on_written: Callable[[tuple[str, ...]], None],
aliases: Callable[[str], frozenset[str]] = _listed_only_as_itself,
) -> tuple[str, ...]:
section_rewrite: Final = await self._rewrite_setting(
section_name=section_name,
key=key,
rewrite=lambda section: _with_list_delta(
section, key=key, requested=tuple(requested), previous=frozenset(previous), aliases=aliases
),
on_written=lambda section: on_written(_listed_items(section, key)),
)
return _listed_items(section_rewrite.after, key)
async def remove_from_list_setting(
self,
*,
section_name: Section,
key: str,
item: str,
on_written: Callable[[tuple[str, ...]], None],
aliases: Callable[[str], frozenset[str]] = _listed_only_as_itself,
) -> None:
if _settings_db_client() is not None and self._settings_stores[section_name].owned_by_config(key):
return
await self.apply_list_setting_delta(
section_name=section_name, key=key, requested=(), previous=(item,), on_written=on_written, aliases=aliases
)
async def apply_mapping_setting_delta(
self,
*,
section_name: Section,
key: str,
requested: Mapping[str, JsonValue],
previous: Mapping[str, JsonValue],
on_written: Callable[[Mapping[str, JsonValue]], None],
) -> Mapping[str, JsonValue]:
section_rewrite: Final = await self._rewrite_setting(
section_name=section_name,
key=key,
rewrite=lambda section: _with_mapping_delta(section, key=key, requested=requested, previous=previous),
on_written=lambda section: on_written(_CONFIG_SECTION_VALUES.validate_python(section.get(key) or {})),
)
return _CONFIG_SECTION_VALUES.validate_python(section_rewrite.after.get(key) or {})
async def _rewrite_setting(
self,
*,
section_name: Section,
key: str,
rewrite: Callable[[Mapping[str, JsonValue]], Mapping[str, JsonValue]],
on_written: Callable[[Mapping[str, JsonValue]], None],
) -> _SectionRewrite:
db_client: Final = _settings_db_client()
if db_client is None:
file_rewrite: Final = await self._rewrite_file_section(section_name=section_name, rewrite=rewrite)
on_written(file_rewrite.after)
return file_rewrite
store: Final = self._settings_stores[section_name]
if store.owned_by_config(key):
config_section: Final[Mapping[str, JsonValue]] = MappingProxyType({key: store.get(key)})
if rewrite(config_section) != config_section:
self._raise_config_owned(section_name=section_name, rejected=(key,), store=store)
return _SectionRewrite(before=config_section, after=config_section)
section_rewrite: Final = await _rewrite_config_section(db_client, section_name=section_name, rewrite=rewrite)
store.apply_db_row(section_name, section_rewrite.after)
on_written(section_rewrite.after)
if section_rewrite.changed:
await invalidate_config_param(section_name)
return section_rewrite
async def _rewrite_file_section(
self, *, section_name: Section, rewrite: Callable[[Mapping[str, JsonValue]], Mapping[str, JsonValue]]
) -> _SectionRewrite:
config: Final = _CONFIG_MAPPING.validate_python(await self.get_config())
section: Final = _CONFIG_SECTION_VALUES.validate_python(config.get(section_name) or {})
section_rewrite: Final = _SectionRewrite(before=section, after=rewrite(section))
if section_rewrite.changed:
await self.save_config(new_config={**config, section_name: dict(section_rewrite.after)})
return section_rewrite
async def save_environment_variables(self, updates: dict[str, str | None]) -> None:
"""Persist specific environment variables to the DB config row.
@ -19720,6 +19923,58 @@ async def invitation_delete(
#### CONFIG MANAGEMENT ####
def _with_slack_alerting(section: Mapping[str, JsonValue]) -> Mapping[str, JsonValue]:
if "alerting" not in section:
return {"alerting": ["slack"]}
alerting: Final = section["alerting"]
if isinstance(alerting, list) and "slack" not in alerting:
return {"alerting": [*alerting, "slack"]}
return {}
def _with_general_setting(section: Mapping[str, JsonValue], setting: tuple[str, JsonValue]) -> Mapping[str, JsonValue]:
key, value = setting
return MappingProxyType(
{**section, **(_with_slack_alerting(section) if key == "alert_to_webhook_url" else {}), key: value}
)
def _merged_litellm_settings(
existing: Mapping[str, JsonValue], updates: Mapping[str, JsonValue]
) -> Mapping[str, JsonValue]:
incoming_callbacks: Final = updates.get("success_callback")
existing_callbacks: Final = existing.get("success_callback")
merged: Final = {**existing, **updates}
if not isinstance(incoming_callbacks, list):
return MappingProxyType(merged)
return _CONFIG_SECTION_VALUES.validate_python(
{
**merged,
"success_callback": list(
set(normalize_callback_names(existing_callbacks) + incoming_callbacks)
if isinstance(existing_callbacks, list)
else set(incoming_callbacks)
),
}
)
async def _update_config_section(
prisma_client: PrismaClient,
*,
section_name: str,
merge: Callable[[Mapping[str, JsonValue]], Mapping[str, JsonValue]],
user_api_key_dict: UserAPIKeyAuth,
) -> None:
section_rewrite: Final = await _rewrite_config_section(prisma_client, section_name=section_name, rewrite=merge)
await invalidate_config_param(section_name)
asyncio.create_task(
create_config_audit_log(
section_name, "updated", dict(section_rewrite.before), dict(section_rewrite.after), user_api_key_dict
)
)
@router.post(
"/config/update",
tags=["config.yaml"],
@ -19815,106 +20070,39 @@ async def update_config(
proxy_config.reject_config_owned_writes(section_name="litellm_settings", changed_keys=raw_litellm_settings)
proxy_config.reject_config_owned_writes(section_name="router_settings", changed_keys=router_settings_updates)
async def _read_section(param_name: str) -> dict:
row: Final[_ConfigParamRow | None] = await _config_param_table(prisma_client, use_writer=True).find_first(
where={"param_name": param_name}
)
if row is None or row.param_value is None:
return {}
return dict(row.param_value)
async def _upsert_section(param_name: str, value: dict) -> None:
serialized: Final = json.dumps(value)
await ConfigRepository(prisma_client).table.upsert(
where={"param_name": param_name},
data={
"create": {"param_name": param_name, "param_value": serialized},
"update": {"param_value": serialized},
},
)
# invalidate the DualCache entry so the next reader (this process
# or any other proxy in the cluster) goes to DB.
await invalidate_config_param(param_name)
# general_settings: merge per-key, with the alert_to_webhook_url side
# effect of auto-enabling slack alerting.
if config_info.general_settings is not None:
existing = await _read_section("general_settings")
before_general_settings: Final = copy.deepcopy(existing)
for k, v in requested_general_settings.items():
if k == "alert_to_webhook_url":
if "alerting" not in existing:
existing["alerting"] = ["slack"]
elif isinstance(existing["alerting"], list) and "slack" not in existing["alerting"]:
existing["alerting"].append("slack")
existing[k] = v
await _upsert_section("general_settings", existing)
asyncio.create_task(
create_config_audit_log(
"general_settings", "updated", before_general_settings, existing, user_api_key_dict
)
await _update_config_section(
prisma_client,
section_name="general_settings",
merge=lambda existing: reduce(_with_general_setting, requested_general_settings.items(), existing),
user_api_key_dict=user_api_key_dict,
)
# environment_variables: idempotently encrypt the request values
# (plaintext on first write, OR ciphertext the UI read back via
# /get/config/callbacks and re-submitted on save), then merge into
# existing. Only the sent keys are re-written; untouched keys keep
# their stored ciphertext byte-for-byte.
if config_info.environment_variables is not None:
existing = await _read_section("environment_variables")
before_environment_variables: Final = copy.deepcopy(existing)
existing.update(
encrypted_environment_variables: Final = _CONFIG_SECTION_VALUES.validate_python(
proxy_config.encrypt_env_variables_for_db(environment_variables=config_info.environment_variables)
)
await _upsert_section("environment_variables", existing)
asyncio.create_task(
create_config_audit_log(
"environment_variables", "updated", before_environment_variables, existing, user_api_key_dict
)
await _update_config_section(
prisma_client,
section_name="environment_variables",
merge=lambda existing: MappingProxyType({**existing, **encrypted_environment_variables}),
user_api_key_dict=user_api_key_dict,
)
# litellm_settings: merge existing + request, request wins (matching
# router_settings semantics — the caller's value for any given key is
# what gets persisted). success_callback is special-cased: it is
# always normalized + deduped, and unioned with any existing list,
# because callbacks are additive (callers send the new entry, not
# the full set). Normalizing on every write — not only when an
# existing entry is present — keeps the DB free of mixed-case
# entries that delete_callback (lowercase lookup) cannot find.
if config_info.litellm_settings is not None:
existing = await _read_section("litellm_settings")
before_litellm_settings: Final = copy.deepcopy(existing)
merged: Final = {**existing, **updated_litellm_settings}
incoming_cb: Final = updated_litellm_settings.get("success_callback")
existing_cb: Final = existing.get("success_callback")
if isinstance(incoming_cb, list):
if isinstance(existing_cb, list):
# Normalize the existing list too — a row written by a
# different code path may still hold mixed-case names,
# which would otherwise dedup-miss against the lowercase
# incoming entries.
merged["success_callback"] = list(set(normalize_callback_names(existing_cb) + incoming_cb))
else:
merged["success_callback"] = list(set(incoming_cb))
await _upsert_section("litellm_settings", merged)
asyncio.create_task(
create_config_audit_log(
"litellm_settings", "updated", before_litellm_settings, merged, user_api_key_dict
)
await _update_config_section(
prisma_client,
section_name="litellm_settings",
merge=lambda existing: _merged_litellm_settings(existing, updated_litellm_settings),
user_api_key_dict=user_api_key_dict,
)
# router_settings: merge existing + request, request wins.
if isinstance(raw_router_settings, dict):
existing = await _read_section("router_settings")
before_router_settings: Final = copy.deepcopy(existing)
new_router_settings: Final = {**existing, **router_settings_updates}
await _upsert_section("router_settings", new_router_settings)
asyncio.create_task(
create_config_audit_log(
"router_settings", "updated", before_router_settings, new_router_settings, user_api_key_dict
)
await _update_config_section(
prisma_client,
section_name="router_settings",
merge=lambda existing: MappingProxyType({**existing, **router_settings_updates}),
user_api_key_dict=user_api_key_dict,
)
await proxy_config.add_deployment(prisma_client=prisma_client, proxy_logging_obj=proxy_logging_obj)

View file

@ -454,7 +454,17 @@ class AgentMakePublicResponse(LiteLLMBaseModel):
class MakeAgentsPublicRequest(LiteLLMBaseModel):
model_config = ConfigDict(frozen=True)
agent_ids: list[str]
previous_agent_ids: tuple[str, ...] | None = Field(
default=None,
description=(
"The public agent list the caller started from. When set, only the agents added or removed relative to "
"it change, so agents another admin published or unpublished meanwhile keep that change. When omitted, "
"agent_ids replaces the stored list."
),
)
def normalize_a2a_jsonrpc_response(

View file

@ -48,6 +48,14 @@ class UpdateUsefulLinksRequest(LiteLLMBaseModel):
# New format: { "displayName": { "url": "...", "index": 0 } }
# Old format: { "displayName": "url" } (for backward compatibility)
useful_links: dict[str, str | dict[str, object]]
previous_useful_links: dict[str, str | dict[str, object]] | None = Field(
default=None,
description=(
"The useful links the caller started from. When set, only the links added, changed or removed relative "
"to it change, so links another admin edited meanwhile keep that edit. When omitted, useful_links "
"replaces the stored links."
),
)
class AutoRouterClassifierDefaultPromptResponse(LiteLLMBaseModel):

View file

@ -0,0 +1,69 @@
import uuid
from collections.abc import Callable
from concurrent.futures import ThreadPoolExecutor
from types import MappingProxyType
from typing import Final
import httpx
import pytest
from integration._support.client import Gateway, Scenario, list_value, object_value
AGENTS_PER_RACE: Final = 8
PUBLISHES: Final[MappingProxyType[str, Callable[[Gateway, str], httpx.Response]]] = MappingProxyType({
"single-agent-route": lambda proxy, agent_id: proxy.request("POST", f"/v1/agents/{agent_id}/make_public"),
"dashboard-modal": lambda proxy, agent_id: proxy.request(
"POST", "/v1/agents/make_public", {"agent_ids": [agent_id], "previous_agent_ids": []}
),
})
def _agent(gateway: Gateway, scenario: Scenario) -> str:
name: Final = f"hub-publish-{uuid.uuid4().hex}"
card: Final = {
"protocolVersion": "0.3",
"name": name,
"description": "Synthetic hub agent",
"version": "1.0.0",
"url": "http://127.0.0.1:9/",
"capabilities": {"streaming": False},
"defaultInputModes": ["text"],
"defaultOutputModes": ["text"],
"skills": [],
}
created: Final = gateway.request("POST", "/v1/agents", {"agent_name": name, "agent_card_params": card})
assert created.status_code == 200, created.text
agent_id: Final = str(created.json()["agent_id"])
scenario.cleanups.callback(lambda: gateway.request("DELETE", f"/v1/agents/{agent_id}"))
return agent_id
def _stored_public_agents(gateway: Gateway) -> frozenset[str]:
rows: Final = gateway.rows(
'SELECT param_value FROM "LiteLLM_Config" WHERE param_name=%s', ("litellm_settings",)
)
return frozenset(str(item) for item in list_value(object_value(rows[0]["param_value"])["public_agent_groups"]))
@pytest.mark.parametrize("publish", tuple(PUBLISHES), ids=tuple(PUBLISHES))
def test_concurrent_publishes_through_two_proxies_keep_every_agent_and_a_delete_unpublishes(
gateway: Gateway, peer: Gateway, scenario: Scenario, publish: str
) -> None:
agent_ids: Final = tuple(_agent(gateway, scenario) for _ in range(AGENTS_PER_RACE))
proxies: Final = (gateway, peer)
with ThreadPoolExecutor(max_workers=AGENTS_PER_RACE) as pool:
replies: Final = tuple(
pool.map(
lambda indexed: PUBLISHES[publish](proxies[indexed[0] % 2], indexed[1]),
enumerate(agent_ids),
)
)
assert [reply.status_code for reply in replies] == [200] * AGENTS_PER_RACE, [reply.text for reply in replies]
assert frozenset(agent_ids) <= _stored_public_agents(gateway)
deleted: Final = peer.request("DELETE", f"/v1/agents/{agent_ids[0]}")
assert deleted.status_code == 200, deleted.text
assert agent_ids[0] not in _stored_public_agents(gateway)
assert frozenset(agent_ids[1:]) <= _stored_public_agents(gateway)

View file

@ -1,6 +1,10 @@
import asyncio
import itertools
import json
from collections.abc import Mapping
from dataclasses import dataclass
from datetime import datetime, timezone
from pathlib import Path
from types import SimpleNamespace
from typing import Final
@ -8,6 +12,7 @@ from unittest.mock import AsyncMock, MagicMock, patch
import httpx
import pytest
import yaml
from fastapi import FastAPI, HTTPException
from fastapi.testclient import TestClient
from prisma.models import LiteLLM_AgentsTable
@ -15,6 +20,7 @@ from prisma.models import LiteLLM_AgentsTable
from litellm.constants import REDACTED_BY_LITELM_STRING
from litellm.proxy._types import LiteLLM_AuditLogs, LitellmTableNames, LitellmUserRoles, UserAPIKeyAuth
from litellm.proxy.agent_endpoints import endpoints as agent_endpoints
from litellm.proxy.agent_endpoints.agent_registry import AgentRegistry
from litellm.proxy.agent_endpoints.auth.agent_permission_handler import (
RestrictedAgentAccess,
)
@ -25,8 +31,9 @@ from litellm.proxy.agent_endpoints.endpoints import (
router,
user_api_key_auth,
)
from litellm.types.agents import AgentResponse, PatchAgentRequest
from litellm.types.agents import AgentResponse, MakeAgentsPublicRequest, PatchAgentRequest
from litellm.types.proxy.agent_identity import AgentIdentityBinding
from tests.unit.proxy.fake_config_table import ConfigRows, ReplicaPrisma
def _sample_agent_card_params() -> dict:
@ -1143,77 +1150,365 @@ def test_merged_agent_card_url_has_no_double_slash_without_proxy_base_url(
assert "//a2a" not in interface_url
class _DbBackedProxyConfig:
"""Round-trips `litellm_settings` through the DB overlay the proxy applies on every
`get_config()`, which is what re-assigns the `litellm.public_*` globals in production.
Storage goes through JSON the way the `litellm_config` row does, so every read hands back
freshly built values instead of the objects the endpoint still holds a reference to."""
def __init__(self, stored_litellm_settings: dict[str, object] | None = None) -> None:
self.stored_litellm_settings_json: str = json.dumps(stored_litellm_settings or {})
async def get_config(self) -> dict[str, dict[str, object]]:
from litellm.proxy.proxy_server import ProxyConfig
config: Final[dict[str, dict[str, object]]] = {"litellm_settings": {}}
db_param_value: Final[dict[str, object]] = json.loads(self.stored_litellm_settings_json)
if not db_param_value:
return config
proxy_config: Final = ProxyConfig()
db_values: Final = proxy_config._prepared_db_settings_values("litellm_settings", db_param_value)
proxy_config._apply_litellm_settings_db_values(db_values)
return {"litellm_settings": dict(proxy_config.litellm_settings.resolved())}
async def save_config(self, new_config: dict[str, dict[str, object]]) -> None:
self.stored_litellm_settings_json = json.dumps(new_config.get("litellm_settings") or {})
_PROXY_ADMIN: Final = UserAPIKeyAuth(user_id="test-user", user_role=LitellmUserRoles.PROXY_ADMIN)
def test_make_agent_public_twice_keeps_both_agents_public(monkeypatch: pytest.MonkeyPatch) -> None:
"""A second /make_public call must not drop the agent published by the first one."""
def _replica_that_missed_a_publish(
monkeypatch: pytest.MonkeyPatch, *, stored_public_agent_groups: list[str], store_model_in_db: bool = True
) -> tuple[ConfigRows, AgentRegistry]:
import litellm
from litellm.proxy.agent_endpoints import agent_registry as agent_registry_module
from litellm.proxy.agent_endpoints.agent_registry import AgentRegistry
from litellm.proxy.proxy_server import ProxyConfig
registry: Final = AgentRegistry()
registry.register_agent(_sample_agent_response(agent_id="agent-1", agent_name="Agent One"))
registry.register_agent(_sample_agent_response(agent_id="agent-2", agent_name="Agent Two"))
rows: Final = ConfigRows({"litellm_settings": {"public_agent_groups": stored_public_agent_groups}})
cached_rows: Final = {"litellm_settings": {"public_agent_groups": []}}
monkeypatch.setattr(agent_registry_module, "global_agent_registry", registry)
monkeypatch.setattr(litellm, "public_agent_groups", None)
monkeypatch.setattr("litellm.proxy.proxy_server.prisma_client", MagicMock())
monkeypatch.setattr("litellm.proxy.proxy_server.proxy_config", _DbBackedProxyConfig())
monkeypatch.setattr(litellm, "public_agent_groups", [])
monkeypatch.setattr("litellm.proxy.proxy_server.prisma_client", ReplicaPrisma(rows, cached_rows))
monkeypatch.setattr("litellm.proxy.proxy_server.store_model_in_db", store_model_in_db)
monkeypatch.setattr("litellm.proxy.proxy_server.general_settings", {"store_model_in_db": store_model_in_db})
monkeypatch.setattr("litellm.proxy.proxy_server.proxy_config", ProxyConfig())
return rows, registry
first: Final = client.post("/v1/agents/agent-1/make_public", headers={"Authorization": "Bearer test-key"})
second: Final = client.post("/v1/agents/agent-2/make_public", headers={"Authorization": "Bearer test-key"})
assert first.status_code == 200
assert second.status_code == 200
assert second.json()["public_agent_groups"] == ["agent-1", "agent-2"]
@pytest.mark.asyncio
async def test_make_agent_public_keeps_an_agent_another_replica_published(monkeypatch: pytest.MonkeyPatch) -> None:
rows, registry = _replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=["agent-1"])
response: Final = await agent_endpoints.make_agent_public(agent_id="agent-2", user_api_key_dict=_PROXY_ADMIN)
assert response["public_agent_groups"] == ["agent-1", "agent-2"]
assert rows.stored("litellm_settings")["public_agent_groups"] == ["agent-1", "agent-2"]
assert [agent.agent_id for agent in registry.get_public_agent_list()] == ["agent-1", "agent-2"]
def test_make_agent_public_rejects_an_agent_published_only_in_the_db(monkeypatch: pytest.MonkeyPatch) -> None:
"""The duplicate guard must fire off the stored list, not just what this process published."""
import litellm
from litellm.proxy.agent_endpoints import agent_registry as agent_registry_module
from litellm.proxy.agent_endpoints.agent_registry import AgentRegistry
@pytest.mark.asyncio
async def test_make_agent_public_concurrent_publishes_all_stay_public(monkeypatch: pytest.MonkeyPatch) -> None:
rows, _ = _replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=[])
registry: Final = AgentRegistry()
registry.register_agent(_sample_agent_response(agent_id="agent-1", agent_name="Agent One"))
monkeypatch.setattr(agent_registry_module, "global_agent_registry", registry)
monkeypatch.setattr(litellm, "public_agent_groups", None)
monkeypatch.setattr("litellm.proxy.proxy_server.prisma_client", MagicMock())
monkeypatch.setattr(
"litellm.proxy.proxy_server.proxy_config",
_DbBackedProxyConfig({"public_agent_groups": ["agent-1"]}),
await asyncio.gather(
agent_endpoints.make_agent_public(agent_id="agent-1", user_api_key_dict=_PROXY_ADMIN),
agent_endpoints.make_agent_public(agent_id="agent-2", user_api_key_dict=_PROXY_ADMIN),
)
duplicate: Final = client.post("/v1/agents/agent-1/make_public", headers={"Authorization": "Bearer test-key"})
assert sorted(rows.stored("litellm_settings")["public_agent_groups"]) == ["agent-1", "agent-2"]
assert duplicate.status_code == 400
assert "already in public agent groups" in duplicate.json()["detail"]
@pytest.mark.asyncio
async def test_make_agent_public_rejects_an_agent_another_replica_published(monkeypatch: pytest.MonkeyPatch) -> None:
rows, _ = _replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=["agent-1"])
with pytest.raises(HTTPException) as duplicate:
await agent_endpoints.make_agent_public(agent_id="agent-1", user_api_key_dict=_PROXY_ADMIN)
assert duplicate.value.status_code == 400
assert "already in public agent groups" in duplicate.value.detail
assert rows.stored("litellm_settings")["public_agent_groups"] == ["agent-1"]
@pytest.mark.asyncio
async def test_make_agent_public_refuses_a_list_the_config_file_owns(
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
) -> None:
from litellm.proxy import proxy_server
rows, _ = _replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=[])
config_file: Final = tmp_path / "config.yaml"
config_file.write_text("litellm_settings:\n public_agent_groups: [agent-1]\n")
monkeypatch.setattr("litellm.proxy.proxy_server.user_config_file_path", str(config_file))
await proxy_server.proxy_config.get_config()
with pytest.raises(HTTPException) as already_public:
await agent_endpoints.make_agent_public(agent_id="agent-1", user_api_key_dict=_PROXY_ADMIN)
with pytest.raises(HTTPException) as refused:
await agent_endpoints.make_agent_public(agent_id="agent-2", user_api_key_dict=_PROXY_ADMIN)
assert already_public.value.status_code == 400
assert "already in public agent groups" in already_public.value.detail
assert refused.value.status_code == 400
assert refused.value.detail["keys"] == ["public_agent_groups"]
assert rows.stored("litellm_settings")["public_agent_groups"] == []
@pytest.mark.asyncio
async def test_make_agent_public_appends_to_the_config_file_without_db_settings(
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
) -> None:
_replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=[], store_model_in_db=False)
config_file: Final = tmp_path / "config.yaml"
config_file.write_text("litellm_settings:\n public_agent_groups: [agent-1]\n")
monkeypatch.setattr("litellm.proxy.proxy_server.user_config_file_path", str(config_file))
response: Final = await agent_endpoints.make_agent_public(agent_id="agent-2", user_api_key_dict=_PROXY_ADMIN)
with pytest.raises(HTTPException) as duplicate:
await agent_endpoints.make_agent_public(agent_id="agent-1", user_api_key_dict=_PROXY_ADMIN)
assert response["public_agent_groups"] == ["agent-1", "agent-2"]
assert yaml.safe_load(config_file.read_text())["litellm_settings"]["public_agent_groups"] == ["agent-1", "agent-2"]
assert duplicate.value.status_code == 400
def _hold_the_first_invalidation_until_the_next_one(monkeypatch: pytest.MonkeyPatch) -> None:
from litellm.proxy import proxy_server
real_invalidate: Final = proxy_server.invalidate_config_param
next_invalidation: Final = asyncio.Event()
invalidations: Final = itertools.count()
async def invalidate(param_name: str) -> None:
if next(invalidations) == 0:
await asyncio.wait_for(next_invalidation.wait(), timeout=5)
else:
next_invalidation.set()
await real_invalidate(param_name)
monkeypatch.setattr(proxy_server, "invalidate_config_param", invalidate)
@pytest.mark.asyncio
async def test_make_agent_public_concurrent_publishes_stay_in_the_worker_list_when_invalidation_is_slow(
monkeypatch: pytest.MonkeyPatch,
) -> None:
import litellm
rows, _ = _replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=[])
_hold_the_first_invalidation_until_the_next_one(monkeypatch)
await asyncio.gather(
agent_endpoints.make_agent_public(agent_id="agent-1", user_api_key_dict=_PROXY_ADMIN),
agent_endpoints.make_agent_public(agent_id="agent-2", user_api_key_dict=_PROXY_ADMIN),
)
assert rows.stored("litellm_settings")["public_agent_groups"] == ["agent-1", "agent-2"]
assert litellm.public_agent_groups == ["agent-1", "agent-2"]
@pytest.mark.asyncio
async def test_make_agent_public_is_seen_by_the_next_settings_read_on_this_worker(
monkeypatch: pytest.MonkeyPatch,
) -> None:
from litellm.caching.dual_cache import DualCache
from litellm.proxy import proxy_server
from litellm.proxy import utils as proxy_utils
rows, _ = _replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=["agent-1"])
live_replica: Final = ReplicaPrisma(rows)
monkeypatch.setattr(proxy_server, "prisma_client", live_replica)
monkeypatch.setattr(proxy_utils, "litellm_config_cache", DualCache())
await proxy_utils.get_config_param(live_replica, "litellm_settings")
await agent_endpoints.make_agent_public(agent_id="agent-2", user_api_key_dict=_PROXY_ADMIN)
cached_row: Final = await proxy_utils.get_config_param(live_replica, "litellm_settings")
assert cached_row.param_value["public_agent_groups"] == ["agent-1", "agent-2"]
assert proxy_server.proxy_config.litellm_settings.get("public_agent_groups") == ["agent-1", "agent-2"]
def _make_agents_public(agent_ids: list[str], *, previous_agent_ids: list[str] | None):
return agent_endpoints.make_agents_public(
request=MakeAgentsPublicRequest(agent_ids=agent_ids, previous_agent_ids=previous_agent_ids),
user_api_key_dict=_PROXY_ADMIN,
)
@pytest.mark.asyncio
@pytest.mark.parametrize(
"stored, previous, requested, expected",
[
(["agent-1"], [], ["agent-2"], ["agent-1", "agent-2"]),
(["agent-1", "agent-2"], ["agent-1", "agent-2"], ["agent-2"], ["agent-2"]),
(["agent-2"], ["agent-1"], ["agent-1"], ["agent-2"]),
(["agent-1"], [], ["agent-1"], ["agent-1"]),
(["agent-2", "agent-1"], ["agent-1"], ["agent-1", "agent-2"], ["agent-2", "agent-1"]),
([], [], ["agent-2", "agent-1", "agent-2"], ["agent-2", "agent-1"]),
],
ids=[
"keeps-an-agent-the-stale-modal-never-showed",
"drops-only-the-deselected-agent",
"keeps-another-writers-removal",
"skips-an-agent-already-stored",
"keeps-the-stored-order",
"adds-in-request-order-once",
],
)
async def test_make_agents_public_applies_only_the_modal_change_to_the_stored_list(
monkeypatch: pytest.MonkeyPatch, stored: list[str], previous: list[str], requested: list[str], expected: list[str]
) -> None:
import litellm
rows, _ = _replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=stored)
response: Final = await _make_agents_public(requested, previous_agent_ids=previous)
assert response["public_agent_groups"] == expected
assert rows.stored("litellm_settings")["public_agent_groups"] == expected
assert litellm.public_agent_groups == expected
@pytest.mark.asyncio
async def test_make_agents_public_concurrent_modal_saves_keep_both_agents(monkeypatch: pytest.MonkeyPatch) -> None:
import litellm
rows, registry = _replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=[])
_hold_the_first_invalidation_until_the_next_one(monkeypatch)
await asyncio.gather(
_make_agents_public(["agent-1"], previous_agent_ids=[]),
_make_agents_public(["agent-2"], previous_agent_ids=[]),
)
assert rows.stored("litellm_settings")["public_agent_groups"] == ["agent-1", "agent-2"]
assert litellm.public_agent_groups == ["agent-1", "agent-2"]
assert [agent.agent_id for agent in registry.get_public_agent_list()] == ["agent-1", "agent-2"]
@pytest.mark.asyncio
async def test_make_agents_public_treats_a_config_agents_legacy_id_as_the_same_agent(
monkeypatch: pytest.MonkeyPatch,
) -> None:
rows, registry = _replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=[])
config_agent: Final = {"agent_name": "Config Agent", "agent_card_params": _sample_agent_card_params()}
registry.load_agents_from_config([config_agent])
stable_id: Final = registry.stable_agent_id(next(iter(registry.config_agent_legacy_ids)))
legacy_id: Final = next(iter(registry.ids_for_agent(stable_id) - {stable_id}))
rows.serialized_rows["litellm_settings"] = json.dumps({"public_agent_groups": [legacy_id, "agent-1"]})
kept: Final = await _make_agents_public([stable_id, "agent-1"], previous_agent_ids=[])
unpublished: Final = await _make_agents_public(["agent-1"], previous_agent_ids=[stable_id, "agent-1"])
assert kept["public_agent_groups"] == [legacy_id, "agent-1"]
assert unpublished["public_agent_groups"] == ["agent-1"]
assert rows.stored("litellm_settings")["public_agent_groups"] == ["agent-1"]
@pytest.mark.asyncio
async def test_make_agents_public_matches_a_legacy_id_in_previous_agent_ids_to_the_stored_agent(
monkeypatch: pytest.MonkeyPatch,
) -> None:
rows, registry = _replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=[])
config_agent: Final = {"agent_name": "Config Agent", "agent_card_params": _sample_agent_card_params()}
registry.load_agents_from_config([config_agent])
stable_id: Final = registry.stable_agent_id(next(iter(registry.config_agent_legacy_ids)))
legacy_id: Final = next(iter(registry.ids_for_agent(stable_id) - {stable_id}))
rows.serialized_rows["litellm_settings"] = json.dumps({"public_agent_groups": [stable_id, "agent-1"]})
unchanged: Final = await _make_agents_public([stable_id, "agent-1"], previous_agent_ids=[legacy_id, "agent-1"])
unpublished: Final = await _make_agents_public(["agent-1"], previous_agent_ids=[legacy_id, "agent-1"])
assert unchanged["public_agent_groups"] == [stable_id, "agent-1"]
assert unpublished["public_agent_groups"] == ["agent-1"]
assert rows.stored("litellm_settings")["public_agent_groups"] == ["agent-1"]
@pytest.mark.asyncio
async def test_make_agents_public_stores_one_id_when_both_ids_of_a_config_agent_are_ticked(
monkeypatch: pytest.MonkeyPatch,
) -> None:
rows, registry = _replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=[])
config_agent: Final = {"agent_name": "Config Agent", "agent_card_params": _sample_agent_card_params()}
registry.load_agents_from_config([config_agent])
legacy_id: Final = next(iter(registry.config_agent_legacy_ids))
stable_id: Final = registry.stable_agent_id(legacy_id)
response: Final = await _make_agents_public([legacy_id, stable_id, "agent-1"], previous_agent_ids=[])
assert response["public_agent_groups"] == [legacy_id, "agent-1"]
assert rows.stored("litellm_settings")["public_agent_groups"] == [legacy_id, "agent-1"]
@pytest.mark.asyncio
async def test_delete_agent_unpublishes_it_so_a_new_agent_reusing_its_id_starts_private(
monkeypatch: pytest.MonkeyPatch,
) -> None:
import litellm
rows, registry = _replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=["agent-1", "agent-2"])
agents_table: Final = SimpleNamespace(
find_unique=AsyncMock(return_value={"agent_id": "agent-1", "agent_name": "Agent One"})
)
monkeypatch.setattr(
"litellm.proxy.proxy_server.prisma_client",
ReplicaPrisma(rows, tables={"litellm_agentstable": agents_table}),
)
monkeypatch.setattr(
agent_endpoints, "AGENT_REGISTRY", MagicMock(wraps=registry, delete_agent_from_db=AsyncMock())
)
response: Final = await agent_endpoints.delete_agent(agent_id="agent-1", user_api_key_dict=_PROXY_ADMIN)
assert response == {"message": "Agent agent-1 deleted successfully"}
assert rows.stored("litellm_settings")["public_agent_groups"] == ["agent-2"]
assert litellm.public_agent_groups == ["agent-2"]
@pytest.mark.asyncio
async def test_make_agents_public_without_previous_agent_ids_replaces_the_stored_list(
monkeypatch: pytest.MonkeyPatch,
) -> None:
import litellm
from litellm.proxy import proxy_server
_replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=["agent-1"])
saved_configs: Final = []
monkeypatch.setattr(
proxy_server.proxy_config, "get_config", AsyncMock(return_value={"litellm_settings": {"drop_params": True}})
)
monkeypatch.setattr(
proxy_server.proxy_config,
"save_config",
AsyncMock(side_effect=lambda new_config: saved_configs.append(new_config)),
)
response: Final = await _make_agents_public(["agent-2"], previous_agent_ids=None)
assert response["public_agent_groups"] == ["agent-2"]
assert litellm.public_agent_groups == ["agent-2"]
assert saved_configs == [{"litellm_settings": {"drop_params": True, "public_agent_groups": ["agent-2"]}}]
@pytest.mark.asyncio
async def test_make_agents_public_refuses_a_change_to_a_list_the_config_file_owns(
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
) -> None:
from litellm.proxy import proxy_server
rows, _ = _replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=[])
config_file: Final = tmp_path / "config.yaml"
config_file.write_text("litellm_settings:\n public_agent_groups: [agent-1]\n")
monkeypatch.setattr("litellm.proxy.proxy_server.user_config_file_path", str(config_file))
await proxy_server.proxy_config.get_config()
unchanged: Final = await _make_agents_public(["agent-1"], previous_agent_ids=["agent-1"])
with pytest.raises(HTTPException) as refused:
await _make_agents_public(["agent-1", "agent-2"], previous_agent_ids=["agent-1"])
assert unchanged["public_agent_groups"] == ["agent-1"]
assert refused.value.status_code == 400
assert refused.value.detail["keys"] == ["public_agent_groups"]
assert rows.stored("litellm_settings")["public_agent_groups"] == []
@pytest.mark.asyncio
async def test_make_agents_public_applies_the_modal_change_to_the_config_file_without_db_settings(
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
) -> None:
import litellm
_replica_that_missed_a_publish(monkeypatch, stored_public_agent_groups=[], store_model_in_db=False)
config_file: Final = tmp_path / "config.yaml"
config_file.write_text("litellm_settings:\n public_agent_groups: [agent-1]\n")
monkeypatch.setattr("litellm.proxy.proxy_server.user_config_file_path", str(config_file))
added: Final = await _make_agents_public(["agent-2"], previous_agent_ids=[])
unchanged: Final = await _make_agents_public(["agent-1", "agent-2"], previous_agent_ids=["agent-1", "agent-2"])
assert added["public_agent_groups"] == unchanged["public_agent_groups"] == ["agent-1", "agent-2"]
assert yaml.safe_load(config_file.read_text())["litellm_settings"]["public_agent_groups"] == ["agent-1", "agent-2"]
assert litellm.public_agent_groups == ["agent-1", "agent-2"]
@pytest.mark.parametrize("enabled, claim_field, expected", [(True, "azp", True), (False, "azp", False), (True, None, False)])

View file

@ -0,0 +1,78 @@
import asyncio
import json
from collections.abc import Callable, Mapping
from dataclasses import dataclass
from types import SimpleNamespace
from typing import Final
@dataclass(frozen=True, slots=True)
class StoredConfigRow:
param_name: str
param_value: dict[str, object]
class ConfigRows:
def __init__(self, rows: Mapping[str, Mapping[str, object]]) -> None:
self.serialized_rows: dict[str, str] = {name: json.dumps(dict(value)) for name, value in rows.items()}
async def find_first(self, *, where: Mapping[str, str]) -> StoredConfigRow | None:
name: Final = where["param_name"]
serialized: Final = self.serialized_rows.get(name)
await asyncio.sleep(0)
return None if serialized is None else StoredConfigRow(param_name=name, param_value=json.loads(serialized))
async def upsert(self, *, where: Mapping[str, str], data: Mapping[str, Mapping[str, str]]) -> None:
self.serialized_rows[where["param_name"]] = data["update"]["param_value"]
def stored(self, name: str) -> dict[str, object]:
return json.loads(self.serialized_rows[name])
class SectionLockedTransaction:
def __init__(self, litellm_config: object, section_lock: asyncio.Lock) -> None:
self.litellm_config: Final = litellm_config
self._section_lock: Final = section_lock
self._holds_section_lock = False
async def __aenter__(self) -> "SectionLockedTransaction":
return self
async def __aexit__(self, *_: object) -> None:
if self._holds_section_lock:
self._section_lock.release()
async def query_raw(self, query: str, section_name: str) -> list[dict[str, int]]:
await self._section_lock.acquire()
self._holds_section_lock = True
return [{"locked": 1}]
def section_locked_transactions(litellm_config: object) -> Callable[[], SectionLockedTransaction]:
section_lock: Final = asyncio.Lock()
return lambda: SectionLockedTransaction(litellm_config, section_lock)
class ReplicaPrisma:
def __init__(
self,
rows: ConfigRows,
cached_rows: Mapping[str, Mapping[str, object]] | None = None,
tables: Mapping[str, object] | None = None,
) -> None:
self.rows: Final = rows
self._cached_rows: Final = cached_rows
self.tx: Final = section_locked_transactions(rows)
self.db: Final = SimpleNamespace(litellm_config=rows, **(tables or {}))
self.writer_db: Final = self.db
async def get_generic_data(self, key: str, value: str, table_name: str) -> SimpleNamespace | None:
cached: Final = (
self._cached_rows.get(value)
if self._cached_rows is not None
else (self.rows.stored(value) if value in self.rows.serialized_rows else None)
)
return None if cached is None else SimpleNamespace(param_name=value, param_value=dict(cached))

View file

@ -46,6 +46,7 @@ from litellm.proxy.mcp_server.mcp_server_manager import MCPServerConfig, MCPServ
from litellm.proxy.utils import ProxyLogging
from litellm.types.mcp import MCPAuth, MCPCredentials
from litellm.types.mcp_server.mcp_server_manager import MCPServer, PinnedMCPTool
from tests.unit.proxy.fake_config_table import ConfigRows, ReplicaPrisma
def generate_mock_mcp_server_db_record(
@ -315,6 +316,93 @@ async def test_mcp_publication_updates_runtime_only_after_successful_save(
save.assert_awaited_once_with(new_config=expected_config)
@pytest.mark.asyncio
async def test_mcp_publication_from_the_modal_keeps_a_server_another_admin_published(
monkeypatch: pytest.MonkeyPatch,
) -> None:
from litellm.proxy.proxy_server import ProxyConfig
manager: Final = MCPServerManager()
manager.config_mcp_servers = {
server_id: generate_mock_mcp_server_config_record(server_id=server_id)
for server_id in ("server-1", "server-2", "server-3")
}
rows: Final = ConfigRows({"litellm_settings": {"public_mcp_servers": ["server-1", "server-2"]}})
monkeypatch.setattr(litellm, "public_mcp_servers", [])
monkeypatch.setattr("litellm.proxy.proxy_server.prisma_client", ReplicaPrisma(rows))
monkeypatch.setattr("litellm.proxy.proxy_server.store_model_in_db", True)
monkeypatch.setattr("litellm.proxy.proxy_server.proxy_config", ProxyConfig())
monkeypatch.setattr("litellm.proxy.mcp_server.mcp_server_manager.global_mcp_server_manager", manager)
response: Final = await mgmt_endpoints.make_mcp_servers_public(
MakeMCPServersPublicRequest(mcp_server_ids=["server-3"], previous_mcp_server_ids=["server-2"]),
generate_mock_user_api_key_auth(user_role=LitellmUserRoles.PROXY_ADMIN),
)
assert response["public_mcp_servers"] == ["server-1", "server-3"]
assert rows.stored("litellm_settings")["public_mcp_servers"] == ["server-1", "server-3"]
assert litellm.public_mcp_servers == ["server-1", "server-3"]
def _replica_publishing_servers(
monkeypatch: pytest.MonkeyPatch, *, config_file_public_mcp_servers: list[str] | None = None
) -> ConfigRows:
from litellm.proxy.proxy_server import ProxyConfig
rows: Final = ConfigRows({"litellm_settings": {"public_mcp_servers": ["server-1", "server-2"]}})
proxy_config: Final = ProxyConfig()
if config_file_public_mcp_servers is not None:
proxy_config._load_yaml_settings_stores(
{"litellm_settings": {"public_mcp_servers": config_file_public_mcp_servers}}
)
monkeypatch.setattr(litellm, "public_mcp_servers", ["server-1", "server-2"])
monkeypatch.setattr("litellm.proxy.proxy_server.prisma_client", ReplicaPrisma(rows))
monkeypatch.setattr("litellm.proxy.proxy_server.store_model_in_db", True)
monkeypatch.setattr("litellm.proxy.proxy_server.proxy_config", proxy_config)
monkeypatch.setattr(
mgmt_endpoints,
"delete_mcp_server",
AsyncMock(return_value=generate_mock_mcp_server_db_record(server_id="server-1")),
)
monkeypatch.setattr(
mgmt_endpoints, "global_mcp_server_manager", MagicMock(reload_servers_from_database=AsyncMock())
)
return rows
@pytest.mark.asyncio
async def test_remove_mcp_server_unpublishes_it_so_a_new_server_reusing_its_id_starts_private(
monkeypatch: pytest.MonkeyPatch,
) -> None:
rows: Final = _replica_publishing_servers(monkeypatch)
response: Final = await mgmt_endpoints.remove_mcp_server(
server_id="server-1",
user_api_key_dict=generate_mock_user_api_key_auth(user_role=LitellmUserRoles.PROXY_ADMIN),
litellm_changed_by=None,
)
assert response.status_code == 202
assert rows.stored("litellm_settings")["public_mcp_servers"] == ["server-2"]
assert litellm.public_mcp_servers == ["server-2"]
@pytest.mark.asyncio
async def test_remove_mcp_server_still_deletes_when_the_config_file_owns_the_public_list(
monkeypatch: pytest.MonkeyPatch,
) -> None:
rows: Final = _replica_publishing_servers(monkeypatch, config_file_public_mcp_servers=["server-1"])
response: Final = await mgmt_endpoints.remove_mcp_server(
server_id="server-1",
user_api_key_dict=generate_mock_user_api_key_auth(user_role=LitellmUserRoles.PROXY_ADMIN),
litellm_changed_by=None,
)
assert response.status_code == 202
assert rows.stored("litellm_settings")["public_mcp_servers"] == ["server-1", "server-2"]
class TestMCPCredentialsTokenExchangeProfile:
"""token_exchange_profile must be a declared MCPCredentials field so the management API can
persist the entra_obo profile. An undeclared key is silently stripped by pydantic when the

View file

@ -55,6 +55,7 @@ from litellm.types.router import (
updateDeployment,
updateLiteLLMParams,
)
from tests.unit.proxy.fake_config_table import ConfigRows, ReplicaPrisma
async def _passthrough_row(update_data):
@ -2119,6 +2120,98 @@ class TestUpdateModel:
assert persisted["litellm_credential_name"] == "shared-credential"
@pytest.mark.asyncio
async def test_update_useful_links_from_the_dashboard_keeps_a_link_another_admin_edited(
monkeypatch: pytest.MonkeyPatch,
) -> None:
import litellm
from litellm.proxy.management_endpoints.model_management_endpoints import update_useful_links
from litellm.proxy.proxy_server import ProxyConfig
from litellm.types.proxy.management_endpoints.model_management_endpoints import UpdateUsefulLinksRequest
docs: Final = {"url": "https://docs.example.com", "index": 0}
status_before: Final = {"url": "https://status.example.com", "index": 1}
status_edited_by_other_admin: Final = {"url": "https://status.example.com/v2", "index": 1}
retired: Final = {"url": "https://retired.example.com", "index": 2}
docs_edited: Final = {"url": "https://docs.example.com/v2", "index": 0}
blog: Final = {"url": "https://blog.example.com", "index": 2}
rows: Final = ConfigRows(
{
"litellm_settings": {
"public_model_groups_links": {"Docs": docs, "Status": status_edited_by_other_admin, "Retired": retired}
}
}
)
monkeypatch.setattr(litellm, "public_model_groups_links", {})
monkeypatch.setattr("litellm.proxy.proxy_server.prisma_client", ReplicaPrisma(rows))
monkeypatch.setattr("litellm.proxy.proxy_server.store_model_in_db", True)
monkeypatch.setattr("litellm.proxy.proxy_server.proxy_config", ProxyConfig())
response: Final = await update_useful_links(
request=UpdateUsefulLinksRequest(
useful_links={"Docs": docs_edited, "Status": status_before, "Blog": blog},
previous_useful_links={"Docs": docs, "Status": status_before, "Retired": retired},
),
user_api_key_dict=UserAPIKeyAuth(user_id="admin", user_role=LitellmUserRoles.PROXY_ADMIN),
)
expected: Final = {"Docs": docs_edited, "Status": status_edited_by_other_admin, "Blog": blog}
assert response["useful_links"] == expected
assert rows.stored("litellm_settings")["public_model_groups_links"] == expected
assert litellm.public_model_groups_links == expected
@pytest.mark.asyncio
async def test_update_useful_links_that_change_nothing_create_no_settings_row(
monkeypatch: pytest.MonkeyPatch,
) -> None:
import litellm
from litellm.proxy.management_endpoints.model_management_endpoints import update_useful_links
from litellm.proxy.proxy_server import ProxyConfig
from litellm.types.proxy.management_endpoints.model_management_endpoints import UpdateUsefulLinksRequest
rows: Final = ConfigRows({})
monkeypatch.setattr(litellm, "public_model_groups_links", {})
monkeypatch.setattr("litellm.proxy.proxy_server.prisma_client", ReplicaPrisma(rows))
monkeypatch.setattr("litellm.proxy.proxy_server.store_model_in_db", True)
monkeypatch.setattr("litellm.proxy.proxy_server.proxy_config", ProxyConfig())
response: Final = await update_useful_links(
request=UpdateUsefulLinksRequest(useful_links={}, previous_useful_links={}),
user_api_key_dict=UserAPIKeyAuth(user_id="admin", user_role=LitellmUserRoles.PROXY_ADMIN),
)
assert response["useful_links"] == {}
assert "litellm_settings" not in rows.serialized_rows
@pytest.mark.asyncio
async def test_update_public_model_groups_from_the_modal_keeps_a_group_another_admin_published(
monkeypatch: pytest.MonkeyPatch,
) -> None:
import litellm
from litellm.proxy.management_endpoints.model_management_endpoints import (
UpdatePublicModelGroupsRequest,
update_public_model_groups,
)
from litellm.proxy.proxy_server import ProxyConfig
rows: Final = ConfigRows({"litellm_settings": {"public_model_groups": ["gpt-a", "gpt-b"]}})
monkeypatch.setattr(litellm, "public_model_groups", [])
monkeypatch.setattr("litellm.proxy.proxy_server.prisma_client", ReplicaPrisma(rows))
monkeypatch.setattr("litellm.proxy.proxy_server.store_model_in_db", True)
monkeypatch.setattr("litellm.proxy.proxy_server.proxy_config", ProxyConfig())
response: Final = await update_public_model_groups(
request=UpdatePublicModelGroupsRequest(model_groups=["gpt-c"], previous_model_groups=["gpt-b"]),
user_api_key_dict=UserAPIKeyAuth(user_id="admin", user_role=LitellmUserRoles.PROXY_ADMIN),
)
assert response["public_model_groups"] == ["gpt-a", "gpt-c"]
assert rows.stored("litellm_settings")["public_model_groups"] == ["gpt-a", "gpt-c"]
assert litellm.public_model_groups == ["gpt-a", "gpt-c"]
class TestUpdatePublicModelGroups:
"""Test that update_public_model_groups correctly sets litellm.public_model_groups
even when get_config() overwrites it with stale DB values."""

View file

@ -24,6 +24,8 @@ import httpx
import pytest
from fastapi.testclient import TestClient
from tests.unit.proxy.fake_config_table import section_locked_transactions
from .conftest import VOLATILE_KEYS, normalize
@ -52,6 +54,7 @@ def _install_litellm_config(mock_prisma: MagicMock) -> MagicMock:
table.delete = AsyncMock()
mock_prisma.db.litellm_config = table
mock_prisma.writer_db.litellm_config = table
mock_prisma.tx = section_locked_transactions(table)
return table

View file

@ -10,6 +10,7 @@ from unittest import mock
from dotenv import load_dotenv
from tests._master_key import MASTER_KEY
from tests.unit.proxy.fake_config_table import section_locked_transactions
import litellm.proxy
import litellm.proxy.proxy_server
@ -3403,6 +3404,7 @@ async def test_update_config_success_callback_normalization(monkeypatch):
self.db.litellm_config.find_first = AsyncMock(side_effect=fake_find_first)
self.db.litellm_config.upsert = AsyncMock(side_effect=fake_upsert)
self.writer_db = self.db
self.tx = section_locked_transactions(self.db.litellm_config)
monkeypatch.setattr(proxy_server, "prisma_client", MockPrisma())

View file

@ -53,6 +53,7 @@ from litellm.proxy.proxy_server import app, aws_error_type_exception_handler, in
from litellm.utils import _invalidate_model_cost_lowercase_map
from litellm.proxy.common_utils.banner import LITELLM_BANNER
from tests._master_key import MASTER_KEY
from tests.unit.proxy.fake_config_table import ConfigRows, ReplicaPrisma, section_locked_transactions
PUBLICLY_KNOWN_KEY: Final = "sk-" + "1234"
@ -10128,6 +10129,7 @@ class _FakePrismaClient:
if replica_rows is None
else _LaggingReplicaLitellmConfig(replica_rows, writer=self.writer_db.litellm_config)
)
self.tx = section_locked_transactions(self.writer_db.litellm_config)
self.jsonify_object = lambda obj: obj
@ -10192,6 +10194,58 @@ def test_update_config_writes_only_sent_section(_update_config_setup):
restore()
@pytest.mark.parametrize(
"stored_general_settings, expected_alerting",
[({}, ["slack"]), ({"alerting": ["email"]}, ["email", "slack"]), ({"alerting": ["slack", "email"]}, ["slack", "email"])],
)
def test_update_config_alert_webhook_turns_on_slack_alerting_once(
_update_config_setup, stored_general_settings, expected_alerting
):
webhooks = {"budget_alerts": "https://hooks.example.com/budget"}
client, prisma, restore = _update_config_setup(initial_rows={"general_settings": stored_general_settings})
try:
resp = client.post("/config/update", json={"general_settings": {"alert_to_webhook_url": webhooks}})
assert resp.status_code == 200
assert prisma.writer_db.litellm_config.rows["general_settings"] == {
"alerting": expected_alerting,
"alert_to_webhook_url": webhooks,
}
finally:
restore()
@pytest.mark.asyncio
async def test_update_config_and_a_concurrent_publish_both_stay_in_litellm_settings(monkeypatch):
from litellm.proxy import proxy_server
from litellm.proxy._types import ConfigYAML, LitellmUserRoles, UserAPIKeyAuth
rows = ConfigRows({"litellm_settings": {"drop_params": True}})
proxy_config = proxy_server.ProxyConfig()
monkeypatch.setattr(proxy_server, "prisma_client", ReplicaPrisma(rows))
monkeypatch.setattr(proxy_server, "store_model_in_db", True)
monkeypatch.setattr(proxy_server, "proxy_config", proxy_config)
monkeypatch.setattr(proxy_config, "add_deployment", AsyncMock(return_value=None))
request = MagicMock()
request.json = AsyncMock(return_value={"litellm_settings": {"num_retries": 3}})
await asyncio.gather(
proxy_server.update_config(
config_info=ConfigYAML(litellm_settings={"num_retries": 3}),
request=request,
user_api_key_dict=UserAPIKeyAuth(user_role=LitellmUserRoles.PROXY_ADMIN, api_key=MASTER_KEY),
),
proxy_config.append_to_list_setting(
section_name="litellm_settings",
key="public_agent_groups",
item="agent-1",
listed_as=frozenset({"agent-1"}),
on_written=lambda _: None,
),
)
assert rows.stored("litellm_settings") == {"drop_params": True, "num_retries": 3, "public_agent_groups": ["agent-1"]}
def test_update_config_keeps_an_environment_variable_the_read_replica_has_not_caught_up_on(_update_config_setup):
client, prisma, restore = _update_config_setup(
initial_rows={"environment_variables": {"SAVED_A_MOMENT_AGO": "enc:new"}},

View file

@ -34,6 +34,7 @@ from litellm.router_utils.pre_call_checks.encrypted_content_affinity_check impor
from litellm.router_utils.pre_call_checks.model_rate_limit_check import ModelRateLimitingCheck
from litellm.router_utils.pre_call_checks.prompt_caching_deployment_check import PromptCachingDeploymentCheck
from litellm.types.router import RetryPolicy, UpdateRouterConfig
from tests.unit.proxy.fake_config_table import section_locked_transactions
@pytest.fixture(autouse=True)
@ -431,6 +432,7 @@ async def test_config_update_persists_and_reads_back_retry_policy(monkeypatch):
prisma_client = MagicMock()
prisma_client.db.litellm_config = fake_table
prisma_client.writer_db = prisma_client.db
prisma_client.tx = section_locked_transactions(fake_table)
async def _apply_router_settings(*args, **kwargs):
await proxy_server.proxy_config._add_router_settings_from_db_config(

View file

@ -741,7 +741,7 @@ describe("ModelHubTable", () => {
await user.click(screen.getByRole("button", { name: "Next" }));
await user.click(screen.getByRole("button", { name: "Save Publication List" }));
expect(networking.makeMCPPublicCall).toHaveBeenCalledWith("test-token", []);
expect(networking.makeMCPPublicCall).toHaveBeenCalledWith("test-token", [], []);
expect(manageVisibility).toBeDisabled();
await act(async () => refresh.reject(new Error("Unable to reload the publication list")));
expect(manageVisibility).toBeDisabled();

View file

@ -52,9 +52,11 @@ describe("UsefulLinksManagement", () => {
await user.click(screen.getByRole("button", { name: /add link/i }));
await waitFor(() =>
expect(mockedUpdateUsefulLinksCall).toHaveBeenCalledWith("token", {
Docs: { url: "https://docs.example.com", index: 0 },
}),
expect(mockedUpdateUsefulLinksCall).toHaveBeenCalledWith(
"token",
{ Docs: { url: "https://docs.example.com", index: 0 } },
{},
),
);
expect(await screen.findByText("Docs")).toBeInTheDocument();
@ -62,6 +64,33 @@ describe("UsefulLinksManagement", () => {
expect(mockedNotifications.success).toHaveBeenCalledWith("Link added successfully");
});
it("should send the links it last saved as the starting point of the next save", async () => {
const user = userEvent.setup();
render(<UsefulLinksManagement accessToken="token" userRole="Admin" />);
const displayNameInput = await screen.findByPlaceholderText("Friendly name");
const urlInput = screen.getByPlaceholderText("https://example.com");
fireEvent.change(displayNameInput, { target: { value: "Docs" } });
fireEvent.change(urlInput, { target: { value: "https://docs.example.com" } });
await user.click(screen.getByRole("button", { name: /add link/i }));
expect(await screen.findByText("Docs")).toBeInTheDocument();
fireEvent.change(displayNameInput, { target: { value: "Status" } });
fireEvent.change(urlInput, { target: { value: "https://status.example.com" } });
await user.click(screen.getByRole("button", { name: /add link/i }));
await waitFor(() =>
expect(mockedUpdateUsefulLinksCall).toHaveBeenLastCalledWith(
"token",
{
Docs: { url: "https://docs.example.com", index: 0 },
Status: { url: "https://status.example.com", index: 1 },
},
{ Docs: { url: "https://docs.example.com", index: 0 } },
),
);
});
it("should rearrange links and save the new order", async () => {
const user = userEvent.setup();
mockedGetPublicModelHubInfo.mockResolvedValue({
@ -87,11 +116,19 @@ describe("UsefulLinksManagement", () => {
await user.click(screen.getByRole("button", { name: /save order/i }));
await waitFor(() =>
expect(mockedUpdateUsefulLinksCall).toHaveBeenCalledWith("token", {
"Second Link": { url: "https://second.example.com", index: 0 },
"First Link": { url: "https://first.example.com", index: 1 },
"Third Link": { url: "https://third.example.com", index: 2 },
}),
expect(mockedUpdateUsefulLinksCall).toHaveBeenCalledWith(
"token",
{
"Second Link": { url: "https://second.example.com", index: 0 },
"First Link": { url: "https://first.example.com", index: 1 },
"Third Link": { url: "https://third.example.com", index: 2 },
},
{
"First Link": "https://first.example.com",
"Second Link": "https://second.example.com",
"Third Link": "https://third.example.com",
},
),
);
expect(mockedNotifications.success).toHaveBeenCalledWith("Link order saved successfully");
@ -155,9 +192,11 @@ describe("UsefulLinksManagement", () => {
await user.click(screen.getByRole("button", { name: /save/i }));
await waitFor(() =>
expect(mockedUpdateUsefulLinksCall).toHaveBeenCalledWith("token", {
"Updated Link": { url: "https://test.example.com", index: 0 },
}),
expect(mockedUpdateUsefulLinksCall).toHaveBeenCalledWith(
"token",
{ "Updated Link": { url: "https://test.example.com", index: 0 } },
{ "Test Link": "https://test.example.com" },
),
);
expect(mockedNotifications.success).toHaveBeenCalledWith("Link updated successfully");

View file

@ -27,6 +27,7 @@ const UsefulLinksManagement: React.FC<UsefulLinksManagementProps> = ({ accessTok
const [isExpanded, setIsExpanded] = useState(true);
const [isRearranging, setIsRearranging] = useState(false);
const [originalLinksOrder, setOriginalLinksOrder] = useState<Link[]>([]);
const [savedLinks, setSavedLinks] = useState<Record<string, string | { url: string; index: number }>>({});
const fetchUsefulLinks = async () => {
if (!accessToken) return;
@ -36,6 +37,7 @@ const UsefulLinksManagement: React.FC<UsefulLinksManagementProps> = ({ accessTok
if (response && response.useful_links) {
const usefulLinks = response.useful_links || {};
setSavedLinks(usefulLinks);
// Convert object to array of links with ids
// Handle both old format (Dict[str, str]) and new format (Dict[str, {url, index}])
@ -98,7 +100,8 @@ const UsefulLinksManagement: React.FC<UsefulLinksManagementProps> = ({ accessTok
};
});
await updateUsefulLinksCall(accessToken, linksObject);
await updateUsefulLinksCall(accessToken, linksObject, savedLinks);
setSavedLinks(linksObject);
return true;
} catch (error) {

View file

@ -131,7 +131,7 @@ describe("MakeAgentPublicForm", () => {
});
await waitFor(() => {
expect(mockMakeAgentsPublicCall).toHaveBeenCalledWith("test-token", ["agent-1", "agent-2"]);
expect(mockMakeAgentsPublicCall).toHaveBeenCalledWith("test-token", ["agent-1", "agent-2"], ["agent-2"]);
expect(mockProps.onSuccess).toHaveBeenCalled();
expect(mockProps.onClose).toHaveBeenCalled();
});
@ -276,6 +276,19 @@ describe("MakeAgentPublicForm", () => {
expect(selectAllCheckbox).toBePartiallyChecked();
});
it("sends the agents public when the modal opened next to the edited selection", async () => {
mockMakeAgentsPublicCall.mockResolvedValueOnce({});
render(<MakeAgentPublicForm {...mockProps} />);
const [, agent1Checkbox, agent2Checkbox] = screen.getAllByRole("checkbox");
fireEvent.click(agent1Checkbox);
fireEvent.click(agent2Checkbox);
fireEvent.click(screen.getByRole("button", { name: "Next" }));
fireEvent.click(screen.getByRole("button", { name: "Make Public" }));
await waitFor(() => expect(mockMakeAgentsPublicCall).toHaveBeenCalledWith("test-token", ["agent-1"], ["agent-2"]));
});
it("should display skills overflow text when agent has more than 3 skills", () => {
const agentWithManySkills = {
...mockProps.agentHubData[0],
@ -326,7 +339,7 @@ describe("MakeAgentPublicForm", () => {
// Should handle error and show error notification
await waitFor(() => {
expect(mockMakeAgentsPublicCall).toHaveBeenCalledWith("test-token", ["agent-2"]);
expect(mockMakeAgentsPublicCall).toHaveBeenCalledWith("test-token", ["agent-2"], ["agent-2"]);
});
// Should not call onSuccess or onClose on error

View file

@ -28,11 +28,13 @@ const MakeAgentPublicForm: React.FC<MakeAgentPublicFormProps> = ({
}) => {
const [currentStep, setCurrentStep] = useState(0);
const [selectedAgents, setSelectedAgents] = useState<Set<string>>(new Set());
const [preselectedAgents, setPreselectedAgents] = useState<Set<string>>(new Set());
const [loading, setLoading] = useState(false);
const handleClose = () => {
setCurrentStep(0);
setSelectedAgents(new Set());
setPreselectedAgents(new Set());
onClose();
};
@ -80,6 +82,7 @@ const MakeAgentPublicForm: React.FC<MakeAgentPublicFormProps> = ({
.map((agent) => agent.agent_id || agent.name);
setSelectedAgents(new Set(alreadyPublicAgents));
setPreselectedAgents(new Set(alreadyPublicAgents));
}
}, [visible, agentHubData]);
@ -94,7 +97,7 @@ const MakeAgentPublicForm: React.FC<MakeAgentPublicFormProps> = ({
const agentIdsToMakePublic = Array.from(selectedAgents);
// Make batch API call for all agents
await makeAgentsPublicCall(accessToken, agentIdsToMakePublic);
await makeAgentsPublicCall(accessToken, agentIdsToMakePublic, Array.from(preselectedAgents));
toast.success(`Successfully made ${agentIdsToMakePublic.length} agent(s) public!`);
handleClose();

View file

@ -160,7 +160,7 @@ describe("MakeMCPPublicForm", () => {
});
await waitFor(() => {
expect(mockMakeMCPPublicCall).toHaveBeenCalledWith("test-token", ["server-1", "server-2"]);
expect(mockMakeMCPPublicCall).toHaveBeenCalledWith("test-token", ["server-1", "server-2"], ["server-2"]);
expect(mockProps.onSuccess).toHaveBeenCalled();
expect(mockProps.onClose).toHaveBeenCalled();
});
@ -202,7 +202,7 @@ describe("MakeMCPPublicForm", () => {
fireEvent.click(screen.getByRole("button", { name: "Next" }));
fireEvent.click(screen.getByRole("button", { name: "Save Publication List" }));
await waitFor(() => expect(mockMakeMCPPublicCall).toHaveBeenCalledWith("test-token", []));
await waitFor(() => expect(mockMakeMCPPublicCall).toHaveBeenCalledWith("test-token", [], ["server-2"]));
expect(mockProps.onSuccess).toHaveBeenCalled();
});
@ -310,7 +310,7 @@ describe("MakeMCPPublicForm", () => {
fireEvent.click(nextButton);
fireEvent.click(screen.getByRole("button", { name: "Save Publication List" }));
await waitFor(() => expect(mockMakeMCPPublicCall).toHaveBeenCalledWith("test-token", []));
await waitFor(() => expect(mockMakeMCPPublicCall).toHaveBeenCalledWith("test-token", [], []));
expect(mockProps.onSuccess).toHaveBeenCalled();
});
@ -385,6 +385,19 @@ describe("MakeMCPPublicForm", () => {
expect(selectAllCheckbox).toBePartiallyChecked();
});
it("sends the servers public when the modal opened next to the edited selection", async () => {
mockMakeMCPPublicCall.mockResolvedValueOnce({});
render(<MakeMCPPublicForm {...mockProps} />);
const [, server1Checkbox, server2Checkbox] = screen.getAllByRole("checkbox");
fireEvent.click(server1Checkbox);
fireEvent.click(server2Checkbox);
fireEvent.click(screen.getByRole("button", { name: "Next" }));
fireEvent.click(screen.getByRole("button", { name: "Save Publication List" }));
await waitFor(() => expect(mockMakeMCPPublicCall).toHaveBeenCalledWith("test-token", ["server-1"], ["server-2"]));
});
it("should display tools overflow text when server has more than 3 tools", () => {
const serverWithManyTools = {
...mockProps.mcpHubData[0],
@ -429,7 +442,7 @@ describe("MakeMCPPublicForm", () => {
// Should handle error and show error notification
await waitFor(() => {
expect(mockMakeMCPPublicCall).toHaveBeenCalledWith("test-token", ["server-2"]);
expect(mockMakeMCPPublicCall).toHaveBeenCalledWith("test-token", ["server-2"], ["server-2"]);
});
expect(toast.fromError).toHaveBeenCalledWith(error);

View file

@ -32,6 +32,7 @@ interface MakeMCPPublicFormProps {
interface PublicationSelection {
readonly catalog: MCPServerData[];
readonly previousServerIds: ReadonlySet<string>;
readonly serverIds: Set<string>;
}
@ -46,6 +47,7 @@ const MakeMCPPublicForm: React.FC<MakeMCPPublicFormProps> = ({
const [selection, setSelection] = useState<PublicationSelection | null>(null);
const [loading, setLoading] = useState(false);
const selectedServers = selection?.serverIds ?? new Set<string>();
const previousServers: ReadonlySet<string> = selection?.previousServerIds ?? new Set<string>();
const hasPublicationMetadata = mcpHubData.every((server) => typeof server.mcp_info?.is_public_explicit === "boolean");
const canManagePublication = hasPublicationMetadata && selection?.catalog === mcpHubData;
const publicationYaml = [
@ -82,15 +84,15 @@ const MakeMCPPublicForm: React.FC<MakeMCPPublicFormProps> = ({
} else {
newSelection.delete(serverId);
}
setSelection({ catalog: mcpHubData, serverIds: newSelection });
setSelection({ catalog: mcpHubData, previousServerIds: previousServers, serverIds: newSelection });
};
const handleSelectAll = (checked: boolean) => {
if (checked) {
const allServerIds = mcpHubData.map((server) => server.server_id);
setSelection({ catalog: mcpHubData, serverIds: new Set(allServerIds) });
setSelection({ catalog: mcpHubData, previousServerIds: previousServers, serverIds: new Set(allServerIds) });
} else {
setSelection({ catalog: mcpHubData, serverIds: new Set() });
setSelection({ catalog: mcpHubData, previousServerIds: previousServers, serverIds: new Set() });
}
};
@ -102,7 +104,11 @@ const MakeMCPPublicForm: React.FC<MakeMCPPublicFormProps> = ({
const publicServerIds = mcpHubData
.filter((server) => server.mcp_info.is_public_explicit === true)
.map((server) => server.server_id);
setSelection({ catalog: mcpHubData, serverIds: new Set(publicServerIds) });
setSelection({
catalog: mcpHubData,
previousServerIds: new Set(publicServerIds),
serverIds: new Set(publicServerIds),
});
setCurrentStep(0);
}, [visible, mcpHubData, hasPublicationMetadata]);
@ -113,7 +119,7 @@ const MakeMCPPublicForm: React.FC<MakeMCPPublicFormProps> = ({
const serverIdsToMakePublic = Array.from(selectedServers);
// Make batch API call for all servers
await makeMCPPublicCall(accessToken, serverIdsToMakePublic);
await makeMCPPublicCall(accessToken, serverIdsToMakePublic, Array.from(previousServers));
toast.success("MCP Hub publication list updated");
handleClose();

View file

@ -170,7 +170,11 @@ describe("MakeModelPublicForm", () => {
});
await waitFor(() => {
expect(mockMakeModelGroupPublic).toHaveBeenCalledWith("test-token", ["gpt-4", "gpt-3.5-turbo"]);
expect(mockMakeModelGroupPublic).toHaveBeenCalledWith(
"test-token",
["gpt-4", "gpt-3.5-turbo"],
["gpt-3.5-turbo"],
);
expect(mockProps.onSuccess).toHaveBeenCalled();
expect(mockProps.onClose).toHaveBeenCalled();
});
@ -315,6 +319,21 @@ describe("MakeModelPublicForm", () => {
expect(selectAllCheckbox).toBePartiallyChecked();
});
it("sends the model groups public when the modal opened next to the edited selection", async () => {
mockMakeModelGroupPublic.mockResolvedValueOnce({});
render(<MakeModelPublicForm {...mockProps} />);
const [, gpt4Checkbox, gpt35Checkbox] = screen.getAllByRole("checkbox");
fireEvent.click(gpt4Checkbox);
fireEvent.click(gpt35Checkbox);
fireEvent.click(screen.getByRole("button", { name: "Next" }));
fireEvent.click(screen.getByRole("button", { name: "Make Public" }));
await waitFor(() =>
expect(mockMakeModelGroupPublic).toHaveBeenCalledWith("test-token", ["gpt-4"], ["gpt-3.5-turbo"]),
);
});
it("should display model badges and information", () => {
render(<MakeModelPublicForm {...mockProps} />);
@ -364,7 +383,7 @@ describe("MakeModelPublicForm", () => {
// Should handle error and show error notification
await waitFor(() => {
expect(mockMakeModelGroupPublic).toHaveBeenCalledWith("test-token", ["gpt-3.5-turbo"]);
expect(mockMakeModelGroupPublic).toHaveBeenCalledWith("test-token", ["gpt-3.5-turbo"], ["gpt-3.5-turbo"]);
});
// Should not call onSuccess or onClose on error

View file

@ -47,12 +47,14 @@ const MakeModelPublicForm: React.FC<MakeModelPublicFormProps> = ({
}) => {
const [currentStep, setCurrentStep] = useState(0);
const [selectedModels, setSelectedModels] = useState<Set<string>>(new Set());
const [preselectedModels, setPreselectedModels] = useState<Set<string>>(new Set());
const [filteredData, setFilteredData] = useState<ModelGroupInfo[]>([]);
const [loading, setLoading] = useState(false);
const handleClose = () => {
setCurrentStep(0);
setSelectedModels(new Set());
setPreselectedModels(new Set());
setFilteredData([]);
onClose();
};
@ -108,6 +110,7 @@ const MakeModelPublicForm: React.FC<MakeModelPublicFormProps> = ({
.map((model) => model.model_group);
setSelectedModels(new Set(alreadyPublicModels));
setPreselectedModels(new Set(alreadyPublicModels));
}
}, [visible, modelHubData]);
@ -120,7 +123,7 @@ const MakeModelPublicForm: React.FC<MakeModelPublicFormProps> = ({
setLoading(true);
try {
const modelGroupsToMakePublic = Array.from(selectedModels);
await makeModelGroupPublic(accessToken, modelGroupsToMakePublic);
await makeModelGroupPublic(accessToken, modelGroupsToMakePublic, Array.from(preselectedModels));
toast.success(`Successfully made ${modelGroupsToMakePublic.length} model group(s) public!`);
handleClose();

View file

@ -1225,3 +1225,33 @@ describe("searchToolQueryCall", () => {
await expect(Networking.searchToolQueryCall("token", "exa-search-2", "litellm")).rejects.toThrow(errorMessage);
});
});
describe("AI Hub publication calls", () => {
const originalFetch = global.fetch;
afterEach(() => {
global.fetch = originalFetch;
});
it.each([
{
send: () => Networking.makeAgentsPublicCall("token", ["agent-1"], ["agent-2"]),
body: { agent_ids: ["agent-1"], previous_agent_ids: ["agent-2"] },
},
{
send: () => Networking.makeMCPPublicCall("token", ["server-1"], ["server-2"]),
body: { mcp_server_ids: ["server-1"], previous_mcp_server_ids: ["server-2"] },
},
{
send: () => Networking.makeModelGroupPublic("token", ["gpt-4"], ["gpt-3.5-turbo"]),
body: { model_groups: ["gpt-4"], previous_model_groups: ["gpt-3.5-turbo"] },
},
])("sends the selected list with the list it started from: $body", async ({ send, body }) => {
const mockFetch = vi.fn().mockResolvedValue(new Response("{}", { status: 200 }));
global.fetch = mockFetch;
await send();
expect(JSON.parse(String(mockFetch.mock.calls.at(-1)?.[1]?.body))).toEqual(body);
});
});

View file

@ -552,7 +552,11 @@ registerAuthHeaderNameGetter(getGlobalLitellmHeaderName);
registerAuthTokenGetter(() => decodeToken(getCookie("token"))?.key ?? null);
registerErrorHandler(handleError);
export const makeModelGroupPublic = async (accessToken: string, modelGroups: string[]) => {
export const makeModelGroupPublic = async (
accessToken: string,
modelGroups: string[],
previousModelGroups: string[],
) => {
const url = proxyBaseUrl ? `${proxyBaseUrl}/model_group/make_public` : `/model_group/make_public`;
const response = await fetch(url, {
method: "POST",
@ -562,6 +566,7 @@ export const makeModelGroupPublic = async (accessToken: string, modelGroups: str
},
body: JSON.stringify({
model_groups: modelGroups,
previous_model_groups: previousModelGroups,
}),
});
return response.json();
@ -1864,11 +1869,12 @@ export const deleteAllowedIP = async (accessToken: string, ip: string) => {
export const updateUsefulLinksCall = async (
accessToken: string,
useful_links: Record<string, string | { url: string; index: number }>,
previous_useful_links: Record<string, string | { url: string; index: number }>,
) => {
try {
return await apiClient.post(`/model_hub/update_useful_links`, {
accessToken,
body: { useful_links: useful_links },
body: { useful_links, previous_useful_links },
});
} catch (error) {
console.error("Failed to create key:", error);
@ -5868,7 +5874,7 @@ export const deleteAgentCall = async (accessToken: string, agentId: string) => {
}
};
export const makeAgentsPublicCall = async (accessToken: string, agentIds: string[]) => {
export const makeAgentsPublicCall = async (accessToken: string, agentIds: string[], previousAgentIds: string[]) => {
try {
const url = proxyBaseUrl ? `${proxyBaseUrl}/v1/agents/make_public` : `/v1/agents/make_public`;
@ -5880,6 +5886,7 @@ export const makeAgentsPublicCall = async (accessToken: string, agentIds: string
},
body: JSON.stringify({
agent_ids: agentIds,
previous_agent_ids: previousAgentIds,
}),
});
@ -5897,7 +5904,11 @@ export const makeAgentsPublicCall = async (accessToken: string, agentIds: string
}
};
export const makeMCPPublicCall = async (accessToken: string, mcpServerIds: string[]) => {
export const makeMCPPublicCall = async (
accessToken: string,
mcpServerIds: string[],
previousMcpServerIds: string[],
) => {
try {
const url = proxyBaseUrl ? `${proxyBaseUrl}/v1/mcp/make_public` : `/v1/mcp/make_public`;
@ -5909,6 +5920,7 @@ export const makeMCPPublicCall = async (accessToken: string, mcpServerIds: strin
},
body: JSON.stringify({
mcp_server_ids: mcpServerIds,
previous_mcp_server_ids: previousMcpServerIds,
}),
});

View file

@ -38289,11 +38289,21 @@ export interface components {
MakeAgentsPublicRequest: {
/** Agent Ids */
agent_ids: string[];
/**
* Previous Agent Ids
* @description The public agent list the caller started from. When set, only the agents added or removed relative to it change, so agents another admin published or unpublished meanwhile keep that change. When omitted, agent_ids replaces the stored list.
*/
previous_agent_ids?: string[] | null;
};
/** MakeMCPServersPublicRequest */
MakeMCPServersPublicRequest: {
/** Mcp Server Ids */
mcp_server_ids: string[];
/**
* Previous Mcp Server Ids
* @description The public MCP server list the caller started from. When set, only the servers added or removed relative to it change, so servers another admin published or unpublished meanwhile keep that change. When omitted, mcp_server_ids replaces the stored list.
*/
previous_mcp_server_ids?: string[] | null;
};
/** ManagedAgentIdentityStatus */
ManagedAgentIdentityStatus: {
@ -49051,6 +49061,11 @@ export interface components {
* @description List of model group names to make public
*/
model_groups: string[];
/**
* Previous Model Groups
* @description The public model group list the caller started from. When set, only the model groups added or removed relative to it change, so model groups another admin published or unpublished meanwhile keep that change. When omitted, model_groups replaces the stored list.
*/
previous_model_groups?: string[] | null;
};
/**
* UpdateRouterConfig
@ -49280,6 +49295,15 @@ export interface components {
};
/** UpdateUsefulLinksRequest */
UpdateUsefulLinksRequest: {
/**
* Previous Useful Links
* @description The useful links the caller started from. When set, only the links added, changed or removed relative to it change, so links another admin edited meanwhile keep that edit. When omitted, useful_links replaces the stored links.
*/
previous_useful_links?: {
[key: string]: string | {
[key: string]: unknown;
};
} | null;
/** Useful Links */
useful_links: {
[key: string]: string | {