Repository navigation
fix: restore incremental Responses reasoning - #138
Conversation
pierreraby
left a comment
There was a problem hiding this comment.
Verified: real bug, confirmed live — the gateway emits response.reasoning.delta (37x on deepseek-v4.1-flash-fast, 0x canonical alias) and pi-ai 1.0.3 drops them, so thinking lands all-at-once on every Responses-routed model. I captured raw frames: {type, sequence_number, item_id, output_index: 0, content_index, delta: string} — integer output_index + string delta, so the normalizer's schema assumption holds against the real gateway, not just the mock.
Local on 7e0e831: typecheck, test-transport 13/13, test-models 28/28, test-pricing 8/8, pi-local PASS, prettier clean. A fresh-context reviewer also checked the SSE parsing, wrapper scoping (Responses-only, 403 fallback preserved), and streaming properties — sound.
Two non-blocking P2s for follow-up: (1) finish() emits a trailing unterminated frame raw instead of normalizing it; (2) on schema mismatch the frame passes through silently, reverting to all-at-once with no signal. Also: this PR's wait-for-close cleanup and main's retry loop (0.7.5) fix the same ENOTEMPTY flake from opposite ends — suggest keeping wait-for-close as primary plus a longer retry backstop (and extending the waiter to runPi's timeout path) rather than picking one.
Leaving the merge to the maintainers.
pierreraby
left a comment
There was a problem hiding this comment.
Re-verified on 8a615be (merge of main + P2 hardening): typecheck, test-transport 16/16, pi-local PASS, prettier clean. The finish() normalization and schema-mismatch warning address my earlier P2s; wait-for-close + retry loop are combined as suggested. Merging once CI is green.
Summary
Restore incremental reasoning on Command Code's Provider API Responses wire, reproduced with
deepseek/deepseek-v4.1-flash-fast.After #133 selected Responses for models advertising
/responses, Command Code'sresponse.reasoning.deltaevents stopped reaching Pi as thinking deltas. pi-ai 1.0.3 understandsresponse.reasoning_text.delta, but not this non-standard alias. The finalresponse.output_item.donestill supplies the complete reasoning text, which explains why thinking appeared all at once at the end.Changes
response.reasoning.deltaSSE payloads toresponse.reasoning_text.delta, including the matching SSEevent:name, before delegating to pi-ai.403 upgrade_requireddetection unchanged.ENOTEMPTYcleanup failure. ReportPASSonly after cleanup succeeds.Validation
npm test, withPI_LOCAL_REQUIRED=1andOMP_COMPAT_REQUIRED=1and a temporary OMP installation supplied throughOMP_BIN: all suites passed, including both real hosts against mock APIs.npm run format:check.git diff --check.npm run test:pi-localruns: all exited successfully after cleanup.npm pack --ignore-scriptsfollowed bynpm run test:release-package -- <tarball>, withOMP_BIN: the installed tarball passed the Pi and OMP mock suites.