fix: improve ACP type check and restore comment accuracy

- Use isinstance() with try/except import for CopilotACPClient check
  in _to_async_client instead of fragile __class__.__name__ string check
- Restore accurate comment: GPT-5.x models *require* (not 'often require')
  the Responses API on OpenAI/OpenRouter; ACP is the exception, not a
  softening of the requirement
- Add inline comment explaining the ACP exclusion rationale
This commit is contained in:
Teknium 2026-04-13 16:06:22 -07:00 committed by Teknium
parent 8680f61f8b
commit b27eaaa4db
2 changed files with 11 additions and 5 deletions

View file

@ -1223,8 +1223,12 @@ def _to_async_client(sync_client, model: str):
return AsyncCodexAuxiliaryClient(sync_client), model return AsyncCodexAuxiliaryClient(sync_client), model
if isinstance(sync_client, AnthropicAuxiliaryClient): if isinstance(sync_client, AnthropicAuxiliaryClient):
return AsyncAnthropicAuxiliaryClient(sync_client), model return AsyncAnthropicAuxiliaryClient(sync_client), model
if sync_client.__class__.__name__ == "CopilotACPClient": try:
return sync_client, model from agent.copilot_acp_client import CopilotACPClient
if isinstance(sync_client, CopilotACPClient):
return sync_client, model
except ImportError:
pass
async_kwargs = { async_kwargs = {
"api_key": sync_client.api_key, "api_key": sync_client.api_key,

View file

@ -705,10 +705,12 @@ class AIAgent:
except Exception: except Exception:
pass pass
# GPT-5.x models often require the Responses API path — they are # GPT-5.x models require the Responses API path — they are rejected
# rejected on /v1/chat/completions by both OpenAI and OpenRouter. # on /v1/chat/completions by both OpenAI and OpenRouter. Also
# Also auto-upgrade for direct OpenAI URLs (api.openai.com) since # auto-upgrade for direct OpenAI URLs (api.openai.com) since all
# newer tool-calling models prefer Responses there. # newer tool-calling models prefer Responses there.
# ACP runtimes are excluded: CopilotACPClient handles its own
# routing and does not implement the Responses API surface.
if ( if (
self.api_mode == "chat_completions" self.api_mode == "chat_completions"
and self.provider != "copilot-acp" and self.provider != "copilot-acp"