Skip to content

fix(openai): protect Responses privacy and finalize interrupted calls - #520

Open
nik13 wants to merge 10 commits into
devfrom
fix/opus-followup-traceAI-486
Open

nik13 wants to merge 10 commits into
devfrom
fix/opus-followup-traceAI-486

Conversation

@nik13

@nik13 nik13 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow up on the independent recall of #486. Keep Parallel Responses on the maintained shared OpenAI instrumentor; add no second patch or duplicate spans.

  • Remove MCP authorization and headers from telemetry-only request and response tool definitions. Preserve the actual SDK wire payload, returned objects, and function schemas.
  • Keep echoed instructions, metadata, input and other request-derived fields out of Responses output, including the streaming JSON fallback. Preserve answer content, status and usage; honor hidden error details.
  • Redact known client/request credentials from status descriptions, attributes, exception messages and stack traces independently of FI_HIDE_ERROR_DETAILS. Re-raise the original SDK exception unchanged.
  • Mark failed/incomplete Responses and failure/error terminal events as ERROR, not successful generations. EOF or close before a terminal event is also ERROR.
  • Finish explicit sync/async stream closes and the high-level responses.stream() context exactly once. That context closes the underlying HTTP response rather than the raw SDK stream, so it needs a per-call response-close proxy as well.
  • End request/stream spans on cancellation or other local aborts before re-raising.
  • Mark interrupted Parallel Task workflows as ERROR, without attaching raw exception text; update both the example and its README recipe.

Reproduction and verification

On current dev 5ae2b9b4a3678af52abc01d90e4fe2fe1d4c2099, the original independent recall suite reproduced all seven findings: 20 failed, 2 passed at each SDK bound, before implementation changes.

The checked-in regressions cover sync/async, non-stream/stream, raw Responses objects, SDK high-level stream context exit, repeated/empty/terminal closes, request/stream cancellation, failure/incomplete/error terminal events, unchanged wire payloads and SDK exceptions, escaped credentials, input privacy flags, and hidden error details. Task interruption tests use the actual registered processor, not only a bare OTel provider.

All Python tests and builds ran inside the prescribed macOS sandbox denying external networking (loopback allowed). SDK requests use synthetic credentials and MockTransport; existing export/example tests use loopback OTLP receivers. No live vendor or Cloud calls.

Environment Result
Python 3.10, openai 1.69.0, parallel-web 1.0.1, core 1.2.2, source 496 passed, 2 skipped
Python 3.13, openai 3.42.1, parallel-web 1.3.7, core 1.2.2, source 496 passed, 2 skipped
Installed wheels, floor SDKs 496 passed, 2 skipped
Installed sdists, latest SDKs 496 passed, 2 skipped
  • Built both wheel and sdist distributions for both packages.
  • Ruff passes for new source and regression files; git diff --check passes.
  • python3 .github/release/release_plan.py --check: 129 packages, versions and coverage consistent.
  • Update the existing Parallel CI matrix to openai 3.42.1, the latest resolved public release.

The key-echoing 401 is a synthetic regression, not a claim about an observed live Parallel response. No registry publication or version bump; release-please owns the patch release.

Related open work

Checked existing OpenAI/Parallel PRs before creating this follow-up. #437 handles Perplexity response extensions, not these findings. #411 adds explicit raw stream close() methods for audio; it does not cover the high-level Responses HTTP-close path, early-vs-terminal status, request/stream cancellation, or the privacy findings. This PR retains compatible close delegation and adds the Responses-specific behavior. Reconcile the shared stream methods when landing those PRs; do not drop the Responses lifecycle tests.

E2E coverage

Not applicable: no application e2e harness is changed. Package contracts, real SDKs, registered processor behavior, built distributions and loopback OTLP export are exercised.

Recall round 2 fixes

  • Collect MCP authorization and arbitrary header values from effective extra_body.tools, honoring shallow replacement/removal without mutating the request or exporting extra-body metadata.
  • Observe sync/async raw read(), text() and json() consumption. Successful non-SSE bodies no longer report a missing SSE terminal event. Failed/cancelled/incomplete JSON statuses remain ERROR, read exceptions retain their identity and finalize exactly once, and unread/SSE responses still require completion. Reads stay lazy; no implicit SDK parse() or post-parser invocation.
  • New regression cases on the reviewed head: 31 failed, 42 passed at each SDK bound. All 73 now pass.
  • Current standalone full OpenAI suite: 727 passed, 8 SDK-feature skips at OpenAI 1.69.0; 735 passed at latest 3.42.1. Python 3.12, OTel 1.29.0/1.45.2; sandboxed synthetic transports.
  • Merged current origin/dev normally. fix(openai): mark interrupted agents and truncated chat streams as errors #536 now contains this exact branch and the resolved shared-request-wrapper conflict, with both fix sets tested together. No force push or release.

Generated with Claude Code

nik13 and others added 4 commits November 1, 2026 21:55
Strip MCP authentication from telemetry-only tool copies, redact known credentials from attributes and exception telemetry, and keep echoed request fields out of response output. Honor failed terminal results, finalize explicit and high-level stream closes, and propagate cancellation after ending spans. Mark interrupted Parallel Task workflows as errors.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Redact resolved request credentials, prevent core traceback reconstruction from restoring secrets, mask nested MCP errors, and trace parsed raw streams. Keep legacy core and published recipe contracts covered.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
Capture actual HTTP request credentials in a per-call context before SDK parsing. Preserve lazy async envelope parsing, finalize envelope closes, and trace every explicit stream parse cache entry with a shared terminal result.

Co-Authored-By: Claude Code <noreply@anthropic.com>
nik13 and others added 2 commits November 2, 2026 05:32
Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Code <noreply@anthropic.com>
nik13 added a commit that referenced this pull request Nov 2, 2026
Keep published-package cancellation, early-close and terminal-state contracts strict. Shared instrumentor repairs remain in #520/#536 pending a genuine fixed release.

Co-Authored-By: Claude Code <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant