[cross-feature coupling] model_routes imports 6 private functions from llm_core internals #703

Closed
opened 2026-06-02 23:56:00 +02:00 by sleepy · 1 comment
Owner

AGENTS.md rule: Features communicate through narrow, typed interfaces. Never import another feature's internals directly.

routes/model_routes.py directly imports private internals from src.llm_core:

from src.llm_core import _detect_provider, ANTHROPIC_MODELS       # line 17
from src.llm_core import _normalize_anthropic_url, _build_anthropic_headers, _build_anthropic_payload  # line 228
from src.llm_core import _build_ollama_payload                     # line 236
from src.llm_core import _uses_max_completion_tokens               # line 245

These are all underscore-prefixed (private) functions. model_routes.py should call through the public API (llm_call, llm_call_async, stream_llm) or the public functions in endpoint_resolver.py.

Additionally, model_routes.py re-implements 4 helper functions that already exist in llm_core.py and endpoint_resolver.py:

  • _anthropic_api_root (line 25) — duplicate of endpoint_resolver._anthropic_api_root (line 110) and llm_core._anthropic_api_root concept
  • _ollama_api_root (line 34) — duplicate of endpoint_resolver._ollama_api_root (line 119)
  • _provider_headers (line 59) — duplicate of endpoint_resolver.build_headers (line 157) and llm_core._provider_headers (line 229)
  • _models_url (line 48) — duplicate of endpoint_resolver.build_models_url (line 145)

Fix: Remove duplicated helpers from model_routes.py and import the public versions from endpoint_resolver.py. Expose any needed internal functions through a proper public interface in llm_core.

**AGENTS.md rule:** Features communicate through narrow, typed interfaces. Never import another feature's internals directly. `routes/model_routes.py` directly imports private internals from `src.llm_core`: ```python from src.llm_core import _detect_provider, ANTHROPIC_MODELS # line 17 from src.llm_core import _normalize_anthropic_url, _build_anthropic_headers, _build_anthropic_payload # line 228 from src.llm_core import _build_ollama_payload # line 236 from src.llm_core import _uses_max_completion_tokens # line 245 ``` These are all underscore-prefixed (private) functions. `model_routes.py` should call through the public API (`llm_call`, `llm_call_async`, `stream_llm`) or the public functions in `endpoint_resolver.py`. Additionally, `model_routes.py` re-implements 4 helper functions that already exist in `llm_core.py` and `endpoint_resolver.py`: - `_anthropic_api_root` (line 25) — duplicate of `endpoint_resolver._anthropic_api_root` (line 110) and `llm_core._anthropic_api_root` concept - `_ollama_api_root` (line 34) — duplicate of `endpoint_resolver._ollama_api_root` (line 119) - `_provider_headers` (line 59) — duplicate of `endpoint_resolver.build_headers` (line 157) and `llm_core._provider_headers` (line 229) - `_models_url` (line 48) — duplicate of `endpoint_resolver.build_models_url` (line 145) **Fix:** Remove duplicated helpers from `model_routes.py` and import the public versions from `endpoint_resolver.py`. Expose any needed internal functions through a proper public interface in `llm_core`.
Author
Owner

Fixed via PR #874 — removed 4 duplicated helpers from model_routes.py, using public API from endpoint_resolver.

Fixed via PR #874 — removed 4 duplicated helpers from model_routes.py, using public API from endpoint_resolver.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sleepy/odysseus#703
No description provided.