Skip to content

fix: Fix "text" Agent exit condition#11665

Merged
sjrl merged 2 commits into
mainfrom
fix-agent-exit-condition-text
Jun 17, 2026
Merged

fix: Fix "text" Agent exit condition#11665
sjrl merged 2 commits into
mainfrom
fix-agent-exit-condition-text

Conversation

@sjrl

@sjrl sjrl commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Related Issues

  • fixes issue in AI agent used in platform

Proposed Changes:

Fixed the Agent exiting prematurely under the default exit_conditions=["text"]. The agent now only stops when the last message is an assistant message with non-empty text (or when no tool invoker is configured). Previously, if the LLM produced an invalid tool call that was discarded, the resulting assistant message with empty text and no tool calls would trigger an exit, preventing the agent from recovering. The agent now continues looping so the model can recover on the next iteration.

How did you test it?

Added new tests

Notes for the reviewer

cc @tstadel

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I have documented my code.
  • I have added a release note file, following the contributors guidelines.
  • I have run pre-commit hooks and fixed any issue.

@sjrl sjrl requested a review from a team as a code owner June 17, 2026 13:35
@sjrl sjrl requested review from davidsbatista and removed request for a team June 17, 2026 13:35
@vercel

vercel Bot commented Jun 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
haystack-docs Ignored Ignored Jun 17, 2026 1:35pm

Request Review

@sjrl sjrl self-assigned this Jun 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/agents
  agent.py
  haystack/components/tools
  tool_invoker.py
Project Total  

This report was generated by python-coverage-comment-action

@claude

claude Bot commented Jun 17, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@davidsbatista davidsbatista left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good 👍🏽

@sjrl sjrl merged commit c9a22a9 into main Jun 17, 2026
26 checks passed
@sjrl sjrl deleted the fix-agent-exit-condition-text branch June 17, 2026 14:26

@tstadel tstadel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing!

bogdankostic pushed a commit that referenced this pull request Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants