# 24.8 Integration layer or model output (/building-ai-workers/evaluating-ai-workers/integration-layer-or-model-output)

---
type: Document
title: "24.8 Integration layer or model output"
description: "How to tell a fault in the code around the model from a fault in what the model wrote, by reading the request first."
status: stable
order: 324.08
ksor:
  owner: team:panaversity
  audience:
    - public
  approval:
    by: process:panaversity
    at: 2026-11-30T00:02:23Z
chapter: '24'
part: III
expert_status: co-build
concepts: [ "24.8" ]
last_verified: '2026-11-29'
sources:
  - id: anthropic-ccdv-f-exam-guide
    title: Claude Certified Developer - Foundations Exam Guide, version 1.1, effective December 7, 2026 (read 2026-11-29)
    resource: https://cc.sj-cdn.net/instructor/6nizmqk8tpzpfjvt6qmmav7rh/public/1794946771/Claude_Certified_Developer_-_Foundations_Exam_Guide_Updated_Dec_7.pdf
  - id: anthropic-stop-reasons
    title: Stop reasons and fallback (verified 2026-11-29)
    resource: https://platform.claude.com/docs/en/build-with-claude/handling-stop-reasons
  - id: anthropic-troubleshooting-tool-use
    title: Troubleshooting tool use (verified 2026-11-29)
    resource: https://platform.claude.com/docs/en/agents-and-tools/tool-use/troubleshooting-tool-use
  - id: anthropic-ccdv-f-prep-module-2
    title: Claude Certified Developer - Foundations prep path, Module 2, Cumulative Debug Task (partner sign-in, read 2026-11-29)
    resource: https://anthropic-partners.skilljar.com/path/claude-certified-developer-foundations/production-grade-prompting-agents-tool-use/486743/scorm/3k33sihfb1tww
generated:
  at: 2026-11-30T00:02:23Z
  by: esl-rewrite/1.2.0+ksor.1
trust_tier: unverified
build_id: sha256:cc6fd9ac5f72207d4365ecbda63d87d1b64f99e05519b358a45b9f5d9bfd6f8f
dirty: true
ksor_version: 0.0.60
---

**In everyday life.** A restaurant guest gets the wrong dish. Before anyone blames the cook, the head waiter reads the order slip. If the slip says "fish" and the guest asked for chicken, the cook did the job right from a wrong slip. If the slip says "chicken" and fish came out, the fault is in the kitchen. The plate looks the same both ways. In this concept, the slip is the request your code sends, the cook is the model, and the plate is the answer.

**What you will learn.** How to tell a fault in your own code from a fault in what the model wrote. You practice it in Lab 24, Tasks 5 and 6.

- What are the two places a failure can begin?
- Is every integration fault a 400?
- How do you tell the two apart?
- What do you check in the integration layer?
- What does reading the request first cost?

**Why it matters.** A builder who blames the model changes the prompt. If the fault is in the code, the prompt change repairs nothing and can break something else.

**At work.** Ana knows INV-8303 well, because it was one of her first cases ([17.6](../connectors-and-mcp/specify-generate-verify.md)). The invoice is $900.00 over its purchase order, PO-7003 (24.2). One of the recorded runs you read in Lab 24 holds an answer about INV-8303 that Ana had marked fail earlier. The answer compares the invoice with a different purchase order.

<!-- EDITOR: Ana's mark on the INV-8303 answer is placed "earlier", in a recorded run, so that "Ana read one answer" stays true for Monday, April 12. The other option: she marks it that Monday, and the page says she read two answers. -->
<!-- OPEN: recorded output. The answer's exact words and the purchase order it names come from the lab's recorded run of the handoff fault. -->

The builder's first guess is hallucination: the model made up an order. The builder checks before saying so. The API returned status 200, and the stop reason was "finished". Then the builder reads the request the code sent. It holds the purchase order of the invoice that was extracted just before INV-8303, and not PO-7003. The model read that order and reported it correctly. The fault is in the handoff, where the extraction step passes its result to the next step. It began in the code.

<!-- OPEN: the page never names "the next step" that receives the extraction step's result, and the spec says only "the next step". It does not say which step uses `poNumber` to answer a question about INV-8303, an invoice from March. Name the step, here and in 24.3's table of test levels, once the lab's handoff fault is recorded. -->

### What are the two places a failure can begin?

The **integration layer** is all the code around the model. It builds the request, lists the tools, keeps the message history, runs the tools, and passes one step's result to the next. **Model output** is what the model wrote in reply. A failure begins in model output only when the request was right and the answer is still wrong. The exam guide asks you to isolate which of the two a failure began in.[^anthropic-ccdv-f-exam-guide]

### Is every integration fault a 400?

