Skip to main content

Module defect

Module defect 

Source
Expand description

Detects an upstream buffered body that carries no turn at all.

Every per-wire buffered parser is total: it deserializes what it recognises and defaults the rest. That is the right behaviour for a reply that is merely sparse, and the wrong behaviour for a reply that is empty, because the parser then manufactures a well-formed canonical response with no content, no usage and no stop reason. Relayed to a client that reads as a successful turn in which the model said nothing, and the audit row records it as completed with zero tokens.

buffered_body_defect runs before the parser and separates the two cases. A body is defective when it is not a JSON object at all, when it carries a provider error object despite the 2xx status, or when it has neither a non-empty content array nor a usage object. A legitimate empty turn – one that stopped immediately but still reports usage – has usage and is left alone.

Copyright (c) systemprompt.io — Business Source License 1.1. See https://systemprompt.io for licensing details.

Enums§

BodyDefect
Why the body cannot be parsed into a turn.

Functions§

buffered_body_defect