Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️ refactor: Use Error Content Part Instead Of Throwing Error for Agents #6262

Merged
merged 1 commit into from
Mar 9, 2025

Conversation

danny-avila
Copy link
Owner

Summary

I refactored the agent error handling workflow to push an error content part instead of throwing errors during execution. This change guarantees that error messages are encapsulated within a structured content part and excluded from subsequent message payloads for smoother processing and display.

  • Updated the agent client in api/server/controllers/agents/client.js to append an error content part with a formatted message instead of throwing an error.
  • Modified the message formatting in api/app/clients/prompts/formatMessages.js to skip any parts marked as ERROR.
  • Added a comprehensive test in api/app/clients/prompts/formatAgentMessages.spec.js to verify that error parts are excluded from the final AIMessage content.
  • Adjusted the error rendering in client/src/components/Chat/Messages/Content/Part.tsx to display the error message from the ERROR property when available.

Testing:

  • Ran the updated unit tests to confirm that error messages are handled as content parts and are omitted from formatted outputs.
  • Simulated agent error scenarios to ensure the correct error message is pushed and rendered without causing unintended interruptions.

Checklist:

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented complex areas of my code as needed
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective
  • Local unit tests pass with my changes
  • Any dependent changes have been merged and published in downstream modules

… agent run, exclude from subsequent payloads
@danny-avila danny-avila merged commit d6ab769 into main Mar 9, 2025
7 checks passed
@danny-avila danny-avila deleted the fix/agent-error-keep-parts branch March 9, 2025 22:06
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.

1 participant