Skip to content

Conversation

@sachaservan
Copy link
Member

@sachaservan sachaservan commented Dec 22, 2025

Summary by cubic

Fixes dropped connections and unreliable streaming by keeping a strong reference to the TinfoilAI client and its URLSession. TinfoilAI.create now returns a TinfoilAI with the same API as OpenAI.

  • Bug Fixes

    • Keep URLSession and client alive to prevent reconnects and stream interruptions.
    • Enable extended background idle mode to maintain persistent connections.
    • Apply certificate pinning for both streaming and non-streaming requests.
    • Add shutdown() and cleanup on deinit to close sessions safely.
  • Migration

    • TinfoilAI.create returns TinfoilAI (use tinfoilClient.chats(...) directly).
    • Remove TinfoilClient; replace underlyingClient calls with TinfoilAI methods.
    • README updated to reflect the new return type.

Written for commit be15736. Summary will update automatically on new commits.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 6 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="Sources/TinfoilAI/Tinfoil.swift">

<violation number="1" location="Sources/TinfoilAI/Tinfoil.swift:103">
P1: The `sslDelegate` is created but not stored as a class property. If the OpenAI client holds a weak reference to the SSL delegate (common pattern), it will be deallocated immediately after init, potentially breaking SSL certificate pinning for streaming operations. Consider adding a `private let sslDelegate: StreamingSSLDelegate` property and passing it to `self.init()`.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

@sachaservan sachaservan merged commit 473af66 into main Dec 22, 2025
3 checks passed
@sachaservan sachaservan deleted the fix/networking branch December 22, 2025 06:05
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