Bird
0
0

Find the bug in this async agent code:

medium📝 Debug Q7 of 15
Agentic AI - Production Agent Architecture
Find the bug in this async agent code:
import asyncio

async def agent():
    await asyncio.sleep(1)
    return 'done'

result = agent()
print(result)
Aagent() should not return a value
BMissing await when calling agent()
Casyncio.sleep cannot be awaited
Dprint cannot print async results
Step-by-Step Solution
Solution:
  1. Step 1: Check async function call

    Calling agent() returns a coroutine, which must be awaited or run.
  2. Step 2: Identify missing await

    Code prints coroutine object instead of result because await is missing.
  3. Final Answer:

    Missing await when calling agent() -> Option B
  4. Quick Check:

    Await async calls to get results [OK]
Quick Trick: Always await async function calls to get results [OK]
Common Mistakes:
  • Not awaiting async calls
  • Thinking asyncio.sleep can't be awaited
  • Believing async functions can't return values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes