Skip to content

refactor: extract Responses lifecycle to open-sse/utils/stream/responsesLifecycle.ts (Issue #3594) - #3926

Closed
oyi77 wants to merge 3 commits into
diegosouzapw:release/v3.8.28from
oyi77:pr/stream-responses-lifecycle
Closed

oyi77 wants to merge 3 commits into
diegosouzapw:release/v3.8.28from
oyi77:pr/stream-responses-lifecycle

Conversation

@oyi77

@oyi77 oyi77 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Part of modularization effort (Issue #3594).

Extracts OpenAI Responses API lifecycle handling from the monolithic open-sse/utils/stream.ts into a dedicated module.

Changes:

  • New file: open-sse/utils/stream/responsesLifecycle.ts (203 lines)
  • Exports: normalizeResponsesSseIds, markPendingRequestCleared, pushUniqueResponsesOutputItems, backfillResponsesCompletedOutput, stripResponsesLifecycleEcho

Testing: No behavior change. Existing stream tests pass.

Follow-up PRs will extract: types (#3917), utils (#3918), errors (#3919), textualToolCalls (#3920), sseFormatters (#3923), openaiChunks (#3924), claudeLifecycle (#3925), and streamCore.

@oyi77
oyi77 requested a review from diegosouzapw as a code owner June 15, 2026 20:27

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new utility file open-sse/utils/stream/responsesLifecycle.ts to handle OpenAI Responses API stream lifecycle events, including ID normalization, backfilling completed outputs, and stripping request echoes to prevent oversized SSE events. The review feedback highlights two main issues: first, there are unused imports (convertOpenAIToResponsesToolCall and uuidv4) that should be removed; second, according to the repository style guide, adding production code in open-sse/ requires corresponding unit tests to be added in the tests/ directory.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +1 to +5
import { convertOpenAIToResponsesToolCall } from "../handlers/responseTranslator.ts";
import { v4 as uuidv4 } from "uuid";

import { stringifyIdValue } from "./utils.ts";
import { JsonRecord } from "./types.ts";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The imports 'convertOpenAIToResponsesToolCall' and 'uuidv4' are not used anywhere in this file. Removing unused imports keeps the codebase clean and prevents potential linter or build errors.

Suggested change
import { convertOpenAIToResponsesToolCall } from "../handlers/responseTranslator.ts";
import { v4 as uuidv4 } from "uuid";
import { stringifyIdValue } from "./utils.ts";
import { JsonRecord } from "./types.ts";
import { stringifyIdValue } from "./utils.ts";
import { JsonRecord } from "./types.ts";

@@ -0,0 +1,203 @@
import { convertOpenAIToResponsesToolCall } from "../handlers/responseTranslator.ts";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

According to the Repository Style Guide (Rule 9), changing production code in 'open-sse/' requires including corresponding tests. Please add unit tests for the newly extracted Responses lifecycle utility functions in the 'tests/' directory.

References
  1. Always include tests when changing production code (src/, open-sse/, electron/, bin/).

@diegosouzapw
diegosouzapw changed the base branch from release/v3.8.26 to release/v3.8.27 June 16, 2026 06:19
oyi77 added 2 commits June 16, 2026 16:12
…sesLifecycle.ts

Part of Issue diegosouzapw#3594 modularization. Extracted OpenAI Responses API lifecycle handling from the monolithic stream.ts.

Exports:
- normalizeResponsesSseIds, markPendingRequestCleared
- pushUniqueResponsesOutputItems, backfillResponsesCompletedOutput
- stripResponsesLifecycleEcho
@oyi77
oyi77 force-pushed the pr/stream-responses-lifecycle branch from d606740 to 4ac62a4 Compare June 16, 2026 09:12
@diegosouzapw
diegosouzapw changed the base branch from release/v3.8.27 to release/v3.8.28 June 17, 2026 08:20
@diegosouzapw

Copy link
Copy Markdown
Owner

Thanks, @oyi77 🙏. These stream extractions are currently additive — the new modules under open-sse/utils/stream/ aren't wired into stream.ts yet, so they don't change runtime behavior on their own. Rather than land the decomposition in fragments, we're going to fold the stream split into the single coordinated modularization pass (Issue #3594) after the quality-gate work lands, so the extraction and the rewiring get sequenced together and verified lossless in one go. Closing for now — purely sequencing, not a reflection on the work; input welcome on #3594 once the plan is up.

@oyi77
oyi77 deleted the pr/stream-responses-lifecycle branch August 7, 2026 21:09
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