Skip `RefineOutput` review of an output no model request produced
Stacked on #13120 (base agent/clai2-12995). Related to #12995; #13120 closes it.
Why we make these changes
A review finding on #13120 reproduced. With InputGuardrail(guard=lambda _: False) and RefineOutput() on one agent, in either order, the guardrail's refusal ended the run as a normal output. RefineOutput then started a review round, and that request carried the blocked prompt to the model, because InputGuardrail only checks the first step.
RefineOutput now reviews an output only when a model produced it. The signal is ModelResponse.model_name, which is None on a response no model produced, such as one a SkipModelRequest returned. model_id would not do: with InputGuardrail(parallel=True) the request already started, so the refusal is stamped with the model's id. The message-history cleanup that merges synthetic responses (_append_response in messages.py) uses the same model_name is None test.
New public surface
none
User-visible behavior
agent = Agent(model, capabilities=[InputGuardrail(guard=lambda _: False), RefineOutput()])
result = await agent.run('...')
# before: one model request, containing the blocked prompt
# after: no model request; result.output is the refusal
Verification
tests/harness/refine_output/test_refine_output.py::TestRefineOutput::test_does_not_review_the_refusal_of_a_blocked_prompt, both capability orders, with a sequential and aparallel=Trueguardrail. It fails without the change (4 failed) and passes with it.tests/harness/refine_output(including DBOS and Prefect), docs parity, skill examples and the append-only scenario pass. The Temporal test passes on Python 3.13.- Not reviewed locally before pushing: the three local pre-push reviews for this work were already spent on #13120.
What changes for existing users
Nothing: RefineOutput is new in #13120.
Do not merge before #13120. After #13120 lands, retarget this PR to main and merge origin/main into it.
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.