Command Palette

Search for a command to run...

Hectal
Phase 7: Tools and Function Calling
LLM Engineering · Exercise 5 of 6 PreviousNext
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

  1. Messages follow the order of the calls
  2. Each message has the matching content
  3. Every message has role tool
  4. 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.