github/copilot-sdk · error

unsupported elicitation content value type %T

Error message

unsupported elicitation content value type %T

What it means

Elicitation UI responses must arrive as one of the supported Go types (e.g. string, []any of strings) for conversion into rpc UI elicitation values. If the decoded value's type matches none of the handled cases, the conversion returns this error identifying the Go type via %T. It signals the host returned an elicitation content value in an unexpected shape.

Solutions

  1. Check the %T in the message to learn which JSON type the host returned
  2. Ensure the host sends the value as a string or array of strings as the schema declares
  3. Align host and SDK versions so the elicitation answer types are mutually supported
  4. Add a conversion case if the type is legitimately part of a newer protocol you control

Example fix

// before
return map[string]any{"values": [...]}, nil // object is unsupported
// after
return []any{"a", "b"}, nil
Defensive patterns

Strategy: type-guard

Validate before calling

switch v.(type) {
case string, []any:
    // supported
default:
    return fmt.Errorf("elicitation answer must be string or string array")
}

Type guard

func isSupportedElicitationValue(v any) bool {
    switch t := v.(type) {
    case string:
        return true
    case []any:
        return allStrings(t)
    default:
        return false
    }
}

Try / catch

val, err := convert(v)
if err != nil && strings.Contains(err.Error(), "content value type") {
    return fmt.Errorf("host sent unsupported answer type; ask host to conform to schema")
}

Prevention

When it happens

Trigger: A host replies to a UI elicitation with a JSON type outside the accepted set, e.g. a bare number, boolean, object, or null, hitting the default branch of the conversion function.

Common situations: Host implementations returning objects for multi-value answers; schema/client disagreement about the answer type; protocol changes where new answer kinds are sent by newer hosts to older SDKs.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09). Data as JSON: /api/errors/7ae960ffddc30630. Report an issue: GitHub.

Appendix: source

Thrown at go/session.go:1132

			return nil, err
		}
		return rpc.UIElicitationNumberValue(f), nil
	case string:
		return rpc.UIElicitationStringValue(val), nil
	case []string:
		return rpc.UIElicitationStringArrayValue(val), nil
	case []any:
		strs := make([]string, len(val))
		for i, item := range val {
			s, ok := item.(string)
			if !ok {
				return nil, fmt.Errorf("unsupported elicitation string array item type %T", item)
			}
			strs[i] = s
		}
		return rpc.UIElicitationStringArrayValue(strs), nil
	default:
		return nil, fmt.Errorf("unsupported elicitation content value type %T", v)
	}
}

// Capabilities returns the session capabilities reported by the server.
func (s *Session) Capabilities() SessionCapabilities {
	s.capabilitiesMu.RLock()
	defer s.capabilitiesMu.RUnlock()
	return s.capabilities
}

// setCapabilities updates the session capabilities.
func (s *Session) setCapabilities(caps *SessionCapabilities) {
	s.capabilitiesMu.Lock()
	defer s.capabilitiesMu.Unlock()
	if caps != nil {
		s.capabilities = *caps
	} else {
		s.capabilities = SessionCapabilities{}

View on GitHub (pinned to cd8cf15dc3)