Skip to content

feat: post-response chaos for proxy mode (phase 2 - non-streaming)#120

Closed
marthakelly wants to merge 2 commits into
mainfrom
feat/chaos-proxy-phase2
Closed

feat: post-response chaos for proxy mode (phase 2 - non-streaming)#120
marthakelly wants to merge 2 commits into
mainfrom
feat/chaos-proxy-phase2

Conversation

@marthakelly

Copy link
Copy Markdown
Contributor

Summary

Adds post-response chaos for proxy mode (non-streaming). Enables mutating proxied responses after upstream call.

What’s included

  • malformed now works in proxy mode
    • upstream is called
    • response body is corrupted before returning
  • Works for non-streaming responses
  • Preserves all existing behavior for fixtures and proxy

Implementation

  • Intercepts res.write / res.end during proxy
  • Buffers upstream response
  • Applies chaos decision after proxy completes
  • Replays or mutates buffered response
  • Ensures response methods are always restored (fixes lifecycle bugs)

Why

Previously, proxy mode could not simulate response corruption — only request-level failures. This enables realistic downstream parsing failures when using real upstream APIs.

Scope

This PR covers Phase 2 (non-streaming):

  • malformed ✅

Follow-up PR will include:

  • status_override
  • truncate
  • streaming (SSE / NDJSON) support

Tests

  • New: malformed chaos in proxy mode (invalid JSON)
  • Full suite passing (~2400 tests)

Notes

  • Minimal, contained implementation
  • Does not modify proxy layer directly
  • Uses response interception; can be refactored into cleaner abstraction later

@pkg-pr-new

pkg-pr-new Bot commented Apr 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@copilotkit/aimock@120

commit: bb46743

@marthakelly

Copy link
Copy Markdown
Contributor Author

closing, trying another approach

@jpr5
jpr5 deleted the feat/chaos-proxy-phase2 branch May 4, 2026 17:30
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