Skip to content

The agent that grows with you

fix(acp): malformed vendor model options fall back to the session default

Teknium16d201f5de03
diff --git a/agent/acp_client.py b/agent/acp_client.py
index 337f755dd6f..81169977105 100644
--- a/agent/acp_client.py
+++ b/agent/acp_client.py
@@ -496,7 +496,10 @@ class ACPClient:
_request(*selection)
else:
logger.warning("%s does not offer model %r; using the session default.", self.label, requested_model)
- except (RuntimeError, TimeoutError, OSError) as exc: # what _request raises (OSError: broken pipe)
+ # _request raises RuntimeError/TimeoutError/OSError (broken pipe); vendor ``session/new`` payload
+ # drift (e.g. a non-list ``configOptions``) raises TypeError/AttributeError in the parsers.
+ # Either way model choice degrades to the session default instead of failing the turn.
+ except (RuntimeError, TimeoutError, OSError, TypeError, AttributeError) as exc:
logger.warning("%s model selection for %r failed; continuing with the session default: %s",
self.label, requested_model, exc)
text_parts: list[str] = []
diff --git a/tests/agent/test_acp_client.py b/tests/agent/test_acp_client.py
index 1ae405204b6..ee7bbf2db6f 100644
--- a/tests/agent/test_acp_client.py
+++ b/tests/agent/test_acp_client.py
@@ -100,6 +100,14 @@ def test_errors_carry_the_subclass_label_and_early_exit_hook(tmp_path):
ACPClient(command=command, args=args, acp_cwd=str(tmp_path)).list_models(timeout_seconds=30)
+def test_malformed_vendor_model_options_fall_back_to_the_session_default(tmp_path):
+ body = _CATALOG_SERVER.replace('result = {"sessionId": "s1", "configOptions": [', 'result = {"sessionId": "s1", "configOptions": 5, "x": [')
+ command, *args = _server(tmp_path, body)
+ completion = _VendorClient(command=command, args=args, acp_cwd=str(tmp_path)).chat.completions.create(
+ model="open-model", messages=[{"role": "user", "content": "hi"}], timeout=30)
+ assert completion.choices[0].message.content == "hello"
+
+
_FROZEN_SUBCLASS_PLUGIN = '''
"""Frozen shape of an out-of-tree ACP provider built on the deprecated alias (kimchi-acp-provider)."""
import os