Skip to content

feat: add blob attachment type for inline base64 data#731

Draft
MackinnonBuck wants to merge 1 commit intomainfrom
inline-data-attachments
Draft

feat: add blob attachment type for inline base64 data#731
MackinnonBuck wants to merge 1 commit intomainfrom
inline-data-attachments

Conversation

@MackinnonBuck
Copy link
Collaborator

Summary

Add support for a new blob attachment type that allows sending base64-encoded content (e.g. images) directly, without disk I/O. This complements the existing file attachment type.

Adapts the SDK to the runtime changes in https://github.com/github/copilot-agent-runtime/pull/4249.

New attachment variant

type: "blob"
data: string       // base64-encoded content (required)
mimeType: string   // MIME type of the data (required)
displayName: string // optional user-facing label

Changes

Generated types (from updated session-events.schema.json)

  • nodejs/src/generated/session-events.ts
  • python/copilot/generated/session_events.py
  • go/generated_session_events.go
  • dotnet/src/Generated/SessionEvents.cs

Manual type updates

  • nodejs/src/types.ts — added blob variant to MessageOptions.attachments union
  • python/copilot/types.py — added BlobAttachment TypedDict and updated Attachment union
  • python/copilot/__init__.py — exported BlobAttachment and all attachment types from public API

Documentation

  • docs/features/image-input.md — new "Quick Start — Blob Attachment" section with examples for all 4 languages
  • nodejs/README.md, python/README.md, go/README.md, dotnet/README.md — added blob examples to Image Support sections
  • docs/features/streaming-events.md — added "blob" to attachment type list
  • test/scenarios/prompts/attachments/README.md — documented blob attachment format

Validation

  • TypeScript typecheck ✅
  • Go build + vet ✅
  • .NET build ✅
  • Python import check ✅
  • Docs code blocks are self-contained for validation pipeline

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Cross-SDK Consistency Review ✅

This PR successfully adds the blob attachment type across all 4 SDK implementations with excellent consistency! The feature is implemented uniformly across Node.js, Python, Go, and .NET.

✅ What's great:

  • ✅ Generated types updated in all 4 SDKs
  • ✅ Manual type definitions added where needed (Node.js types.ts, Python types.py)
  • ✅ Python properly exports BlobAttachment and all attachment types from __init__.py
  • ✅ Comprehensive documentation with examples for all 4 languages
  • ✅ API naming follows proper language conventions (camelCase vs PascalCase)
  • ✅ All READMEs updated consistently

Minor suggestion:

There are a couple of documentation comments that could be updated for completeness (see inline comments), but these are non-blocking polish items. The actual implementation is solid and consistent across all SDKs.

Great work maintaining feature parity! 🎉

Generated by SDK Consistency Review Agent for issue #731 ·

@MackinnonBuck MackinnonBuck force-pushed the inline-data-attachments branch from 75cd246 to 9d9671a Compare March 9, 2026 02:06
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

SDK Consistency Review: Critical Issues Found ⚠️

Thank you for working on blob attachment support! However, I've identified cross-SDK consistency issues that need to be addressed before this PR can maintain feature parity across all four SDK implementations.

❌ Missing Implementation in Go SDK

The Go SDK's generated types in go/generated_session_events.go are missing blob support:

Current state:

type Attachment struct {
    DisplayName *string `json:"displayName,omitempty"`
    Path *string `json:"path,omitempty"`
    Type AttachmentType `json:"type"`
    FilePath *string `json:"filePath,omitempty"`
    // ... other fields for selection, github_reference
    // ❌ Missing: Data and MIMEType fields
}

const (
    Directory       AttachmentType = "directory"
    File            AttachmentType = "file"
    GithubReference AttachmentType = "github_reference"
    Selection       AttachmentType = "selection"
    // ❌ Missing: Blob constant
)

What's needed:

  • Add Data *string and MIMEType *string fields to the Attachment struct
  • Add Blob AttachmentType = "blob" constant

❌ Missing Implementation in .NET SDK

The .NET SDK's generated types in dotnet/src/Generated/SessionEvents.cs are missing blob support:

Current state:

[JsonPolymorphic(TypeDiscriminatorPropertyName = "type", ...)]
[JsonDerivedType(typeof(UserMessageDataAttachmentsItemFile), "file")]
[JsonDerivedType(typeof(UserMessageDataAttachmentsItemDirectory), "directory")]
[JsonDerivedType(typeof(UserMessageDataAttachmentsItemSelection), "selection")]
[JsonDerivedType(typeof(UserMessageDataAttachmentsItemGithubReference), "github_reference")]
// ❌ Missing: JsonDerivedType for blob
public partial class UserMessageDataAttachmentsItem { ... }

// ❌ Missing: UserMessageDataAttachmentsItemBlob class entirely

What's needed:

  • Create UserMessageDataAttachmentsItemBlob class with Data, MimeType, and DisplayName properties
  • Add [JsonDerivedType(typeof(UserMessageDataAttachmentsItemBlob), "blob")] attribute

⚠️ Incomplete Python Generated Types

While the Python SDK has a working implementation via the manual BlobAttachment TypedDict in types.py, the generated types in python/copilot/generated/session_events.py are incomplete:

class AttachmentType(Enum):
    DIRECTORY = "directory"
    FILE = "file"
    GITHUB_REFERENCE = "github_reference"
    SELECTION = "selection"
    # ❌ Missing: BLOB = "blob"

`@dataclass`
class Attachment:
    type: AttachmentType
    # ... existing fields
    # ❌ Missing: data and mime_type fields

🔧 Root Cause

The issue appears to be that the schema used for type generation (session-events.schema.json from @github/copilot) may not have been updated with the blob attachment variant yet, or the type generation script wasn't re-run after the schema update.

📋 Action Items

To bring all SDKs into alignment:

  1. Verify schema is up-to-date: Ensure session-events.schema.json from @github/copilot (referenced in copilot-agent-runtime#4249) includes the blob attachment type
  2. Re-run type generation: Execute npm run generate:session-types in the nodejs/ directory to regenerate all four language SDKs' types
  3. Verify generated output: Confirm that:
    • Go's Attachment struct has Data and MIMEType fields + Blob constant
    • .NET's generated file has UserMessageDataAttachmentsItemBlob class and the corresponding JsonDerivedType
    • Python's generated Attachment dataclass has data and mime_type fields + BLOB enum value

📚 Documentation is Excellent

The documentation updates across all four SDK READMEs and docs/features/image-input.md are comprehensive and show proper examples for all languages—once the generated types are fixed, these examples will work perfectly! ✨


Recommendation: Please update the generated types for Go, .NET, and Python before merging. The manual types in Node.js and Python's types.py are good workarounds, but having consistent generated types across all SDKs is important for long-term maintainability.

Generated by SDK Consistency Review Agent for issue #731 ·

Add support for a new 'blob' attachment type that allows sending
base64-encoded content (e.g. images) directly without disk I/O.

Generated types will be updated automatically when the runtime publishes
the new schema to @github/copilot. This commit includes:

- Add blob variant to Node.js and Python hand-written types
- Export attachment types from Python SDK public API
- Update docs: image-input.md, all language READMEs, streaming-events.md

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MackinnonBuck MackinnonBuck force-pushed the inline-data-attachments branch from 9d9671a to 7f62d6c Compare March 9, 2026 02:21
@MackinnonBuck
Copy link
Collaborator Author

CI failures are expected until the runtime PR merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant