Skip to content

Fix #134: ModuleNotFoundError: No module named 'agents'#144

Open
JiwaniZakir wants to merge 1 commit intoAIDC-AI:mainfrom
JiwaniZakir:fix/134-modulenotfounderror-no-module-named-agen
Open

Fix #134: ModuleNotFoundError: No module named 'agents'#144
JiwaniZakir wants to merge 1 commit intoAIDC-AI:mainfrom
JiwaniZakir:fix/134-modulenotfounderror-no-module-named-agen

Conversation

@JiwaniZakir
Copy link
Copy Markdown

Closes #134

Defers the ImportError for the missing/wrong agents package from module-load time to call time, preventing ComfyUI from failing to load the entire plugin on startup.

In backend/agent_factory.py, the top-level raise ImportError(...) inside the except block is replaced with a _AGENTS_AVAILABLE = False sentinel. The set_default_openai_api and set_tracing_disabled calls are guarded behind if _AGENTS_AVAILABLE:, and create_agent() now raises the actionable error message only when actually invoked. In backend/service/debug_agent.py, the bare imports of agents.items.ItemHelpers and agents.run.Runner are wrapped in a try/except ImportError that sets both to None, so the module can be imported without a functioning agents package.

  • backend/agent_factory.py: _AGENTS_AVAILABLE sentinel, create_agent() guard
  • backend/service/debug_agent.py: ItemHelpers, Runner graceful fallback

Verified by installing only the legacy RL agents package (without openai-agents) and confirming ComfyUI loads the plugin successfully, with the error surfaced only upon invoking the debug workflow feature.


This PR was created with AI assistance (Claude). The changes were reviewed by quality gates and a critic model before submission.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ModuleNotFoundError: No module named 'agents'

2 participants