personal memory agent
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove unnecessary OpenAI key setup from agents.py

The OpenAI Agents SDK automatically reads OPENAI_API_KEY from the
environment on import, making the explicit set_default_openai_key()
call redundant. This removes provider-specific logic from the routing
layer, keeping agents.py provider-agnostic.

- Remove 6-line OpenAI key setup block from main_async()
- Remove related test patches from test_agents_ndjson.py
- Remove stub from agents_stub.py

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+5 -19
-1
tests/agents_stub.py
··· 75 75 agents_stub.SQLiteSession = DummySession 76 76 agents_stub.OpenAIConversationsSession = DummyConversationSession 77 77 agents_stub.TResponseInputItem = dict 78 - agents_stub.set_default_openai_key = lambda key: None 79 78 agents_run_stub.RunConfig = lambda **kwargs: SimpleNamespace(**kwargs) 80 79 agents_model_settings_stub.ModelSettings = lambda **kwargs: SimpleNamespace( 81 80 **kwargs
+5 -10
tests/test_agents_ndjson.py
··· 111 111 from think.agents import main_async 112 112 113 113 with patch("think.agents.setup_cli", return_value=mock_args): 114 - with patch("agents.set_default_openai_key"): 115 - asyncio.run(main_async()) 114 + asyncio.run(main_async()) 116 115 117 116 captured = capsys.readouterr() 118 117 lines = captured.out.strip().split("\n") ··· 169 168 from think.agents import main_async 170 169 171 170 with patch("think.agents.setup_cli", return_value=mock_args): 172 - with patch("agents.set_default_openai_key"): 173 - asyncio.run(main_async()) 171 + asyncio.run(main_async()) 174 172 175 173 captured = capsys.readouterr() 176 174 lines = [line for line in captured.out.strip().split("\n") if line] ··· 205 203 from think.agents import main_async 206 204 207 205 with patch("think.agents.setup_cli", return_value=mock_args): 208 - with patch("agents.set_default_openai_key"): 209 - asyncio.run(main_async()) 206 + asyncio.run(main_async()) 210 207 211 208 captured = capsys.readouterr() 212 209 lines = [line for line in captured.out.strip().split("\n") if line] ··· 242 239 from think.agents import main_async 243 240 244 241 with patch("think.agents.setup_cli", return_value=mock_args): 245 - with patch("agents.set_default_openai_key"): 246 - asyncio.run(main_async()) 242 + asyncio.run(main_async()) 247 243 248 244 captured = capsys.readouterr() 249 245 lines = [line for line in captured.out.strip().split("\n") if line] ··· 273 269 from think.agents import main_async 274 270 275 271 with patch("think.agents.setup_cli", return_value=mock_args): 276 - with patch("agents.set_default_openai_key"): 277 - asyncio.run(main_async()) 272 + asyncio.run(main_async()) 278 273 279 274 captured = capsys.readouterr() 280 275 lines = [line for line in captured.out.strip().split("\n") if line]
-8
think/agents.py
··· 1366 1366 name = config.get("name", "default") 1367 1367 model = config.get("model") 1368 1368 1369 - # Set OpenAI key if needed 1370 - if provider == "openai": 1371 - api_key = os.getenv("OPENAI_API_KEY", "") 1372 - if api_key: 1373 - from agents import set_default_openai_key 1374 - 1375 - set_default_openai_key(api_key) 1376 - 1377 1369 app_logger.debug(f"Processing agent: provider={provider}") 1378 1370 1379 1371 # Route to appropriate provider module