Skip to content

Commit 85cae98

Browse files
committed
fix: Enhanced Authentication Logic: Added fallback to chatgpt authentication method when no API key is provided, enabling seamless use of existing auth.json files.
1 parent dbfc830 commit 85cae98

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "a2a-acp"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
description = "A native A2A protocol server that exposes ZedACP agents over HTTP using JSON-RPC 2.0."
55
authors = [{ name = "Autonomous Developer Agent" }]
66
readme = "README.md"

src/a2a_acp/zed_agent.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,21 @@ async def initialize(self) -> dict[str, Any] | None:
338338
self._logger.info("Using API key authentication", extra={"method_id": api_key_method_id})
339339
await self.authenticate(api_key_method_id, self._api_key)
340340
elif api_key_method:
341-
raise AgentProcessError("Agent requires API key authentication but no API key provided")
341+
# Try chatgpt method as fallback when no API key is provided
342+
chatgpt_method = next((m for m in auth_methods if m.get("id") == "chatgpt"), None)
343+
if chatgpt_method:
344+
self._logger.info("Using ChatGPT authentication with existing auth.json", extra={"method_id": "chatgpt"})
345+
await self.authenticate("chatgpt")
346+
else:
347+
raise AgentProcessError("Agent requires API key authentication but no API key provided and no chatgpt method available")
342348
else:
343-
raise AgentProcessError(f"Agent requires authentication but no supported method found. Available: {[m.get('id') for m in auth_methods]}")
349+
# No API key method available, try chatgpt method if available
350+
chatgpt_method = next((m for m in auth_methods if m.get("id") == "chatgpt"), None)
351+
if chatgpt_method:
352+
self._logger.info("Using ChatGPT authentication with existing auth.json", extra={"method_id": "chatgpt"})
353+
await self.authenticate("chatgpt")
354+
else:
355+
raise AgentProcessError(f"Agent requires authentication but no supported method found. Available: {[m.get('id') for m in auth_methods]}")
344356
else:
345357
self._logger.debug("No authentication required")
346358

0 commit comments

Comments
 (0)