crewai - ✅(Solved) Fix [BUG] A2A client is not working in Jupyter Environments [2 pull requests, 3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
crewAIInc/crewAI#4671Fetched 2026-04-08 00:40:45
View on GitHub
Comments
3
Participants
2
Timeline
11
Reactions
0
Timeline (top)
commented ×3cross-referenced ×2closed ×1labeled ×1

RuntimeError Traceback (most recent call last) Cell In[3], line 28 18 task = Task( 19 description="Research the latest developments in quantum computing", 20 expected_output="A comprehensive research report", 21 agent=agent 22 ) 24 crew = Crew(agents=[agent], 25 tasks=[task], 26 27 verbose=True) ---> 28 result = crew.kickoff()

File ~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:743, in Crew.kickoff(self, inputs, input_files) 740 inputs = prepare_kickoff(self, inputs, input_files) 742 if self.process == Process.sequential: --> 743 result = self._run_sequential_process() 744 elif self.process == Process.hierarchical: 745 result = self._run_hierarchical_process()

File ~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:1150, in Crew._run_sequential_process(self) 1148 def _run_sequential_process(self) -> CrewOutput: 1149 """Executes tasks sequentially and returns the final output.""" -> 1150 return self._execute_tasks(self.tasks) ... 206 ) 207 except RuntimeError as e: 208 if "no running event loop" not in str(e).lower():

RuntimeError: execute_a2a_delegation() cannot be called from an async context. Use 'await aexecute_a2a_delegation()' instead.

Error Message

╭─────────────────────────────────────────── 🚀 Crew Execution Started ───────────────────────────────────────────╮ │ │ │ Crew Execution Started │ │ Name: │ │ crew │ │ ID: │ │ c25e3f10-6e86-426d-9d19-2fd04eed9064 │ │ │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────── 📋 Task Started ────────────────────────────────────────────────╮ │ │ │ Task Started │ │ Name: Research the latest developments in quantum computing │ │ ID: 2f01754c-6488-49a1-baa9-05e85482ea0a │ │ │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────── 🤖 Agent Started ────────────────────────────────────────────────╮ │ │ │ Agent: Research Coordinator │ │ │ │ Task: Research the latest developments in quantum computing │ │ │ │ IMPORTANT: You have the ability to delegate this task to remote A2A agents. │ │ │ │ <AVAILABLE_A2A_AGENTS> │ │ │ │ { │ │ "description": "A CrewAI-powered autonomous research agent capable of performing deep topic analysis and │ │ generating structured research reports from natural language queries.", │ │ "skills": [ │ │ { │ │ "description": "Performs in-depth analytical research on scientific, technical, and business topics. │ │ Produces structured research reports including insights, trends, risks, and future outlook.", │ │ "examples": [ │ │ "Research latest developments in quantum computing", │ │ "Analyze AI impact on retail pricing", │ │ "Create technology trend report", │ │ "Provide research summary on LLM adoption" │ │ ], │ │ "id": "deep_research", │ │ "name": "Deep Research Analyst", │ │ "tags": [ │ │ "research", │ │ "analysis", │ │ "technology", │ │ "ai", │ │ "market research", │ │ "trend analysis", │ │ "quantum computing", │ │ "crewAI", │ │ "llm reasoning" │ │ ] │ │ } │ │ ], │ │ "url": "http://0.0.0.0:10001/" │ │ } │ │ │ │ </AVAILABLE_A2A_AGENTS> │ │ │ │ │ │ <PREVIOUS_A2A_CONVERSATION> │ │ │ │ </PREVIOUS_A2A_CONVERSATION> │ │ │ │ │ │ │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────── ✅ Agent Final Answer ─────────────────────────────────────────────╮ │ │ │ Agent: Research Coordinator │ │ │ │ Final Answer: │ │ a2a_ids=('http://localhost:10001/.well-known/agent-card.json',) message='Research the latest developments in │ │ quantum computing' is_a2a=True │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────── 📋 Task Failure ────────────────────────────────────────────────╮ │ │ │ Task Failed │ │ Name: │ │ Research the latest developments in quantum computing │ │ Agent: │ │ Research Coordinator │ │ │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────── Crew Failure ──────────────────────────────────────────────────╮ │ │ │ Crew Execution Failed │ │ Name: │ │ crew │ │ ID: │ │ c25e3f10-6e86-426d-9d19-2fd04eed9064 │ │ │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

