## TL;DR

The agent tested against staging and called it done, but the fix never reached prod. Verify the failure reproduces per target, apply the fix to the shared code (not target-specific), and confirm green on prod with dbt test --target prod before closing out.

## Error

```text
agent misread the test failure: fixed staging, prod still broken
```

## Steps

1. Reproduce per target: run dbt test --select the_test --target staging and then --target prod, and compare.
   Expected: You see it green on staging, red on prod, confirming the split.

2. Check whether the agent's fix is target-gated: search for target.name conditionals or target-specific config that excludes prod.
   Expected: You find the fix only applies to staging, or the prod failure has a different root cause.

3. Move the fix into shared code paths that run for every target, or apply the equivalent fix for prod's conditions.
   Expected: The fix is target-independent.

4. Run dbt build --select the_model+ --target prod to verify end to end in prod.
   Expected: Prod green; the fix is verified where it matters.

## When to use

- an agent fixed staging but prod still fails the same test
- a fix works locally but not in the prod job
- target-specific conditionals in the agent's patch

## When not to use

- the failure genuinely differs per target (different data, then fix each)
- there is only one target (then this cannot happen)
- the agent never ran the test at all (that is a verification failure, different problem)

## Tool compatibility

- dbt --target flag to run per environment
- target.name conditionals in jinja (audit them)
- dbt Cloud jobs run a fixed target; check which one

## Variant phrasings

### agent fixed dev, CI still red
Same shape: the agent's environment is not the grading environment. Always verify in the environment that reported the failure.

### fix works on prod data in staging target
Data and target are different axes. Reproduce with prod's target settings, not just prod-like data.

## Why it happens

Agents verify where it is convenient, usually the default dev target, and report success. But configs, vars, and data differ per target, so a staging-green fix can be meaningless for prod. Verification has to happen in the failing environment.

## Edge cases

- Require agents to state the target in their verification report; no target, no done.
- Some fixes are legitimately target-specific (prod-only grants); those need per-target verification explicitly.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_hjmjkLT65nMc7tEX6snTfw
