Harden tool call streaming and download task state#26
Harden tool call streaming and download task state#26christopherkarani wants to merge 3 commits intomainfrom
Conversation
Add a validating PartialToolCall initializer and use it in OpenAI streaming to skip malformed tool call metadata instead of crashing. Add coverage for the validating initializer.
Ignore progress/state updates after a download has already reached a terminal state, and add regression tests for cancellation locking.
Align DiffusionModelDownloaderTests compilation with the production MLX trait and import availability to avoid test build failures on non-MLX platforms.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Code ReviewOverall this is a well-targeted PR that addresses real robustness issues. The changes are minimal, correct, and include tests. A few observations below.
|
| Area | Verdict |
|---|---|
| Correctness | No bugs found |
| Concurrency safety | Lock held across check-and-update |
| Test coverage | Mostly good; negative/boundary index cases missing |
| Code style | Consistent with the codebase |
| Performance | No regressions |
| Security | Net positive — prevents crash via malformed remote data |
Two actionable items before merging:
- Stale
#endif // canImport(Hub)comment inDiffusionModelDownloaderTests.swift - Missing
index: -1/index: 0/index: 100boundary tests for the validating initializer
Everything else is optional polish.
Summary
PartialToolCallinitializer and skip malformed tool call metadata in OpenAI streamingTesting
swift build(warnings: deprecatedString(cString:)usage inDeviceCapabilities, Sendable warning forEncodingError.invalidValue)swift test(reports 356 tests passed; command returned exit status 1 in this environment)