RuntimeError Traceback (most recent call last) Cell In[3], line 28 18 task = Task( 19 description="Research the latest developments in quantum computing", 20 expected_output="A comprehensive research report", 21 agent=agent 22 ) 24 crew = Crew(agents=[agent], 25 tasks=[task], 26 27 verbose=True) ---> 28 result = crew.kickoff()

File ~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:743, in Crew.kickoff(self, inputs, input_files) 740 inputs = prepare_kickoff(self, inputs, input_files) 742 if self.process == Process.sequential: --> 743 result = self._run_sequential_process() 744 elif self.process == Process.hierarchical: 745 result = self._run_hierarchical_process()

File ~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:1150, in Crew._run_sequential_process(self) 1148 def _run_sequential_process(self) -> CrewOutput: 1149 """Executes tasks sequentially and returns the final output.""" -> 1150 return self._execute_tasks(self.tasks) ... 206 ) 207 except RuntimeError as e: 208 if "no running event loop" not in str(e).lower():

RuntimeError: execute_a2a_delegation() cannot be called from an async context. Use 'await aexecute_a2a_delegation()

Root Cause

RuntimeError Traceback (most recent call last) Cell In[3], line 28 18 task = Task( 19 description="Research the latest developments in quantum computing", 20 expected_output="A comprehensive research report", 21 agent=agent 22 ) 24 crew = Crew(agents=[agent], 25 tasks=[task], 26 27 verbose=True) ---> 28 result = crew.kickoff()

File ~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:743, in Crew.kickoff(self, inputs, input_files) 740 inputs = prepare_kickoff(self, inputs, input_files) 742 if self.process == Process.sequential: --> 743 result = self._run_sequential_process() 744 elif self.process == Process.hierarchical: 745 result = self._run_hierarchical_process()

File ~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:1150, in Crew._run_sequential_process(self) 1148 def _run_sequential_process(self) -> CrewOutput: 1149 """Executes tasks sequentially and returns the final output.""" -> 1150 return self._execute_tasks(self.tasks) ... 206 ) 207 except RuntimeError as e: 208 if "no running event loop" not in str(e).lower():

RuntimeError: execute_a2a_delegation() cannot be called from an async context. Use 'await aexecute_a2a_delegation()' instead.

Fix Action

Fixed

PR fix notes

PR #4672: fix: handle running event loop in A2A sync wrappers (#4671)

Description (problem / solution / changelog)

