Skip to content

fix: stop Agent retries on refusal-only replies - #13829

Draft
wang1299 wants to merge 1 commit into
deepset-ai:mainfrom
wang1299:codex/fix-agent-refusal-termination
Draft

wang1299 wants to merge 1 commit into
deepset-ai:mainfrom
wang1299:codex/fix-agent-refusal-termination

Conversation

@wang1299

Copy link
Copy Markdown

Related Issues

Proposed Changes

An Agent with tools treats a completed refusal-only model reply as an empty recoverable response and requests more replies until its step limit. Recognize non-empty string refusal metadata as the existing content_filter outcome, retaining the original refusal and provider metadata.

This also lets StructuredOutputHook store None without retrying a refusal. Tool-call replies, ordinary empty-reply recovery and length precedence remain intact; on-exit hooks can still request deliberate recovery. Refusals without tools now report content_filter instead of text, covered by the upgrade note.

How did you test it?

  • Regression selection before the fix: 10 failed, 12 passed; focused selection afterward: 27 passed.
  • Selected Agent/hook/tool/retrieval suites: 1,600 passed, 11 skipped; selected generator/pipeline suites: 354 passed.
  • 63 additional local scenarios passed, including a real OpenAI SDK/loopback HTTP matrix for both APIs, sync/async and JSON/SSE. No live external-model or billing verification.
  • In-scope pre-commit hooks, Ruff, codespell, release-note check, mypy on the three changed Python files, and wheel/sdist builds passed. Python 3.11 syntax parsing passed; runtime tests used Python 3.12.14 in an isolated Hatch environment.

The full upstream test/type suite, other runtime versions, Linux and production load were not verified.

Notes for the reviewer

Reusing content_filter avoids adding an exit-reason value and matches the existing blocked/refused-response path. Feedback on this choice is welcome. The Issue assignment request is not maintainer acceptance.

This implementation was generated with an AI coding assistant, tested locally and independently reviewed by a read-only AI agent. It is submitted as a Draft for review; no personal human-review attestation is claimed.

@vercel

vercel Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

@wang1299 is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Nov 20, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added topic:tests P1 High priority, add to the next sprint labels Nov 20, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High priority, add to the next sprint topic:tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent repeats refusal-only replies until max_agent_steps when tools are configured

2 participants