From 0a530948972b156c782c3ed193bfbfb40bb2c4ec Mon Sep 17 00:00:00 2001 From: Ayush Nangia Date: Fri, 7 Aug 2026 15:09:11 +0530 Subject: [PATCH] fix: key the pin on delegation.model as well (model arm of #80450) A delegation.model-only pin (provider inherited) took the unpinned column because pinned was keyed on override_provider alone, so the child inherited the parent chain and a mid-run failure could silently swap the pinned model. model at the call site is creds["model"] -- delegation.model config -- at both call sites, so keying on it adds no false pins. base_url-only pins already resolve to a provider override. Caught by review on the PR; two matrix tests added (model-only pin with absent and declared chains). --- tests/tools/test_delegate_fallback_matrix.py | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/tools/test_delegate_fallback_matrix.py b/tests/tools/test_delegate_fallback_matrix.py index 0b8cc028d0..a8bda5afcc 100644 --- a/tests/tools/test_delegate_fallback_matrix.py +++ b/tests/tools/test_delegate_fallback_matrix.py @@ -130,6 +130,7 @@ class TestBuildChildAgentWiring(unittest.TestCase): """End-to-end through _build_child_agent: the resolver is actually wired.""" def _spawn(self, parent, cfg, **overrides): + model = overrides.pop("model", None) with ( patch("tools.delegate_tool._load_config", return_value=cfg), patch("run_agent.AIAgent") as MockAgent, @@ -140,7 +141,7 @@ class TestBuildChildAgentWiring(unittest.TestCase): goal="matrix wiring", context=None, toolsets=None, - model=None, + model=model, max_iterations=10, parent_agent=parent, task_count=1, @@ -175,6 +176,25 @@ class TestBuildChildAgentWiring(unittest.TestCase): self.assertIn("deepseek", providers) self.assertNotIn("openrouter", providers) + def test_model_only_pin_gets_no_parent_chain(self): + """The model arm of #80450: delegation.model without delegation.provider + must not inherit the parent chain — a mid-run failure would silently + swap the pinned model.""" + kwargs = self._spawn( + _parent(list(PARENT_CHAIN)), {}, model="deepseek-chat", + ) + self.assertIsNone(kwargs["fallback_model"]) + + def test_model_only_pin_with_declared_chain_uses_declared(self): + kwargs = self._spawn( + _parent(list(PARENT_CHAIN)), + {"fallback_providers": list(DECLARED_CHAIN)}, + model="deepseek-chat", + ) + providers = {e.get("provider") for e in (kwargs["fallback_model"] or [])} + self.assertIn("deepseek", providers) + self.assertNotIn("openrouter", providers) + def test_default_inheritance_preserved(self): kwargs = self._spawn(_parent(list(PARENT_CHAIN)), {}) self.assertEqual(kwargs["fallback_model"], PARENT_CHAIN)