Skip to content

[WRONG BRANCH] fix(responses): bound orphan call reordering work - #319

Closed
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-cpu-exhaustion-due-to-quadratic-reordering
Closed

[WRONG BRANCH] fix(responses): bound orphan call reordering work#319
luvs01 wants to merge 1 commit into
mainfrom
codex/fix-cpu-exhaustion-due-to-quadratic-reordering

Conversation

@luvs01

@luvs01 luvs01 commented Aug 19, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Repair an availability regression where orphaned-tool-call synthesis triggered a recursive reordering pass that scanned and sorted request-controlled arrays with includes/indexOf, allowing admitted Requests to cause superlinear CPU and deep recursion.
  • Keep the intended behavior of emitting synthetic placeholder outputs for stateless Responses providers while bounding the CPU work done during request construction.

Description

  • Replace the recursive remainder-scan reorder with an indexed, iterative reordering pass that builds a Map of output indexes and emits matched outputs by keyed lookup instead of batchKeys.includes/batchKeys.indexOf lookups. The new algorithm tracks emitted indexes with a Set to avoid repeated work and eliminates the recursive call path. (changed: src/adapters/openai-responses.ts)
  • Move the output-index mapping into the reordering routine so the algorithm runs in linear time over the repaired array and uses constant-time map/set operations for membership and ordering.
  • Preserve existing semantics for parallel call batches and synthetic key handling so outputs remain ordered by their originating call batch while avoiding request-controlled superlinear scans.
  • Add a regression test that constructs 2,000 separated dangling calls to verify the reordering finishes without recursive reprocessing and that synthetic outputs are emitted in the expected places. (added: tests/responses-stateless-dangling-call-repair.test.ts)

Testing

  • Ran ./node_modules/.bin/bun test tests/responses-stateless-dangling-call-repair.test.ts which passed all 9 tests in that file.
  • Ran bun x tsc --noEmit (typecheck) which completed successfully.
  • Ran PATH="$PWD/node_modules/.bin:$PATH" bun run privacy:scan which reported Privacy scan passed.
  • Attempted a broader bun run test of the whole suite but stopped after the focused adapter coverage because unrelated integration/concurrency tests timed out or failed; the targeted adapter tests and typecheck that validate this change passed.

Codex Task

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: fb3b4dbc-dc08-44be-b0ad-38338e9db475


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Aug 19, 2026
@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot changed the title fix(responses): bound orphan call reordering work [WRONG BRANCH] fix(responses): bound orphan call reordering work Aug 19, 2026
@github-actions

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request is being kept as a draft automatically. Once every issue above is resolved, it will be marked ready for review again.

@github-actions
github-actions Bot marked this pull request as draft August 19, 2026 09:45
@luvs01 luvs01 closed this Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant