Context
When the Letta Code CLI (headless mode) detects a 409 PENDING_APPROVAL error, it autonomously attempts recovery by resolving pending approvals. During this process, it emits {"type": "recovery", ...} JSON messages to stdout.
The SDK's transformMessage() in session.ts does not handle type=recovery messages -- they are silently dropped. This means downstream consumers (like lettabot) have no visibility into what recovery the CLI attempted.
Impact
Currently low -- lettabot #478 added its own approval detection and recovery that works regardless of what the CLI does. However, surfacing recovery events would:
- Improve debugging/observability when approval issues arise
- Allow downstream consumers to avoid redundant recovery attempts
- Give better visibility into the CLI's autonomous recovery behavior
Suggested fix
Add a type=recovery handler in transformMessage() (session.ts ~line 1083) that creates an SDKRecoveryMessage:
if (wireMsg.type === "recovery") {
const msg = wireMsg as WireMessage & {
recovery_type: string;
message: string;
session_id?: string;
};
return {
type: "recovery" as const,
recoveryType: msg.recovery_type,
message: msg.message,
};
}
Related: lettabot #478 (bot-side fix for #439/#438)
Context
When the Letta Code CLI (headless mode) detects a 409 PENDING_APPROVAL error, it autonomously attempts recovery by resolving pending approvals. During this process, it emits
{"type": "recovery", ...}JSON messages to stdout.The SDK's
transformMessage()insession.tsdoes not handletype=recoverymessages -- they are silently dropped. This means downstream consumers (like lettabot) have no visibility into what recovery the CLI attempted.Impact
Currently low -- lettabot #478 added its own approval detection and recovery that works regardless of what the CLI does. However, surfacing recovery events would:
Suggested fix
Add a
type=recoveryhandler intransformMessage()(session.ts ~line 1083) that creates anSDKRecoveryMessage:Related: lettabot #478 (bot-side fix for #439/#438)