The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(model-metadata): cover local Ollama fallback
atakan g713982a8f89f
diff --git a/tests/agent/test_model_metadata.py b/tests/agent/test_model_metadata.pyindex a41c739127e..122063548db 100644--- a/tests/agent/test_model_metadata.py+++ b/tests/agent/test_model_metadata.py@@ -1218,6 +1218,32 @@ class TestGetModelContextLength:# The local probe MUST be called exactly oncemock_local_ctx.assert_called_once()+ @patch("agent.model_metadata.get_cached_context_length", return_value=None)+ @patch("agent.model_metadata.fetch_model_metadata", return_value={})+ @patch("agent.model_metadata._resolve_endpoint_context_length", return_value=None)+ @patch("agent.model_metadata._query_ollama_api_show", return_value=131072)+ @patch("agent.model_metadata._query_local_context_length", return_value=None)+ @patch("agent.model_metadata.is_local_endpoint", return_value=True)+ @patch("agent.model_metadata.save_context_length")+ @patch("agent.model_metadata._maybe_cache_local_context_length")+ def test_local_ollama_falls_back_to_generic_probe(+ self,+ mock_maybe_cache, mock_save,+ mock_is_local, mock_local_ctx,+ mock_ollama_show, mock_resolve_ep,+ mock_fetch, mock_cache,+ ):+ """Local Ollama falls back to the generic /api/show probe when the+ num_ctx-first local probe cannot determine a context length."""+ result = get_model_context_length(+ "my-model",+ base_url="http://localhost:11434",+ )++ assert result == 131072+ mock_local_ctx.assert_called_once()+ mock_ollama_show.assert_called_once()+@patch("agent.model_metadata.get_cached_context_length", return_value=None)@patch("agent.model_metadata.fetch_model_metadata", return_value={})@patch("agent.model_metadata._resolve_endpoint_context_length", return_value=None)