0
0
Agentic AIml~10 mins

Parallel tool execution in Agentic AI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to run two tools in parallel using asyncio.

Agentic AI
import asyncio

async def run_tools():
    task1 = asyncio.create_task(tool1())
    task2 = asyncio.create_task([1])
    await task1
    await task2
Drag options to blanks, or click blank then click option'
Atool2()
Btool1()
Ctool3()
Dtool4()
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same tool function twice.
Not calling the function (missing parentheses).
Awaiting tasks before creating both.
2fill in blank
medium

Complete the code to gather results from two parallel tool executions.

Agentic AI
import asyncio

async def run_tools():
    results = await asyncio.gather(tool1(), [1])
    return results
Drag options to blanks, or click blank then click option'
Atool1()
Btool3()
Ctool2()
Dtool4()
Attempts:
3 left
💡 Hint
Common Mistakes
Repeating the same tool twice.
Forgetting parentheses to call the function.
Using a non-async function.
3fill in blank
hard

Fix the error in the code to run tools in parallel and collect results.

Agentic AI
import asyncio

async def run_tools():
    tasks = [tool1, [1]]
    results = await asyncio.gather(*[task() for task in tasks])
    return results
Drag options to blanks, or click blank then click option'
Atool2
Btool3()
Ctool4
Dtool1
Attempts:
3 left
💡 Hint
Common Mistakes
Including parentheses in the tasks list.
Mixing function calls and references.
Passing non-callable objects.
4fill in blank
hard

Fill both blanks to create tasks for three tools and run them concurrently.

Agentic AI
import asyncio

async def run_tools():
    task1 = asyncio.create_task(tool1())
    task2 = asyncio.create_task([1])
    task3 = asyncio.create_task([2])
    await asyncio.gather(task1, task2, task3)
Drag options to blanks, or click blank then click option'
Atool2()
Btool3()
Ctool4()
Dtool1()
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same tool multiple times.
Missing parentheses in function calls.
Not awaiting all tasks together.
5fill in blank
hard

Fill all three blanks to run tools in parallel and collect their results in a dictionary.

Agentic AI
import asyncio

async def run_tools():
    results = await asyncio.gather(tool1(), [1], [2])
    return {"tool1": results[0], [3]: results[1], "tool3": results[2]}
Drag options to blanks, or click blank then click option'
Atool2()
B"tool2"
Ctool3()
D"tool1"
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect keys in the dictionary.
Forgetting parentheses in function calls.
Mixing up the order of results.