Skip to content

Improve stream id isolation in stream utilities#683

Open
matdev83 wants to merge 1 commit intodevfrom
codex/fix-cross-message-data-leaks-t2y3t2
Open

Improve stream id isolation in stream utilities#683
matdev83 wants to merge 1 commit intodevfrom
codex/fix-cross-message-data-leaks-t2y3t2

Conversation

@matdev83
Copy link
Owner

@matdev83 matdev83 commented Nov 7, 2025

Summary

  • update get_stream_id to prefer request-level metadata and maintain per-key identifiers when no explicit stream id is provided
  • clean up fallback stream mappings on completion so concurrent sessions do not share buffers
  • add regression tests covering request-id isolation and fallback cleanup behaviour

Testing

  • python -m pytest tests/unit/core/services/streaming/test_stream_utils.py -vv

Codex Task

@cursor
Copy link

cursor bot commented Nov 7, 2025

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on December 5.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@coderabbitai
Copy link

coderabbitai bot commented Nov 7, 2025

Warning

Rate limit exceeded

@matdev83 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 25 minutes and 46 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between c03159e and 851ed37.

📒 Files selected for processing (2)
  • src/core/services/streaming/stream_utils.py (1 hunks)
  • tests/unit/core/services/streaming/test_stream_utils.py (1 hunks)
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/fix-cross-message-data-leaks-t2y3t2

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 and usage tips.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +92 to +96
if content.is_done or content.is_cancellation:
with _fallback_lock:
fallback_key = _reverse_stream_keys.pop(stream_id, None)
if fallback_key is not None:
_active_stream_ids.pop(fallback_key, None)

Choose a reason for hiding this comment

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

P1 Badge Clean stale fallback stream mapping when real id arrives

When a stream starts without stream_id, this function stores a generated UUID in _active_stream_ids and _reverse_stream_keys. If later chunks include an explicit stream_id or request_id, the loop above returns that explicit value, but the cleanup here uses the new identifier to pop the reverse map. The original UUID entry is never removed, so future streams that only carry the same session metadata will reuse the stale UUID and share buffers, and the dictionaries leak entries indefinitely. Consider removing or updating the fallback mapping whenever the resolved stream_id differs from the recorded fallback value.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant