Skip to content

Conversation

@matdev83
Copy link
Owner

@matdev83 matdev83 commented Nov 7, 2025

Summary

  • add TTL-based cleanup to the JSON repair stream processor so incomplete streams do not accumulate state indefinitely
  • track last access times for each stream buffer and expose a configurable cleanup TTL
  • add a regression test that verifies stale stream state is evicted once the TTL expires

Testing

  • python -m pytest tests/unit/core/services/test_json_repair_processor.py

Codex Task

@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 26 minutes and 13 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 2f99e79.

📒 Files selected for processing (2)
  • src/core/services/streaming/json_repair_processor.py (1 hunks)
  • tests/unit/core/services/test_json_repair_processor.py (2 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-memory-leaks-and-add-tests

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 +55 to +62
async def process(self, content: StreamingContent) -> StreamingContent:
if not self._enabled:
return content

self._cleanup_stale_states()

if content.is_empty and not content.is_done:
return content

Choose a reason for hiding this comment

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

P1 Badge Update stream access time before early-returning on empty chunks

The TTL cleanup runs before checking content.is_empty and the method returns immediately when the chunk is empty without ever touching the per-stream state. As a result last_accessed is not refreshed for streams that send periodic keep-alive/heartbeat chunks with is_empty=True while a JSON fragment is still buffered. After state_ttl_seconds elapses the next call will purge the stream from _states as “stale”, discarding the buffered partial JSON and corrupting the eventual output even though the stream was still active. Consider updating last_accessed (or bypassing cleanup) for empty chunks so active streams are not evicted simply because they temporarily contain no payload.

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.

2 participants