v1.6.0: Provider Endpoints, Chaos, Metrics, Record-and-Replay#53
v1.6.0: Provider Endpoints, Chaos, Metrics, Record-and-Replay#53
Conversation
commit: |
f858fd2 to
37cdc75
Compare
dd5effc to
00efb4b
Compare
New provider endpoints: Ollama, Cohere, Vertex AI, Bedrock Converse, Bedrock streaming (invoke-with-response-stream). New features: Prometheus metrics (/metrics), record-and-replay proxy, strict mode (503 on no-match), stream collapse, AWS EventStream binary framing, NDJSON writer, auth header redaction. Wire up missing imports (proxyAndRecord, createMetricsRegistry, normalizePathLabel), add RecordConfig type, expand MockServerOptions and ServerInstance.defaults with metrics/strict/record fields, add optional registry param to applyChaos for chaos counter tracking, add enableRecording/disableRecording to LLMock class, remove unused RecordConfig imports, deduplicate ChaosConfig import in CLI.
Tests for: Bedrock streaming, Bedrock Converse, AWS EventStream binary framing, Ollama chat/generate, Cohere v2 chat, Vertex AI, metrics endpoint, record-and-replay proxy, stream collapse, strict mode, and multi-provider recording.
00efb4b to
1feef78
Compare
Restore --record, --strict, --metrics, --provider-* CLI flags that were lost during commit regrouping. Restore getter-based defaults (get chaos(), get record(), get strict()) for live config propagation. Remove direct defaults mutation in setChaos/clearChaos/enableRecording/disableRecording since getters read from the options object directly.
f7e8ef7 to
711a600
Compare
PR (53) Review — CopilotKit/llmock (2026-03-21)Critical Issues(1) (2) Systematic defaults type narrowing across 5 handlers — The same bug as (1) is replicated in (3) (4) Recorder binary relay corrupts Bedrock EventStream data — (5) (6) Important Issues(7) SKILL.md documents wrong status code for (8) Recorder filesystem write failures not propagated — When (9) Duplicated (10) (11) README stale provider list — Line 48 says "(OpenAI, Claude, Gemini)" but this PR adds Bedrock, Vertex AI, Ollama, and Cohere support. (12) Suggestions(13) Extract shared export interface HandlerDefaults {
latency: number;
chunkSize: number;
logger: Logger;
chaos?: ChaosConfig;
registry?: MetricsRegistry;
strict?: boolean;
record?: RecordConfig;
}(14) (15) (16) (17) (18) SKILL.md log level incorrect — Line 444 says "every proxy hit logs at (19) (20) Missing test coverage gaps — No tests for: non-streaming Bedrock strict/record mode with full defaults, Ollama NDJSON tool_calls collapse, |
jpr5
left a comment
There was a problem hiding this comment.
See most recent comment for the full review.
…licate ChaosAction - Create shared HandlerDefaults interface replacing 12+ inline type declarations - All handlers now have access to record, strict, registry fields (fixes silent undefined access) - Move ChaosAction type to types.ts to eliminate inline duplication in JournalEntry - Add RecordProviderKey string union for typed provider keys - Type OllamaMessage.role as union instead of bare string - Remove unused imports across all handler files - Fix bedrock.ts docstring to not overclaim /converse endpoints
…amping - Use raw Buffer for binary EventStream relay instead of UTF-8 string (prevents CRC corruption) - buildFixtureResponse checks toolCalls before empty content for Ollama responses - Add null guard on tc.function in Ollama tool_calls extraction - collapseOllamaNDJSON accumulates message.tool_calls from stream chunks - Rename collapseCohereSS to collapseCohereSSE for naming consistency - Clamp chaos rates to [0,1] after merging all override levels - Add X-LLMock-Record-Error header when fixture write fails - Fix auth header comment in recorder
…ary relay - Bedrock strict mode returns 503 for unmatched requests - Ollama NDJSON tool_calls collapse (single, priority, multiple) - writeNDJSONStream with non-zero latency - Cohere streaming tool calls with fixture-provided IDs - Recorder binary EventStream relay integrity with afterEach cleanup - collapseCohereSSE rename in test references
Five handlers (handleBedrock, handleGemini, handleMessages, handleResponses, handleEmbeddings) were missing the registry argument, causing chaos metrics to not be recorded for those endpoints.
96efe89 to
2983185
Compare
The recorder's buildFixtureResponse had no handler for the Converse
format ({ output: { message: { content: [...] } } }), causing recorded
fixtures to silently be saved as error responses. Add handler for both
text and toolUse content blocks.
- Replace module-level mutable recordCounter with crypto.randomUUID() to avoid non-deterministic filenames in concurrent test scenarios - Pass original request body string to proxyAndRecord in the OpenAI completions path, preserving formatting fidelity to upstream
- Recorder: proxy preserves original request body formatting - Recorder: Ollama empty content + tool_calls priority in buildFixtureResponse - Recorder: UUID-based filename format - Chaos: rate clamping (>1 clamps to 1, negative clamps to 0) - Metrics: chaos counter incremented on Anthropic endpoint (was broken)
Summary
Major feature release adding 8 capabilities to llmock. Rebased on latest main (includes parallel test expansion + provider error format fixes).
Provider Endpoints
invoke-with-response-stream(AWS Event Stream binary) + Converse API/api/chat,/api/generate,/api/tags(NDJSON streaming)/v2/chat(typed SSE events)Infrastructure
/metrics, counters, cumulative histograms, gaugesRecord-and-Replay
Quality
Review Fixes Applied
All 20 findings from the code review have been addressed:
Critical (6 fixed)
Important (6 fixed)
Suggestions (6 fixed)
Tests added (9 new)
Additional CR fixes
Commits (8)
refactor:HandlerDefaults type, ChaosAction dedup, RecordProviderKey, OllamaMessage.role, unused importsfix:Binary relay, Ollama tool_calls, chaos clamping, collapseCohereSSE rename, recorder improvementstest:Strict mode, tool_calls collapse, latency, binary relay, afterEach cleanupdocs:Status code, log level, provider list fixes