Skip to content

fix(core): request/response events' stream discrimination.#525

Merged
samchon merged 1 commit intomainfrom
feat/event
Jan 28, 2026
Merged

fix(core): request/response events' stream discrimination.#525
samchon merged 1 commit intomainfrom
feat/event

Conversation

@samchon
Copy link
Member

@samchon samchon commented Jan 28, 2026

This pull request refactors how request and response events are typed and constructed in the Agentica core package, improving type safety and clarity for streaming and non-streaming OpenAI chat completion events. The main changes introduce discriminated union types for events, update factory functions to leverage these types, and simplify event handling logic throughout the codebase.

Event Type System Improvements

  • Refactored AgenticaRequestEvent and AgenticaResponseEvent from interfaces to discriminated union types, with distinct types for streaming and non-streaming events, making event handling more type-safe and explicit. [1] [2]

Factory Function Updates

  • Updated createRequestEvent and createResponseEvent to use generic parameters that enforce the correct body and completion types depending on the stream flag, aligning with the new event type definitions. [1] [2] [3]

Request/Response Handling Logic

  • Modified request creation in getChatCompletionFunction to explicitly set the stream property and use the correct body type for each event.
  • Refactored response event construction to use the new discriminated union types, replacing the previous nested response property with top-level stream, body, and completion properties. [1] [2]

Test Code Adaptation

  • Updated test logic to use the new event properties (event.stream and event.completion), ensuring compatibility with the refactored event types.

@samchon samchon requested a review from sunrabbit123 January 28, 2026 07:28
@samchon samchon self-assigned this Jan 28, 2026
@samchon samchon added the documentation Improvements or additions to documentation label Jan 28, 2026
Copilot AI review requested due to automatic review settings January 28, 2026 07:28
@samchon samchon added the enhancement New feature or request label Jan 28, 2026
@samchon samchon added this to WrtnLabs Jan 28, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 28, 2026

Open in StackBlitz

@agentica/benchmark

npm i https://pkg.pr.new/wrtnlabs/agentica/@agentica/benchmark@525

@agentica/chat

npm i https://pkg.pr.new/wrtnlabs/agentica/@agentica/chat@525

agentica

npm i https://pkg.pr.new/wrtnlabs/agentica@525

@agentica/core

npm i https://pkg.pr.new/wrtnlabs/agentica/@agentica/core@525

create-agentica

npm i https://pkg.pr.new/wrtnlabs/agentica/create-agentica@525

@agentica/rpc

npm i https://pkg.pr.new/wrtnlabs/agentica/@agentica/rpc@525

@agentica/vector-selector

npm i https://pkg.pr.new/wrtnlabs/agentica/@agentica/vector-selector@525

commit: ba4eca0

@samchon samchon merged commit 41b953d into main Jan 28, 2026
19 checks passed
@samchon samchon deleted the feat/event branch January 28, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants