Skip to content

Content types should have default values for Literal type fields #1731

@maxisbey

Description

@maxisbey

Problem

Content types like TextContent and ImageContent require passing type="text" or type="image" explicitly, even though these are single-value Literal types.

Current definitions:

class TextContent(BaseModel):
    type: Literal["text"]  # No default
    text: str

class ImageContent(BaseModel):
    type: Literal["image"]  # No default
    data: str
    mimeType: str

Current usage (verbose):

TextContent(type="text", text="hello")
ImageContent(type="image", data="...", mimeType="image/png")

PR #1292 already added defaults for method: Literal fields on request and notification types - could do the same thing here.

Related

AI Disclaimer

Metadata

Metadata

Labels

P1Significant bug affecting many users, highly requested featureenhancementRequest for a new feature that's not currently supportedv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions