chenhg5/cc-connect · error

wps-agentspace: SendFile: invalid reply context type %T

Error message

wps-agentspace: SendFile: invalid reply context type %T

What it means

Type-assertion guard in wps-agentspace SendFile: replyCtx is not the platform's *replyContext type, so the target ChatID for the persisted-file notice cannot be determined.

Source

Thrown at platform/wps-agentspace/wpsagentspace.go:222

	return p.sendText(rc.ChatID, content, rc)
}

// Send sends a message to a chat.
func (p *Platform) Send(ctx context.Context, replyCtx any, content string) error {
	rc, ok := replyCtx.(*replyContext)
	if !ok {
		return fmt.Errorf("wps-agentspace: invalid reply context type")
	}
	return p.sendText(rc.ChatID, content, rc)
}

// SendFile implements core.FileSender. The WPS Agentspace WebSocket protocol
// has no native binary file frame, so we persist the file to a shared
// directory and reply with a path the user can open locally.
func (p *Platform) SendFile(ctx context.Context, replyCtx any, file core.FileAttachment) error {
	rc, ok := replyCtx.(*replyContext)
	if !ok {
		return fmt.Errorf("wps-agentspace: SendFile: invalid reply context type %T", replyCtx)
	}

	path, err := p.saveAttachment(file.FileName, file.Data)
	if err != nil {
		return fmt.Errorf("wps-agentspace: SendFile: %w", err)
	}

	notice := fmt.Sprintf("📎 文件已保存到本地:\n%s", path)
	return p.sendText(rc.ChatID, notice, rc)
}

// SendImage implements core.ImageSender. Same disk-persist fallback as SendFile.
func (p *Platform) SendImage(ctx context.Context, replyCtx any, img core.ImageAttachment) error {
	rc, ok := replyCtx.(*replyContext)
	if !ok {
		return fmt.Errorf("wps-agentspace: SendImage: invalid reply context type %T", replyCtx)
	}

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Ensure callers forward the platform-owned *replyContext
  2. Add reconstruction support so non-reply flows obtain a valid context
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at platform/wps-agentspace/wpsagentspace.go:222 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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