feat: Add metadata field to request and response

This changes adds Optional metadata field to OpenAI compatible request and
response object.

fixes: #3564
Signed-off-by: Abhishek Bongale <abhishekbongale@outlook.com>
This commit is contained in:
Abhishek Bongale 2025-11-26 11:53:57 +00:00
parent b1c5b8fa9f
commit cfbc1f1624
10 changed files with 98 additions and 0 deletions

View file

@ -89,6 +89,7 @@ class Agents(Protocol):
),
] = None,
max_tool_calls: int | None = None,
metadata: dict[str, str] | None = None,
) -> OpenAIResponseObject | AsyncIterator[OpenAIResponseObjectStream]:
"""Create a model response.
@ -100,6 +101,7 @@ class Agents(Protocol):
:param include: (Optional) Additional fields to include in the response.
:param guardrails: (Optional) List of guardrails to apply during response generation. Can be guardrail IDs (strings) or guardrail specifications.
:param max_tool_calls: (Optional) Max number of total calls to built-in tools that can be processed in a response.
:param metadata: (Optional) Dictionary of metadata key-value pairs to attach to the response.
:returns: An OpenAIResponseObject.
"""
...

View file

@ -597,6 +597,7 @@ class OpenAIResponseObject(BaseModel):
:param usage: (Optional) Token usage information for the response
:param instructions: (Optional) System message inserted into the model's context
:param max_tool_calls: (Optional) Max number of total calls to built-in tools that can be processed in a response
:param metadata: (Optional) Dictionary of metadata key-value pairs
"""
created_at: int
@ -619,6 +620,7 @@ class OpenAIResponseObject(BaseModel):
usage: OpenAIResponseUsage | None = None
instructions: str | None = None
max_tool_calls: int | None = None
metadata: dict[str, str] | None = None
@json_schema_type