Skip to content

Lesson 5 of 9 · 5 min read

One Loop, Many Providers: The Adapter Layer

Providers agree on the mechanism of tool calling and disagree on the wire: where the system prompt goes, whether tool calls are fields or content blocks, where tool results are placed and how they are matched to calls, how stop reasons are spelled, whether parallel calls are allowed and how strict schema enforcement is requested. A harness that lets those differences into the loop has provider-shaped bugs everywhere. The alternative is one neutral set of types (message, tool call, tool result, completion) that the loop, the tracer, the budgets and the tests use, and an adapter per provider that converts at the boundary. The adapter is small, it is where every provider-specific trap lives, and it is tested with recorded fixtures and a round-trip property rather than with live calls.

Premium lessonReviewed By the AIAgentInterviews editorial team
Get full Premium access · $25

All 19 topics with every worked answer, all lessons and courses, the full practice bank, and anything new that appears during your access.

6 months · One payment · No auto-renewal

Practise it as an interviewer asks it

Course lessons that teach this

Related lessons