Skip to content

feat: Update error raised by Agent if a runtime error occurs#10573

Draft
sjrl wants to merge 3 commits intomainfrom
update-error-message-agent
Draft

feat: Update error raised by Agent if a runtime error occurs#10573
sjrl wants to merge 3 commits intomainfrom
update-error-message-agent

Conversation

@sjrl
Copy link
Contributor

@sjrl sjrl commented Feb 12, 2026

Related Issues

  • fixes #issue-number

Proposed Changes:

cc @c-bonucci

This updates the error creation in Agent when a error occurs in the underlying chat_generator or tool_invoker by creating a new PipelineRuntimeError object that is raised from the one caused by a failing chat generator or tool invoker.

By doing this we are able to provide relevant information to end-users to inspect the error object and determine that the error came from/belongs to the Agent component within a pipeline. By inspecting the attributes component_name and component_type of the PipelineRuntimeError object users can now see that they resolve to component_name="name of agent in pipeline" and component_type=haystack.components.agents.agent.Agent whereas before they would have resolved to chat_generator and haystack.components.generators.chat.openai.OpenAIChatGenerator (or whatever generator they passed).

Also the error message is updated. Previously it would have been

The following component failed to run:
Component name: 'chat_generator'
Component type: 'OpenAIChatGenerator'
Error: Error code: 404 - {'error': {'message': 'The model `gpt-4.2-mini` does not exist or you do not have access to it.', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}

and now it will be

The following component failed to run:
Component name: 'agent'
Component type: 'Agent'
Error: The following component failed to run:
Component name: 'chat_generator'
Component type: 'OpenAIChatGenerator'
Error: Error code: 404 - {'error': {'message': 'The model `gpt-4.2-mini` does not exist or you do not have access to it.', 'type': 'invalid_request_error', 'param': None, 'code': 'model_not_found'}}

How did you test it?

Notes for the reviewer

I'm open to further tweaking the error message to better convey that an internal component within Agent failed. So the above message is not set in stone.

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.

@vercel
Copy link

vercel bot commented Feb 12, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
haystack-docs Ignored Ignored Feb 12, 2026 10:34am

Request Review

Copy link
Member

@tstadel tstadel left a comment

Choose a reason for hiding this comment

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

That would fully fix the platform visualization. No further platform changes needed.

@sjrl sjrl self-assigned this Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants