fix: add anthropic api key check before using token counter (#3628)

This commit is contained in:
cthomas
2025-07-29 14:42:49 -07:00
committed by GitHub
parent 17f23a23d9
commit f3ab6bb550

View File

@@ -1298,7 +1298,7 @@ class Agent(BaseAgent):
)
async def get_context_window_async(self) -> ContextWindowOverview:
if os.getenv("LETTA_ENVIRONMENT") == "PRODUCTION":
if os.getenv("LETTA_ENVIRONMENT") == "PRODUCTION" and os.getenv("ANTHROPIC_API_KEY"):
return await self.get_context_window_from_anthropic_async()
return await self.get_context_window_from_tiktoken_async()