mirror of
https://github.com/dtzp555-max/olp.git
synced 2026-07-19 09:45:07 +00:00
fix(anthropic): suppress stream-json log spam for system/* and user events
The NDJSON event parser matched only `system/init` and treated every
other system subtype as "unknown event type" — logged via console.error,
once per event. During the 2026-05-28 OAuth-expiry 401 cascade this
produced 2 spam lines per failed request (PI231 server log was
~50% noise).
Also caught: claude echoes {type:'user'} events back in some stream-json
modes (analogous to --replay-user-messages); these were also spammed
as unknown.
Both are now consumed silently — neither maps to an IR chunk.
Authority:
- empirical PI231 v2.1.104 transcripts 2026-05-28 (server log shows
'[anthropic] unknown stream_json event type: system' and
'[anthropic] unknown stream_json event type: user')
- ADR 0009 Amendment 1 § "NDJSON event handling" — generic "future-proof
for unknown events" intent; the table was incomplete
Tests: 795 → 797
- 41e-5b: regression guard for system/<non-init-subtype>
- 41e-5c: user (echo) event consumption
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -17581,6 +17581,26 @@ describe('Suite 41 — ADR 0009 Amendment 1: stream-json transport (Phase 6)', (
|
||||
assert.equal(chunk, null, 'system/init must return null (consumed, no yield)');
|
||||
});
|
||||
|
||||
it('41e-5b: anthropicStreamJsonEventToIR — system/<other-subtype> → null (regression guard)', () => {
|
||||
// 2026-05-28: 401 cascade transcripts on PI231 showed claude emitting
|
||||
// system events with subtypes other than 'init' (e.g. api_retry). The
|
||||
// original parser matched only subtype==='init' and routed everything
|
||||
// else to the "unknown event type" log, spamming the server log.
|
||||
for (const subtype of ['api_retry', 'shutdown', undefined]) {
|
||||
const event = { type: 'system', subtype, note: 'whatever' };
|
||||
const chunk = anthropicStreamJsonEventToIR(event, false);
|
||||
assert.equal(chunk, null, `system/${subtype} must return null (consumed, no IR yield)`);
|
||||
}
|
||||
});
|
||||
|
||||
it('41e-5c: anthropicStreamJsonEventToIR — user (echoed user-message) → null', () => {
|
||||
// claude emits {type:'user'} echo events in some stream-json modes
|
||||
// (analogous to --replay-user-messages). Must be consumed, never yielded.
|
||||
const event = { type: 'user', message: { role: 'user', content: 'hi' } };
|
||||
const chunk = anthropicStreamJsonEventToIR(event, false);
|
||||
assert.equal(chunk, null, 'user echo events must return null');
|
||||
});
|
||||
|
||||
it('41e-6: anthropicStreamJsonEventToIR — rate_limit_event → null (consumed)', () => {
|
||||
const event = { type: 'rate_limit_event', rate_limit_info: { status: 'allowed' } };
|
||||
const chunk = anthropicStreamJsonEventToIR(event, false);
|
||||
|
||||
Reference in New Issue
Block a user