diff --git a/agentflow/core/llm/client_factory.py b/agentflow/core/llm/client_factory.py index 35cdfb3..5fb8329 100644 --- a/agentflow/core/llm/client_factory.py +++ b/agentflow/core/llm/client_factory.py @@ -72,9 +72,7 @@ def detect_provider(model: str, use_vertex_ai: bool = False) -> str: return "openai" -def resolve_provider_and_model( - model: str, use_vertex_ai: bool = False -) -> tuple[str, str]: +def resolve_provider_and_model(model: str, use_vertex_ai: bool = False) -> tuple[str, str]: """Resolve a model string into a concrete ``(provider, model)`` pair. Unlike :func:`detect_provider`, this also returns the model name that should diff --git a/tests/conftest.py b/tests/conftest.py index 1aa85f8..54c8b8f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -34,6 +34,13 @@ def setup_test_environment(): # Set dummy Google API key for tests os.environ.setdefault("GEMINI_API_KEY", "dummy-gemini-key-for-testing-only") + # Vertex AI selection must NOT be inherited from a developer's .env / shell. + # Agent() reads GOOGLE_GENAI_USE_VERTEXAI as the default for use_vertex_ai, so + # an ambient "true" would make provider auto-detection resolve to "google" for + # every model and break deterministic unit tests. Force it off for the suite; + # tests that exercise Vertex pass use_vertex_ai=True explicitly. + os.environ.pop("GOOGLE_GENAI_USE_VERTEXAI", None) + # Keep tests compatible while core graph transitions from # Node(name, func, publisher) to Node(name, func). Node.__init__ = _compat_node_init diff --git a/tests/normal_tests/test_custom_state_comprehensive.py b/tests/normal_tests/test_custom_state_comprehensive.py index 8d523c4..bb8c01f 100644 --- a/tests/normal_tests/test_custom_state_comprehensive.py +++ b/tests/normal_tests/test_custom_state_comprehensive.py @@ -6,8 +6,6 @@ from dataclasses import dataclass, field from typing import Any -from dotenv import load_dotenv - from agentflow.storage.checkpointer import InMemoryCheckpointer from agentflow.core.graph import StateGraph from agentflow.core.state.agent_state import AgentState @@ -15,9 +13,6 @@ from agentflow.utils.converter import convert_messages -load_dotenv() - - @dataclass class TestCustomState(AgentState): """Test state with various field types."""