Skip to content

fix: remove spurious type field from converse-stream delta and start events (closes #165)#167

Merged
jpr5 merged 5 commits intomainfrom
fix/converse-stream-delta-type
May 8, 2026
Merged

fix: remove spurious type field from converse-stream delta and start events (closes #165)#167
jpr5 merged 5 commits intomainfrom
fix/converse-stream-delta-type

Conversation

@jpr5
Copy link
Copy Markdown
Contributor

@jpr5 jpr5 commented May 8, 2026

Summary

Converse-stream spec conformance fixes — same class of bugs as #162 (Claude Messages API format leaking into Converse API handlers). Full 10-agent Bedrock conformance audit completed; all other Bedrock endpoints are clean.

Fixes

  1. contentBlockDelta spurious type fielddelta objects contained Claude Messages API type fields (text_delta, thinking_delta) not valid in the Converse API's tagged union. botocore's single-member parser rejected the extra field with ResponseParserError. (Closes Bug: converse-stream contentBlockDelta.delta contains invalid type field, causing ResponseParserError #165)

  2. Reasoning events used Claude formatcontentBlockStart used start: { type: "thinking" } and deltas used delta: { thinking: "..." }. Now uses Converse format: start: { reasoningContent: {} } and delta: { reasoningContent: { text: "..." } }.

  3. Text contentBlockStart had spurious typestart: { type: "text" } changed to start: {} (Converse text blocks have empty start).

  4. inferenceConfig.maxTokens silently droppedconverseToCompletionRequest now forwards maxTokens to max_tokens.

  5. Non-streaming converse missing metrics — Added metrics: { latencyMs: 0 } to all 3 non-streaming response builders, matching the streaming path and AWS ConverseResponse spec.

New drift tests

  • invoke-with-response-stream drift test with binary frame parsing and Anthropic-native event shape comparison
  • converse-stream tool call shapes — toolUse start/delta SDK shapes + triangulate
  • converse-stream reasoning shapes — reasoningContent start/delta SDK shapes + triangulate

Audit scope

10-agent MSAL covering: invoke non-streaming, invoke-stream binary framing, invoke-stream Claude events, converse non-streaming, converse-stream text/tool/reasoning, converse request conversion, invoke request conversion, drift test + SDK shape coverage. All clean except the 5 issues above.

Closes #165 — reported by @KMiya84377

Test plan

  • pnpm test — 2837 passed
  • npx tsc --noEmit — clean
  • Negative assertions on all delta and start payloads
  • SDK drift shapes updated for all 3 converse-stream variants (text, tool, reasoning)
  • invoke-with-response-stream drift test added
  • Full codebase audit: zero Claude format contamination in other providers

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 8, 2026

Open in StackBlitz

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

commit: 8b242bc

@jpr5 jpr5 self-assigned this May 8, 2026
jpr5 added 4 commits May 8, 2026 09:33
… metrics (closes #165)

Remove spurious Claude Messages API type fields from converse-stream
delta and start events. Use reasoningContent format for thinking blocks.
Forward inferenceConfig.maxTokens in request conversion. Add metrics
field to non-streaming converse responses.
Negative assertions on delta and start payloads (not.toHaveProperty
type). Reasoning tests use reasoningContent format. maxTokens
forwarding test. Non-streaming metrics assertions.
… SDK shapes

New drift test for invoke-with-response-stream binary framing and
Anthropic-native event shapes. SDK shapes for converse-stream tool call
and reasoning variants. Three-way triangulate comparisons.
@jpr5 jpr5 force-pushed the fix/converse-stream-delta-type branch from 3a3418b to 1e57275 Compare May 8, 2026 16:33
@jpr5 jpr5 force-pushed the fix/converse-stream-delta-type branch from 84c6264 to 8b242bc Compare May 8, 2026 16:41
@jpr5 jpr5 merged commit a398ff3 into main May 8, 2026
22 checks passed
@jpr5 jpr5 deleted the fix/converse-stream-delta-type branch May 8, 2026 16:46
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.

Bug: converse-stream contentBlockDelta.delta contains invalid type field, causing ResponseParserError

1 participant