Skip to content

Self-improving AI Employees for everyone

Merge pull request #51 from zeenie-ai/perf/boot-delay-fixes

zeenie.ai09d3612f6b5b
diff --cc server/services/ai.py
index 264211c9,8b53bf0b..6dcad852
--- a/server/services/ai.py
+++ b/server/services/ai.py
@@@ -33,15 -33,14 +33,15 @@@ from typing import Awaitable, Dict, Any
from langchain_core.messages import BaseMessage # eager: type hint for _run_agent_loop
import json
- # Eager imports — both are tiny and read on every chat/agent execution
- # path. ``openai`` is the canonical SDK whose typed exception hierarchy
- # (``BadRequestError`` / ``AuthenticationError`` / ``RateLimitError`` / …)
- # is the contract this module dispatches on; ``NodeUserError`` is the
- # framework's "user-correctable, no-traceback" sentinel used to surface
- # those typed errors cleanly through ``BaseNode.execute()``.
- import openai
+ # ``NodeUserError`` is the framework's "user-correctable, no-traceback"
+ # sentinel used to surface typed SDK errors cleanly through
+ # ``BaseNode.execute()``. The ``openai`` SDK itself is imported
+ # function-locally in ``execute_agent`` / ``execute_chat_agent`` (its
+ # only consumers here, via ``except openai.OpenAIError``) — a top-level
+ # import cost seconds of boot time and re-created the eager-LLM-SDK
+ # anti-pattern (docs-internal/performance.md).
from services.plugin import NodeUserError
+from services.tool_identity import DuplicateToolNameError, ensure_unique_tool_names
if TYPE_CHECKING:
from langchain_openai import ChatOpenAI # noqa: F401