Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/fast_agent/core/direct_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from fast_agent.core import Core
from fast_agent.core.exceptions import AgentConfigError, ModelConfigError
from fast_agent.core.logging.logger import get_logger
from fast_agent.core.model_resolution import resolve_model_spec
from fast_agent.core.model_resolution import HARDCODED_DEFAULT_MODEL, resolve_model_spec
from fast_agent.core.validation import get_dependencies_groups
from fast_agent.event_progress import ProgressAction
from fast_agent.interfaces import (
Expand Down Expand Up @@ -82,8 +82,6 @@ async def __call__(
) -> AgentDict: ...


HARDCODED_DEFAULT_MODEL = "gpt-5-mini.low"


def get_model_factory(
context,
Expand Down
2 changes: 2 additions & 0 deletions src/fast_agent/core/model_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import os
from typing import Any

HARDCODED_DEFAULT_MODEL = "gpt-5-mini.low"


def resolve_model_spec(
context: Any,
Expand Down
4 changes: 2 additions & 2 deletions src/fast_agent/mcp/mcp_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from fast_agent.context_dependent import ContextDependent
from fast_agent.core.exceptions import ServerSessionTerminatedError
from fast_agent.core.logging.logger import get_logger
from fast_agent.core.model_resolution import resolve_model_spec
from fast_agent.core.model_resolution import HARDCODED_DEFAULT_MODEL, resolve_model_spec
from fast_agent.event_progress import ProgressAction
from fast_agent.mcp.common import SEP, create_namespaced_name, is_namespaced_name
from fast_agent.mcp.gen_client import gen_client
Expand Down Expand Up @@ -357,7 +357,7 @@ def session_factory(read_stream, write_stream, read_timeout, **kwargs):
self.context,
model=self.config.model,
cli_model=cli_model_override,
fallback_to_hardcoded=False,
hardcoded_default=HARDCODED_DEFAULT_MODEL,
)
if model_source:
logger.info(
Expand Down
19 changes: 15 additions & 4 deletions src/fast_agent/mcp/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from fast_agent.agents.agent_types import AgentConfig
from fast_agent.agents.llm_agent import LlmAgent
from fast_agent.core.logging.logger import get_logger
from fast_agent.core.model_resolution import HARDCODED_DEFAULT_MODEL, resolve_model_spec
from fast_agent.interfaces import FastAgentLLMProtocol
from fast_agent.llm.sampling_converter import SamplingConverter
from fast_agent.mcp.helpers.server_config_helpers import get_server_config
Expand Down Expand Up @@ -106,6 +107,7 @@ async def sample(

model: str | None = None
api_key: str | None = None
app_context: Any | None = None
try:
# Extract model from server config using type-safe helper
server_config = get_server_config(context)
Expand Down Expand Up @@ -144,11 +146,20 @@ async def sample(
# Fall back to system default model
if model is None:
try:
if app_context and app_context.config and app_context.config.default_model:
model = app_context.config.default_model
logger.debug(f"Using system default model for sampling: {model}")
cli_model_override = None
if app_context and app_context.config:
cli_model_override = getattr(
app_context.config, "cli_model_override", None
)
model, model_source = resolve_model_spec(
app_context,
cli_model=cli_model_override,
hardcoded_default=HARDCODED_DEFAULT_MODEL,
)
if model:
logger.debug(f"Using {model_source} model for sampling: {model}")
except Exception as e:
logger.debug(f"Could not get system default model: {e}")
logger.debug(f"Could not resolve default model for sampling: {e}")

if model is None:
raise ValueError(
Expand Down
Loading