mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-21 03:57:04 +00:00
Claude Code writes failed API calls ("Prompt is too long", usage limits,
logged out) as synthetic assistant records whose usage carries
`service_tier: null`. The schema only accepted undefined, so the local
session scanner dropped every one and the web session just looked stalled.
- Accept null for the usage fields the Messages API types as nullable.
- Keep the top-level `error`/`isApiErrorMessage` on assistant records in
local mode, and `error` in the SDK converter for remote mode.
- Render assistant records carrying `error` as the existing error event,
so the all-zero synthetic usage no longer resets the context gauge.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6bf0a633bb
commit
d3473f9ed4
@@ -159,6 +159,23 @@ describe('SDKToLogConverter', () => {
|
||||
|
||||
expect((logMessage as any).requestId).toBe('req_123')
|
||||
})
|
||||
|
||||
it('keeps the top-level error on synthetic API error messages (#1857)', () => {
|
||||
const sdkMessage: any = {
|
||||
type: 'assistant',
|
||||
message: {
|
||||
model: '<synthetic>',
|
||||
role: 'assistant',
|
||||
content: [{ type: 'text', text: 'Prompt is too long' }]
|
||||
},
|
||||
error: 'invalid_request',
|
||||
is_api_error_message: true
|
||||
}
|
||||
|
||||
const logMessage = converter.convert(sdkMessage)
|
||||
|
||||
expect((logMessage as any).error).toBe('invalid_request')
|
||||
})
|
||||
})
|
||||
|
||||
describe('System messages', () => {
|
||||
|
||||
Reference in New Issue
Block a user