From fb7091ef799775ebae995cd92f932dfa3ebf4302 Mon Sep 17 00:00:00 2001 From: Mateo Wang <277851410+mateo-berri@users.noreply.github.com> Date: Sat, 16 May 2026 15:11:36 +0000 Subject: [PATCH] refactor(reasoning_effort_grid): tighten test helpers per Greptile review Two P2 nits flagged by Greptile on PR 28036: 1. _build_completion_kwargs() defaulted vertex_project to "vertex-check-481318" when VERTEX_PROJECT was unset. That value is a specific GCP project that doesn't belong to this repo, so if the env-var skip guard were ever bypassed (misconfig, direct helper call), the test would silently issue calls to a foreign project rather than failing loudly. Drop the fallback and read os.environ["VERTEX_PROJECT"] directly, mirroring how AZURE_FOUNDRY_* are handled. 2. _build_messages_kwargs() was a one-liner that returned the result of _build_completion_kwargs() unchanged -- a dead abstraction with one caller. Inline at the _call_messages call site and delete the helper. --- .../test_reasoning_effort_grid.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/llm_translation/reasoning_effort_grid/test_reasoning_effort_grid.py b/tests/llm_translation/reasoning_effort_grid/test_reasoning_effort_grid.py index a815eb861e..4f2b6f0955 100644 --- a/tests/llm_translation/reasoning_effort_grid/test_reasoning_effort_grid.py +++ b/tests/llm_translation/reasoning_effort_grid/test_reasoning_effort_grid.py @@ -65,20 +65,13 @@ def _build_completion_kwargs(model: ModelEntry, effort: str) -> Dict[str, Any]: if effort != "__omit__": kwargs["reasoning_effort"] = effort if model.model.startswith("vertex_ai/"): - kwargs["vertex_project"] = os.environ.get( - "VERTEX_PROJECT", "vertex-check-481318" - ) + kwargs["vertex_project"] = os.environ["VERTEX_PROJECT"] if model.model.startswith("azure_ai/"): kwargs["api_base"] = os.environ["AZURE_FOUNDRY_API_BASE"] kwargs["api_key"] = os.environ["AZURE_FOUNDRY_API_KEY"] return kwargs -def _build_messages_kwargs(model: ModelEntry, effort: str) -> Dict[str, Any]: - kwargs = _build_completion_kwargs(model, effort) - return kwargs - - def _converse_subbody(body: Dict[str, Any]) -> Dict[str, Any]: """Return the dict that holds thinking/output_config for a Converse wire body.""" return body.get("additionalModelRequestFields", body) @@ -185,7 +178,7 @@ async def _call_chat(model: ModelEntry, effort: str) -> Tuple[int, Optional[Exce async def _call_messages( model: ModelEntry, effort: str ) -> Tuple[int, Optional[Exception]]: - kwargs = _build_messages_kwargs(model, effort) + kwargs = _build_completion_kwargs(model, effort) try: await litellm.anthropic_messages(**kwargs) return 200, None