Skip to content

feat: response merging, JSON auto-stringify, and openai-responses migration#111

Merged
jpr5 merged 4 commits intomainfrom
feat/response-merging-dx
Apr 15, 2026
Merged

feat: response merging, JSON auto-stringify, and openai-responses migration#111
jpr5 merged 4 commits intomainfrom
feat/response-merging-dx

Conversation

@jpr5
Copy link
Copy Markdown
Contributor

@jpr5 jpr5 commented Apr 14, 2026

Summary

  • Response template merging — override id, created, model, usage, finishReason, role, systemFingerprint on fixture responses across all 4 provider formats (OpenAI, Claude, Gemini, Responses API), streaming and non-streaming
  • JSON auto-stringify — fixture arguments and content accept objects (auto-stringified by loader AND programmatic API), eliminating escaped JSON pain
  • Repo-wide conversion — all fixture files and docs examples converted to object syntax
  • Migration guidedocs/migrate-from-openai-responses/ targeting ~8.5K weekly PyPI users with accurate before/after examples
  • Docs accuracy fixes — fixtures page field names corrected (latency, ttft, chaos), missing endpoint/ContentWithToolCalls documented, onTranscription signature fixed
  • Type cleanuprole/finishReason consolidated into ResponseOverrides, FixtureFile* types extend ResponseOverrides, validateFixtures recognizes all response types
  • New exportsResponseOverrides, ContentWithToolCallsResponse, FixtureFileResponse, FixtureFileToolCall
  • Updated guidanceskills/write-fixtures/SKILL.md and docs pages updated for new features
  • Version bump — 1.14.0

Test plan

  • 2377 tests pass (40 new: 29 response overrides + 8 auto-stringify + 3 programmatic)
  • Build clean (1.8MB, 285 files)
  • Exports clean (all 6 paths verified)
  • All commit headers under 100 chars (commitlint)
  • No escaped JSON strings remain in fixtures or docs
  • Full MSAL CR loop converged (5 module reviews + fix round + 7-agent final gate)

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 14, 2026

Open in StackBlitz

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

commit: 320d466

@jpr5 jpr5 force-pushed the feat/response-merging-dx branch 4 times, most recently from 7eb1c5a to ec66322 Compare April 15, 2026 00:12
jpr5 added 4 commits April 15, 2026 16:39
Add ResponseOverrides interface for overriding envelope fields (id, created,
model, usage, finishReason, role, systemFingerprint) in fixture responses.
Thread overrides through all 4 provider handlers (OpenAI Chat, Responses API,
Claude Messages, Gemini) for both streaming and non-streaming paths.

Add normalizeResponse() for auto-stringifying object-valued content and
toolCalls[].arguments in fixtures — lets authors write plain JSON objects
instead of escaped strings. FixtureFile* types accept relaxed input while
runtime types remain strict.

Type safety improvements:
- Add system_fingerprint to SSEChunk/ChatCompletion types
- Make type guards mutually exclusive (isTextResponse excludes toolCalls)
- Narrow extractOverrides parameter type
- Remove unnecessary as-casts

Cross-provider consistency:
- finishReason mappings: length, content_filter for all providers
- Usage auto-sum: total_tokens computed from components when omitted
- Reasoning support for ContentWithToolCallsResponse in all providers
- webSearches warnings for unsupported providers

Validation: ResponseOverrides field type checks, unknown field detection,
unknown usage key detection, ContentWithToolCallsResponse validation.
55 new tests across 4 test files:
- response-overrides.test.ts: override propagation for all providers
  (streaming + non-streaming), cross-provider finishReason mappings
  (stop, tool_calls, length, content_filter), usage auto-sum and
  partial merge per provider, CWTC with overrides/reasoning/webSearches,
  extractOverrides unit tests
- fixture-loader.test.ts: auto-stringify edge cases (arrays, null,
  mixed types, immutability), validation for all override fields,
  ContentWithToolCallsResponse validation, unknown field/usage detection
- content-with-toolcalls.test.ts: multi-tool-call streaming for
  OpenAI/Claude/Gemini, type guard mutual exclusivity
- llmock.test.ts: programmatic API override passthrough via on()
- Migration guide from openai-responses-python
- Fixtures docs: Response Override Fields table, provider support matrix,
  ContentWithToolCallsResponse row, finishReason/usage mapping details
- SKILL.md: complete override field docs with provider support matrix,
  finishReason translation table, usage auto-compute notes
- Convert all fixture examples to object syntax (auto-stringify)
- Fix provider count to 8, finishReason to camelCase in README
- Remove stale TODO in stream-collapse.ts
@jpr5 jpr5 force-pushed the feat/response-merging-dx branch from f71127c to 320d466 Compare April 15, 2026 23:40
@jpr5 jpr5 merged commit fdf36b3 into main Apr 15, 2026
22 checks passed
@jpr5 jpr5 deleted the feat/response-merging-dx branch April 15, 2026 23:43
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