Skip to content

Add metadata field to ModelMessage #3404

@steventen

Description

@steventen

Description

Summary

This feature request is to add a new, optional metadata: dict[str, Any] | None field to both the ModelRequest and ModelResponse. This field would serve as a "user-space" container for arbitrary, application-specific data that is not sent to the LLM.

Problem & Motivation

Developers often need to tag messages for filtering, grouping, or post-processing based on their application's internal logic. However, currently, there is no dedicated field on message objects to attach custom, application-specific data.

For example, an application might need to decorate the user's raw input before sending it as a ModelRequest. With a metadata field, developers could easily track which messages are customized and which template was used, enabling more reliable filtering or post-processing. Without metadata, we currently have to rely on detecting special characters in the message, which is error-prone.

A dedicated metadata field provides a clean, and simple way to store this information directly on the message object, improving developer experience and code robustness.

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions