docs(session): state the flat result converter failure contract

The exported converter rejects malformed wrappers with SessionFormatError in addition to refusing unsupported nesting. Document both failure categories so callers can distinguish corruption from a converter support limit.

Remove the obsolete claim that recorded replay compares serialized field order: the native-writer parity assertion compares parsed objects. The emitted fields and their order remain unchanged.
This commit is contained in:
Tianyi Cui committed 2026-09-19 17:20:53 +08:00
1 parent 45ce6ef21d
commit 4ab9101271
1 file changed
+1 -1
@@ -30,6 +30,7 @@ function resultContent(value: SessionFormatJsonValue | undefined, subject: strin
* rejected instead of being silently truncated.
* @param event - released wrapper tool/result event.
* @returns the same event with a first-class tool-role message.
* @throws {SessionFormatError} when the wrapper, tool source, content, or error flag is malformed.
* @throws {SessionFormatUnsupportedMigrationError} when the result contains another result.
*/
export function liftToolResult(event: SessionFormatEvent): SessionFormatEvent {
@@ -56,7 +57,6 @@ export function liftToolResult(event: SessionFormatEvent): SessionFormatEvent {
if (isError !== undefined && typeof isError !== 'boolean') {
throw new SessionFormatError(`format v3 ${event.type} at seq ${event.seq} tool-result isError must be boolean`)
}
// Recorded replay compares serialized messages with createToolResultMessage's field order.
const targetMessage: Record<string, SessionFormatJsonValue> = {
role: 'tool',
source,