Intermediate
Pair results with calls by id
Tools ran concurrently and their results arrived in any order. Write pair_by_id(calls, results). calls is a list of dicts with an id. results is a list of dicts {"tool_call_id": ..., "content": ...} in arrival order.
Return a list of tool messages {"role": "tool", "tool_call_id": id, "content": content} **in the order of calls**. If a call has no result, use the content '{"error":"no result"}'.
What Check tests
- Messages follow the order of the calls
- Each message has the matching content
- Every message has role
tool - A missing result becomes an error message
Stuck? One hint at a time
The solution unlocks after your first Check. Try first: that is where the learning happens.
main.py
Sign in to run your code.
Output
Press Run to see what your program prints.