Conversation
samchon
left a comment
There was a problem hiding this comment.
Special issue by OpenRouter.
@agentica/benchmark
@agentica/chat
agentica
@agentica/core
create-agentica
@agentica/rpc
@agentica/vector-selector
commit: |
There was a problem hiding this comment.
Pull request overview
This PR enhances the robustness of the agentica core library by adding defensive handling for potentially undefined choices arrays in ChatCompletion and ChatCompletionChunk objects. It also adds a test for validation error stringification.
Changes:
- Added defensive
?? []checks and optional chaining when accessingchoicesarrays across orchestration and utility modules - Introduced explicit boolean coercion with
!!operator forchoices?.every()calls in streaming code paths - Added a new test file for validation error stringification
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/src/features/test_validation_error_stringify.ts | New test file for JsonUtil.stringifyValidateFailure functionality |
| packages/core/src/utils/ChatGptCompletionStreamingUtil.ts | Added defensive ?? [] when accessing choices in flatMap and registerContext calls |
| packages/core/src/utils/ChatGptCompletionMessageUtil.ts | Added defensive ?? [] for origin.choices and optional chaining for result.choices iteration |
| packages/core/src/orchestrate/select.ts | Added defensive checks for choices with ?? [] in loops and optional chaining in array access |
| packages/core/src/orchestrate/initialize.ts | Changed to optional chaining for choices array access |
| packages/core/src/orchestrate/describe.ts | Changed to optional chaining for choices array access |
| packages/core/src/orchestrate/cancel.ts | Added defensive ?? [] when iterating over choices |
| packages/core/src/orchestrate/call.ts | Added defensive checks, explicit boolean type annotations, and optional chaining for choices access |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This pull request introduces several updates to improve the handling of potentially undefined or missing
choicesarrays in the core orchestration and utility modules. The changes enhance robustness by ensuring that code does not fail whenchoicesisundefined, and also add a new test for validation error stringification.Robustness improvements for handling
choices:call.ts,cancel.ts, andselect.tsto use(completion.choices ?? []), preventing errors whenchoicesisundefined. [1] [2] [3] [4] [5]choices, ensuring safe access and correct behavior whenchoicesmay be absent. [1] [2] [3] [4] [5] [6] [7]Utility function enhancements:
ChatGptCompletionMessageUtil.tsandChatGptCompletionStreamingUtil.tsto usechoices ?? []and optional chaining in array operations, improving error handling and consistency. [1] [2] [3]Testing improvements:
test_validation_error_stringify.tsto verify the stringification of validation errors usingJsonUtil.stringifyValidateFailure.