From d6ef3c5d4d2d49c2e0ffa64f748f9c317d9cd2ff Mon Sep 17 00:00:00 2001 From: Jiaxu Liu Date: Mon, 23 Mar 2026 14:46:25 +0000 Subject: [PATCH] fix: raise explicit error when gh token is missing in CopilotClient Replace the 'copilot' fallback string with a RuntimeError so users get a clear message instead of a cryptic auth failure from the API. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tradingagents/llm_clients/copilot_client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tradingagents/llm_clients/copilot_client.py b/tradingagents/llm_clients/copilot_client.py index 221032c3..66bfba25 100644 --- a/tradingagents/llm_clients/copilot_client.py +++ b/tradingagents/llm_clients/copilot_client.py @@ -132,12 +132,16 @@ class CopilotClient(BaseLLMClient): def get_llm(self) -> Any: """Return configured ChatOpenAI instance pointed at the Copilot API.""" token = _get_github_token() + if not token: + raise RuntimeError( + "No GitHub token found. Run `gh auth login` to authenticate." + ) copilot_url = _get_copilot_api_url() llm_kwargs = { "model": self.model, "base_url": copilot_url, - "api_key": token or "copilot", + "api_key": token, "default_headers": dict(_COPILOT_HEADERS), }