Skip to content

Commit d61be03

Browse files
authored
fix(responses): use proper text.format object for plain-text verbosity
Mypy reported a typing error because the `text.format` TypedDict expects an object (e.g. {"type": "text"}) not a plain string "text". Previously we set response_format = {"format": "text", "verbosity": ...} which fails type checks. This change uses the correct format object: {"format": {"type": "text"}, "verbosity": <value>} This resolves the mypy failure and keeps the `text` payload valid for the Responses API.
1 parent 1ec2b74 commit d61be03

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/agents/models/openai_responses.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,12 @@ async def _fetch_response(
299299
if response_format is not omit:
300300
response_format["verbosity"] = model_settings.verbosity # type: ignore [index]
301301
else:
302-
# When no output_schema is present, text needs an explicit format key.
303-
# Use the plain text format with verbosity to produce a valid `text` payload.
304-
response_format = {"format": "text", "verbosity": model_settings.verbosity}
302+
# When no output_schema is present, `text` needs an explicit format object.
303+
# Use the plain text format object with verbosity to produce a valid `text` payload.
304+
response_format = {
305+
"format": {"type": "text"},
306+
"verbosity": model_settings.verbosity,
307+
}
305308

306309
stream_param: Literal[True] | Omit = True if stream else omit
307310

0 commit comments

Comments
 (0)