chenhg5/cc-connect · error

cloud_web: reconstruct_reply not supported by gateway

Error message

cloud_web: reconstruct_reply not supported by gateway

What it means

ReconstructReplyCtx can only rebuild a reply context from data the platform retained. The gateway transport does not register the capReconstructReply capability, so any call immediately returns this error rather than attempting reconstruction. Callers should check the capability first.

Source

Thrown at platform/cloud-web/cloudweb.go:670

	rc, err := parseReplyCtx(replyCtx)
	if err != nil {
		return err
	}
	if !p.hasCap(capAudio) {
		return core.ErrNotSupported
	}
	return p.sendWire(ctx, map[string]any{
		"type":        "audio",
		"session_key": rc.SessionKey,
		"reply_ctx":   rc.ReplyCtx,
		"data":        base64.StdEncoding.EncodeToString(audio),
		"format":      format,
	})
}

func (p *Platform) ReconstructReplyCtx(sessionKey string) (any, error) {
	if !p.hasCap(capReconstructReply) {
		return nil, fmt.Errorf("cloud_web: reconstruct_reply not supported by gateway")
	}
	replyCtx, ok := p.lookupReplyCtx(sessionKey)
	if !ok {
		return nil, fmt.Errorf("cloud_web: no stored reply context for session %q", sessionKey)
	}
	return replyContext{SessionKey: sessionKey, ReplyCtx: replyCtx}, nil
}

func (p *Platform) sendWire(ctx context.Context, msg map[string]any) error {
	if ctx == nil {
		ctx = context.Background()
	}
	return p.tp.Send(ctx, msg)
}

func parseReplyCtx(v any) (replyContext, error) {
	switch rc := v.(type) {
	case replyContext:

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Check the reconstruct-reply capability before calling and skip restoration for gateway-backed sessions
  2. Start a fresh message (Send) for gateway sessions instead of reconstructing old reply contexts
  3. Switch the platform to a transport that supports reconstruct_reply if reply-context restoration is required
  4. Wrap the call so the error is treated as 'not available' rather than a hard failure in the restore path

Example fix

// before
ctxAny, err := p.ReconstructReplyCtx(sessionKey)
if err != nil { return err }

// after
if !p.SupportsReconstructReply() {
    return nil // gateway: start fresh session instead
}
ctxAny, err := p.ReconstructReplyCtx(sessionKey)
Defensive patterns

Strategy: validation

Validate before calling

if !p.SupportsReconstructReply() {
    return nil // skip restore for gateway transport
}

Type guard

rr, ok := p.(ReconstructReplyer); if !ok { /* capability absent */ }

Try / catch

rc, err := p.ReconstructReplyCtx(key)
if err != nil && strings.Contains(err.Error(), "not supported") {
    return nil // gateway: start fresh
}

Prevention

When it happens

Trigger: Calling p.ReconstructReplyCtx(sessionKey) on a cloud_web Platform instance created with the gateway transport (capability not registered).

Common situations: Engine session-restore logic calling ReconstructReplyCtx uniformly across platforms, hitting the gateway-backed instance; switching a deployment from long_poll/websocket to gateway while existing restore code assumes reconstruction works; writing tests against one transport and running under another.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/ce2d5b98551ab0d9. Report an issue: GitHub.