fix: handle running event loop in A2A sync wrappers (#4671)

Summary

Fixes #4671execute_a2a_delegation() and fetch_agent_card() now work when called from environments with an already-running event loop (e.g. Jupyter notebooks).

Previously, execute_a2a_delegation() explicitly detected a running event loop and raised RuntimeError, making A2A delegation unusable from Jupyter. fetch_agent_card() had a similar gap where it unconditionally called asyncio.new_event_loop() + loop.run_until_complete() without checking for an existing loop first.

Both functions now detect a running loop via asyncio.get_running_loop() and, when one exists, run the async coroutine in a ThreadPoolExecutor(max_workers=1) thread — the same pattern already used in file_store._run_sync() and MCPNativeTool._run() within this codebase.

Files changed:

  • lib/crewai/src/crewai/a2a/utils/delegation.py — replaced the RuntimeError raise with the thread-based fallback
  • lib/crewai/src/crewai/a2a/utils/agent_card.py — added the same running-loop detection to fetch_agent_card()
  • Two new test files with 7 tests covering both functions, with and without a running event loop, including error propagation

Review & Testing Checklist for Human

  • Verify the except RuntimeError: pass catch on asyncio.get_running_loop() is acceptable — it's broader than the original string-matching check but matches the existing codebase pattern. Confirm no other RuntimeError can leak from get_running_loop().
  • Verify that creating the coroutine object before the try/except (so it's shared between both code paths) is safe — only one path will await it, and a coroutine can only be consumed once. If the ThreadPoolExecutor path runs, the fallback loop.run_until_complete(coro) is never reached, and vice versa.
  • Consider testing in an actual Jupyter notebook with a real A2A agent to confirm the end-to-end flow works as expected (the unit tests mock the async functions).

Notes

Changed files

  • lib/crewai/src/crewai/a2a/utils/agent_card.py (modified, +15/-3)
  • lib/crewai/src/crewai/a2a/utils/delegation.py (modified, +42/-45)
  • lib/crewai/tests/a2a/utils/test_agent_card_event_loop.py (added, +110/-0)
  • lib/crewai/tests/a2a/utils/test_delegation_event_loop.py (added, +129/-0)

PR #4675: fix(a2a): support Jupyter environments with running event loops

Description (problem / solution / changelog)

Summary

  • Use thread-based async bridge pattern when a running event loop is detected (e.g. Jupyter notebooks), instead of raising RuntimeError
  • Applied to execute_a2a_delegation(), fetch_agent_card(), and _fetch_agent_card_cached()

Closes #4671

Changed files

  • lib/crewai/src/crewai/a2a/utils/agent_card.py (modified, +21/-14)
  • lib/crewai/src/crewai/a2a/utils/delegation.py (modified, +35/-47)

Code Example

from crewai import Agent, Crew, Task
from crewai.a2a import A2AClientConfig

agent = Agent(
    role="Research Coordinator",
    goal="Coordinate research tasks efficiently",
    backstory="Expert at delegating to specialized research agents",
    llm=llm,
    a2a=A2AClientConfig(
        endpoint="http://localhost:10001/.well-known/agent-card.json",
        timeout=120,
        max_turns=10,
        #trust_remote_completion_status=True

    ),
)

task = Task(
    description="Research the latest developments in quantum computing",
    expected_output="A comprehensive research report",
    agent=agent
)

crew = Crew(agents=[agent],
            tasks=[task],

            verbose=True)
result = crew.kickoff()

---

╭─────────────────────────────────────────── 🚀 Crew Execution Started ───────────────────────────────────────────╮
│                                                                                                                 │
Crew Execution StartedName:│  crew                                                                                                           │
ID:│  c25e3f10-6e86-426d-9d19-2fd04eed9064                                                                           │
│                                                                                                                 │
│                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────── 📋 Task Started ────────────────────────────────────────────────╮
│                                                                                                                 │
Task StartedName: Research the latest developments in quantum computing                                                    │
ID: 2f01754c-6488-49a1-baa9-05e85482ea0a                                                                       │
│                                                                                                                 │
│                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─────────────────────────────────────────────── 🤖 Agent Started ────────────────────────────────────────────────╮
│                                                                                                                 │
Agent: Research Coordinator│                                                                                                                 │
Task: Research the latest developments in quantum computing                                                    │
│                                                                                                                 │
IMPORTANT: You have the ability to delegate this task to remote A2A agents.                                    
│                                                                                                                 │
<AVAILABLE_A2A_AGENTS>│                                                                                                                 │
{"description": "A CrewAI-powered autonomous research agent capable of performing deep topic analysis and     │
│  generating structured research reports from natural language queries.","skills": [{"description": "Performs in-depth analytical research on scientific, technical, and business topics.     
Produces structured research reports including insights, trends, risks, and future outlook.","examples": ["Research latest developments in quantum computing","Analyze AI impact on retail pricing","Create technology trend report","Provide research summary on LLM adoption"],"id": "deep_research","name": "Deep Research Analyst","tags": ["research","analysis","technology","ai","market research","trend analysis","quantum computing","crewAI","llm reasoning"]}],"url": "http://0.0.0.0:10001/"}│                                                                                                                 │
</AVAILABLE_A2A_AGENTS>│                                                                                                                 │
│                                                                                                                 │
<PREVIOUS_A2A_CONVERSATION>│                                                                                                                 │
</PREVIOUS_A2A_CONVERSATION>│                                                                                                                 │
│                                                                                                                 │
│                                                                                                                 │
│                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────── ✅ Agent Final Answer ─────────────────────────────────────────────╮
│                                                                                                                 │
Agent: Research Coordinator│                                                                                                                 │
Final Answer:│  a2a_ids=('http://localhost:10001/.well-known/agent-card.json',) message='Research the latest developments in│  quantum computing' is_a2a=True│                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────── 📋 Task Failure ────────────────────────────────────────────────╮
│                                                                                                                 │
Task FailedName:Research the latest developments in quantum computing                                                          │
Agent:Research Coordinator│                                                                                                                 │
│                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────── Crew Failure ──────────────────────────────────────────────────╮
│                                                                                                                 │
Crew Execution FailedName:│  crew                                                                                                           │
ID:│  c25e3f10-6e86-426d-9d19-2fd04eed9064                                                                           │
│                                                                                                                 │
│                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[3], [line 28](vscode-notebook-cell:?execution_count=3&line=28)
     18 task = Task(
     19     description="Research the latest developments in quantum computing",
     20     expected_output="A comprehensive research report",
     21     agent=agent
     22 )
     24 crew = Crew(agents=[agent],
     25             tasks=[task],
     26 
     27             verbose=True)
---> [28](vscode-notebook-cell:?execution_count=3&line=28) result = crew.kickoff()

File ~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:743, in Crew.kickoff(self, inputs, input_files)
    740 inputs = prepare_kickoff(self, inputs, input_files)
    742 if self.process == Process.sequential:
--> [743](https://file+.vscode-resource.vscode-cdn.net/home/sunil/arias/aria-ip-ingest-iq-files/tests/~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:743)     result = self._run_sequential_process()
    744 elif self.process == Process.hierarchical:
    745     result = self._run_hierarchical_process()

File ~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:1150, in Crew._run_sequential_process(self)
   1148 def _run_sequential_process(self) -> CrewOutput:
   1149     """Executes tasks sequentially and returns the final output."""
-> [1150](https://file+.vscode-resource.vscode-cdn.net/home/sunil/arias/aria-ip-ingest-iq-files/tests/~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:1150)     return self._execute_tasks(self.tasks)
...
    206     )
    207 except RuntimeError as e:
    208     if "no running event loop" not in str(e).lower():

RuntimeError: execute_a2a_delegation() cannot be called from an async context. Use 'await aexecute_a2a_delegation()
RAW_BUFFERClick to expand / collapse

Description

RuntimeError Traceback (most recent call last) Cell In[3], line 28 18 task = Task( 19 description="Research the latest developments in quantum computing", 20 expected_output="A comprehensive research report", 21 agent=agent 22 ) 24 crew = Crew(agents=[agent], 25 tasks=[task], 26 27 verbose=True) ---> 28 result = crew.kickoff()

File ~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:743, in Crew.kickoff(self, inputs, input_files) 740 inputs = prepare_kickoff(self, inputs, input_files) 742 if self.process == Process.sequential: --> 743 result = self._run_sequential_process() 744 elif self.process == Process.hierarchical: 745 result = self._run_hierarchical_process()

File ~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:1150, in Crew._run_sequential_process(self) 1148 def _run_sequential_process(self) -> CrewOutput: 1149 """Executes tasks sequentially and returns the final output.""" -> 1150 return self._execute_tasks(self.tasks) ... 206 ) 207 except RuntimeError as e: 208 if "no running event loop" not in str(e).lower():

RuntimeError: execute_a2a_delegation() cannot be called from an async context. Use 'await aexecute_a2a_delegation()' instead.

Steps to Reproduce

from crewai import Agent, Crew, Task
from crewai.a2a import A2AClientConfig

agent = Agent(
    role="Research Coordinator",
    goal="Coordinate research tasks efficiently",
    backstory="Expert at delegating to specialized research agents",
    llm=llm,
    a2a=A2AClientConfig(
        endpoint="http://localhost:10001/.well-known/agent-card.json",
        timeout=120,
        max_turns=10,
        #trust_remote_completion_status=True

    ),
)

task = Task(
    description="Research the latest developments in quantum computing",
    expected_output="A comprehensive research report",
    agent=agent
)

crew = Crew(agents=[agent],
            tasks=[task],

            verbose=True)
result = crew.kickoff()

Expected behavior

None

Screenshots/Code snippets


╭─────────────────────────────────────────── 🚀 Crew Execution Started ───────────────────────────────────────────╮
│                                                                                                                 │
│  Crew Execution Started                                                                                         │
│  Name:                                                                                                          │
│  crew                                                                                                           │
│  ID:                                                                                                            │
│  c25e3f10-6e86-426d-9d19-2fd04eed9064                                                                           │
│                                                                                                                 │
│                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────── 📋 Task Started ────────────────────────────────────────────────╮
│                                                                                                                 │
│  Task Started                                                                                                   │
│  Name: Research the latest developments in quantum computing                                                    │
│  ID: 2f01754c-6488-49a1-baa9-05e85482ea0a                                                                       │
│                                                                                                                 │
│                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─────────────────────────────────────────────── 🤖 Agent Started ────────────────────────────────────────────────╮
│                                                                                                                 │
│  Agent: Research Coordinator                                                                                    │
│                                                                                                                 │
│  Task: Research the latest developments in quantum computing                                                    │
│                                                                                                                 │
│  IMPORTANT: You have the ability to delegate this task to remote A2A agents.                                    │
│                                                                                                                 │
│  <AVAILABLE_A2A_AGENTS>                                                                                         │
│                                                                                                                 │
│  {                                                                                                              │
│    "description": "A CrewAI-powered autonomous research agent capable of performing deep topic analysis and     │
│  generating structured research reports from natural language queries.",                                        │
│    "skills": [                                                                                                  │
│      {                                                                                                          │
│        "description": "Performs in-depth analytical research on scientific, technical, and business topics.     │
│  Produces structured research reports including insights, trends, risks, and future outlook.",                  │
│        "examples": [                                                                                            │
│          "Research latest developments in quantum computing",                                                   │
│          "Analyze AI impact on retail pricing",                                                                 │
│          "Create technology trend report",                                                                      │
│          "Provide research summary on LLM adoption"                                                             │
│        ],                                                                                                       │
│        "id": "deep_research",                                                                                   │
│        "name": "Deep Research Analyst",                                                                         │
│        "tags": [                                                                                                │
│          "research",                                                                                            │
│          "analysis",                                                                                            │
│          "technology",                                                                                          │
│          "ai",                                                                                                  │
│          "market research",                                                                                     │
│          "trend analysis",                                                                                      │
│          "quantum computing",                                                                                   │
│          "crewAI",                                                                                              │
│          "llm reasoning"                                                                                        │
│        ]                                                                                                        │
│      }                                                                                                          │
│    ],                                                                                                           │
│    "url": "http://0.0.0.0:10001/"                                                                               │
│  }                                                                                                              │
│                                                                                                                 │
│  </AVAILABLE_A2A_AGENTS>                                                                                        │
│                                                                                                                 │
│                                                                                                                 │
│  <PREVIOUS_A2A_CONVERSATION>                                                                                    │
│                                                                                                                 │
│  </PREVIOUS_A2A_CONVERSATION>                                                                                   │
│                                                                                                                 │
│                                                                                                                 │
│                                                                                                                 │
│                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────── ✅ Agent Final Answer ─────────────────────────────────────────────╮
│                                                                                                                 │
│  Agent: Research Coordinator                                                                                    │
│                                                                                                                 │
│  Final Answer:                                                                                                  │
│  a2a_ids=('http://localhost:10001/.well-known/agent-card.json',) message='Research the latest developments in   │
│  quantum computing' is_a2a=True                                                                                 │
│                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────── 📋 Task Failure ────────────────────────────────────────────────╮
│                                                                                                                 │
│  Task Failed                                                                                                    │
│  Name:                                                                                                          │
│  Research the latest developments in quantum computing                                                          │
│  Agent:                                                                                                         │
│  Research Coordinator                                                                                           │
│                                                                                                                 │
│                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭───────────────────────────────────────────────── Crew Failure ──────────────────────────────────────────────────╮
│                                                                                                                 │
│  Crew Execution Failed                                                                                          │
│  Name:                                                                                                          │
│  crew                                                                                                           │
│  ID:                                                                                                            │
│  c25e3f10-6e86-426d-9d19-2fd04eed9064                                                                           │
│                                                                                                                 │
│                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[3], [line 28](vscode-notebook-cell:?execution_count=3&line=28)
     18 task = Task(
     19     description="Research the latest developments in quantum computing",
     20     expected_output="A comprehensive research report",
     21     agent=agent
     22 )
     24 crew = Crew(agents=[agent],
     25             tasks=[task],
     26 
     27             verbose=True)
---> [28](vscode-notebook-cell:?execution_count=3&line=28) result = crew.kickoff()

File ~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:743, in Crew.kickoff(self, inputs, input_files)
    740 inputs = prepare_kickoff(self, inputs, input_files)
    742 if self.process == Process.sequential:
--> [743](https://file+.vscode-resource.vscode-cdn.net/home/sunil/arias/aria-ip-ingest-iq-files/tests/~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:743)     result = self._run_sequential_process()
    744 elif self.process == Process.hierarchical:
    745     result = self._run_hierarchical_process()

File ~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:1150, in Crew._run_sequential_process(self)
   1148 def _run_sequential_process(self) -> CrewOutput:
   1149     """Executes tasks sequentially and returns the final output."""
-> [1150](https://file+.vscode-resource.vscode-cdn.net/home/sunil/arias/aria-ip-ingest-iq-files/tests/~/miniconda3/envs/crewai_3.13/lib/python3.13/site-packages/crewai/crew.py:1150)     return self._execute_tasks(self.tasks)
...
    206     )
    207 except RuntimeError as e:
    208     if "no running event loop" not in str(e).lower():

RuntimeError: execute_a2a_delegation() cannot be called from an async context. Use 'await aexecute_a2a_delegation()

Operating System

Ubuntu 22.04

Python Version

3.12

crewAI Version

1.9.3

crewAI Tools Version

None

Virtual Environment

Venv

Evidence

None

Possible Solution

None

Additional context

None

extent analysis

Fix Plan

The error message indicates that execute_a2a_delegation() cannot be called from an async context. To fix this, we need to ensure that the function is called from a non-async context or use the await keyword if it's an async function.

Here are the steps to fix the issue:

  • Check if execute_a2a_delegation() is an async function. If it is, use the await keyword when calling it.
  • If execute_a2a_delegation() is not an async function, ensure that it's not being called from an async context.

Example code:

import asyncio

# Assuming execute_a2a_delegation is an async function
async def kickoff_crew():
    # ... other code ...
    result = await execute_a2a_delegation()
    # ... other code ...

# Call the kickoff_crew function
async def main():
    await kickoff_crew()

asyncio.run(main())

Alternatively, if execute_a2a_delegation() is not an async function, you can use the following code:

import asyncio

# Assuming execute_a2a_delegation is not an async function
def kickoff_crew():
    # ... other code ...
    result = execute_a2a_delegation()
    # ... other code ...

# Call the kickoff_crew function
def main():
    kickoff_crew()

main()

Verification

To verify that the fix worked, run the code and check if the RuntimeError is resolved. You can also add print statements or logging to ensure that the execute_a2a_delegation() function is being called correctly.

Extra Tips

  • Ensure that you're using the correct version of the crewai library and that it's compatible with your Python version.
  • Check the documentation for the crewai library to see if there are any specific requirements or restrictions for using async functions.
  • If you're still experiencing issues, try to isolate the problem by creating a minimal reproducible example and seeking further assistance.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

None

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

crewai - ✅(Solved) Fix [BUG] A2A client is not working in Jupyter Environments [2 pull requests, 3 comments, 2 participants]