No. [21.9](../agent-loop-by-hand/when-the-loop-goes-wrong.md) said that integration faults show up as errors with a 400, and model faults as normal responses with wrong content. Those integration faults were the ones the API rejects. This one it accepts. The API checks the shape of a request. It cannot know that a request with a correct shape carries the wrong purchase order. So the response is a 200 with wrong content, which is exactly how a model fault looks.

The official pages give another case. A response that ends "finished" with almost no content can come from code that adds text after the tool results, or that sends a finished response again.[^anthropic-stop-reasons] From outside it looks like under-acting. It began in the integration layer.

### How do you tell the two apart?

Read in this order, and stop at the first fault you find:

1. **The status and the stop reason.** An error such as a 400 means the API rejected the request, so the fault is your code's (21.9). A "declined" stop reason is the model's own answer (21.3).
2. **The request, as it was sent.** Read the recorded request, and not the code that should have built it. Ask whether everything the answer needed is there, and whether it is right. That means the instructions, the tool list, the history, the tool results, and every value handed over from an earlier step.
3. **The output.** Only when the request was right is a wrong answer a fault in model output.

The approver answer in 24.7 went through the same three steps. The request carried line 8 with "before payment", so that fault was in model output.

A **reproduction** confirms it. A reproduction is the recorded request sent again, to watch the failure happen again. Correct the one wrong value in the request and send that too. If the answer is now right, the request was the fault.

<!-- FIGURE 24.5: Two panels side by side, titled "The same wrong answer, twice". Each panel is a row of three boxes joined by arrows that point left to right: "Your code" -> "Request" -> "Model", and then one arrow from "Model" down to a box "Answer on Ana's screen". Both panels show the label "Status 200, stop reason finished" on the arrow out of the model, and both end in the same answer box, marked with a red cross: an answer about INV-8303 that names the wrong purchase order. Left panel, headed "Integration layer": the "Request" box is edged in red and reads "INV-8303 with the purchase order of the invoice before it". The "Model" box is edged in green and reads "Reported the request correctly". A red marker sits on the arrow from "Your code" to "Request", labeled "The fault began here: the handoff". Right panel, headed "Model output": the "Request" box is edged in green and reads "INV-8303 with PO-7003, $12,000.00". The "Model" box is edged in red and reads "Answered wrongly from a right request". A red marker sits on the arrow from "Model" to "Answer", labeled "The fault began here". Under both panels, one line: "The answer cannot tell you which. Read the request." OPEN: recorded output: the wrong purchase order's number and the answer's exact words, from the lab's recorded run. -->

*Figure 24.5. The same wrong answer twice: once from a wrong request sent by the code, and once from a right request answered wrongly by the model.*

### What do you check in the integration layer?

Four layers of your own code, and then the handoff between steps. The exam's prep course has a debugging task with four planted defects, one in each of four layers. All four are in the integration layer.[^anthropic-ccdv-f-prep-module-2] Use them as a checklist before you blame the model:

| Layer | A defect there | How it looks from outside |
| --- | --- | --- |
| The tool's schema | A tool description of two words | The model picks the wrong tool |
| The streaming code | A turn saved before the stream is complete ([21.11](../agent-loop-by-hand/streaming.md)) | A half-built tool call in the history, and the API rejects the next request |
| The message history | A tool result with no turn that asked for it | The API rejects the request |
| The memory | Every earlier session put into the context | The context window fills, and the worker seems to forget |

Two of the four end in a rejected request. The other two look like the model's fault: a wrong tool, and a worker that forgets. The fix for the first is in the description. The official troubleshooting page says to tell two similar tools apart by when each should be used.[^anthropic-troubleshooting-tool-use]

Brightline adds a fifth place to check: the handoff between two steps. Of the four test levels in 24.3, this is the integration level.

### What does reading the request first cost?

It costs a little time on every failure, and it needs the request recorded with its content (24.7). It also does not prove the model right. Sometimes the request is right and the model is wrong, as with the approver answer.

**The operating rule:** read the status, then the request as sent, then the output. Blame the model only for a wrong answer to a right request.

**Do this now.** Ask your coding agent for the last request. Copy this line:

> Show me the exact request the worker sent on its last run: the instructions, the tool list and every message, with nothing summarized.

Find one value in it that an earlier step of your code produced. That value is a handoff. Say what the model would answer if it were wrong.

[^anthropic-ccdv-f-exam-guide]: Claude Certified Developer - Foundations Exam Guide, version 1.1, Anthropic.
[^anthropic-stop-reasons]: Stop reasons and fallback, Anthropic.
[^anthropic-ccdv-f-prep-module-2]: Claude Certified Developer - Foundations prep path, Module 2, Cumulative Debug Task, Anthropic.
[^anthropic-troubleshooting-tool-use]: Troubleshooting tool use, Anthropic.
