refactor(agents): move llm_config + prompt_caching to app/agents/shared (slice 4b)

Relocate the mutually-dependent LLM config layer and the LiteLLM prompt-caching
helper to the shared kernel as one unit, rewiring their internal cross-reference
to the shared paths. Flip 21 non-frozen importers. Re-export shims remain at
new_chat/{llm_config,prompt_caching}.py for the frozen single-agent stack
(chat_deepagent); they will be removed when that stack is retired.
This commit is contained in:
CREDO23 2026-06-04 12:41:52 +02:00
parent 8fca2753aa
commit 946f8a8c5d
23 changed files with 928 additions and 882 deletions

View file

@ -1,5 +1,5 @@
r"""Tests for ``apply_litellm_prompt_caching`` in
:mod:`app.agents.new_chat.prompt_caching`.
:mod:`app.agents.shared.prompt_caching`.
The helper replaces the legacy ``AnthropicPromptCachingMiddleware`` (which
never activated for our LiteLLM stack) with LiteLLM-native multi-provider
@ -34,8 +34,8 @@ from typing import Any
import pytest
from app.agents.new_chat.llm_config import AgentConfig
from app.agents.new_chat.prompt_caching import apply_litellm_prompt_caching
from app.agents.shared.llm_config import AgentConfig
from app.agents.shared.prompt_caching import apply_litellm_prompt_caching
pytestmark = pytest.mark.unit

View file

@ -17,7 +17,7 @@ from __future__ import annotations
import pytest
from app.agents.new_chat.chat_deepagent import _resolve_prompt_model_name
from app.agents.new_chat.llm_config import AgentConfig
from app.agents.shared.llm_config import AgentConfig
pytestmark = pytest.mark.unit

View file

@ -44,7 +44,7 @@ def patched_globals(monkeypatch: pytest.MonkeyPatch):
-2: {"id": -2, "billing_tier": "free"},
}
monkeypatch.setattr(
"app.agents.new_chat.llm_config.load_global_llm_config_by_id",
"app.agents.shared.llm_config.load_global_llm_config_by_id",
lambda cid: llm_configs.get(cid),
)

View file

@ -227,7 +227,7 @@ global_llm_configs:
def test_agent_config_from_yaml_explicit_overrides_resolver():
from app.agents.new_chat.llm_config import AgentConfig
from app.agents.shared.llm_config import AgentConfig
cfg_text_only = AgentConfig.from_yaml_config(
{
@ -256,7 +256,7 @@ def test_agent_config_from_yaml_explicit_overrides_resolver():
def test_agent_config_from_yaml_unannotated_uses_resolver():
"""Without an explicit YAML key, AgentConfig defers to the catalog
resolver for ``gpt-4o`` LiteLLM's map says supports_vision=True."""
from app.agents.new_chat.llm_config import AgentConfig
from app.agents.shared.llm_config import AgentConfig
cfg = AgentConfig.from_yaml_config(
{
@ -275,7 +275,7 @@ def test_agent_config_auto_mode_supports_image_input():
so users can keep their selection on Auto with a vision-capable
deployment somewhere in the pool. The router's own `allowed_fails`
handles non-vision deployments via fallback."""
from app.agents.new_chat.llm_config import AgentConfig
from app.agents.shared.llm_config import AgentConfig
auto = AgentConfig.from_auto_mode()
assert auto.supports_image_input is True

View file

@ -61,7 +61,7 @@ async def test_get_vision_llm_global_openrouter_sets_api_base():
return_value=cfg,
),
patch(
"app.agents.new_chat.llm_config.SanitizedChatLiteLLM",
"app.agents.shared.llm_config.SanitizedChatLiteLLM",
new=FakeSanitized,
),
):