Skip to content

Address issues in core package #137

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Mirza-Samad-Ahmed-Baig
Copy link

This commit addresses 10 critical and minor code-level issues found in the events.ts and types.ts files within the ag-ui/typescript-sdk/packages/core package.
These fixes improve type safety, consistency, and maintainability of the core functionalities.

Detailed Changes:

events.ts:

  1. Removed redundant schema definitions: Eliminated duplicate definitions for RunStartedSchema, RunFinishedSchema, RunErrorSchema, StepStartedSchema, and
    StepFinishedSchema. This reduces redundancy and potential for inconsistencies.
  2. Fixed ToolCallResultEventSchema extension: Ensured ToolCallResultEventSchema extends BaseEventSchema. This brings consistency in event structure, ensuring
    all events inherit common properties like timestamp and rawEvent.
  3. Made messageId and role required in TextMessageChunkEventSchema: Changed messageId and role from optional to required. This improves data integrity by
    ensuring each text message chunk is properly attributed.
  4. Redefined ThinkingTextMessageContentEventSchema: Simplified its definition by directly extending BaseEventSchema and including the delta field. This makes
    the schema definition clearer and more consistent with other event schemas.
  5. Clarified StateDeltaEventSchema's delta: Added a more descriptive comment for the delta field, explicitly stating it should conform to JSON Patch (RFC
    6902). This provides better guidance on the expected data structure.

types.ts:
6. ToolMessageSchema extends BaseMessageSchema: Modified ToolMessageSchema to extend BaseMessageSchema. This eliminates code duplication and ensures
ToolMessage inherits common message properties.
7. Clarified ToolSchema's parameters: Added a comment to ToolSchema indicating that parameters should be a JSON Schema object. This provides better context
for developers using this schema.
8. Clarified RunAgentInputSchema's state and forwardedProps: Added comments to RunAgentInputSchema to clarify the arbitrary nature of state and
forwardedProps. This helps in understanding the expected data types for these flexible fields.
9. Clarified StateSchema: Added a comment to StateSchema to indicate it represents an arbitrary state object. This clarifies its permissive nature.
10. Enhanced AGUIError: Added an optional code property to the AGUIError class. This allows for more specific error categorization and handling, improving
debugging and error management within the application.

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