mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: Fix broken samples for GitHub Copilot, declarative, and Responses API (#4915)
* Python: Fix broken samples for GitHub Copilot, declarative, and Responses API - Add missing on_permission_request handler to github_copilot_basic and github_copilot_with_session samples (required by copilot SDK) - Increase timeout for remote MCP query in github_copilot_with_mcp sample - Soften session isolation claim in github_copilot_with_session sample - Fix inline_yaml sample: pass project_endpoint via client_kwargs instead of relying on YAML connection block (AzureAIClient expects project_endpoint, not endpoint) - Handle raw JSON schemas in Responses client _convert_response_format so declarative outputSchema works with the Responses API Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Improve raw JSON schema detection heuristic and add tests - Broaden raw schema detection to handle anyOf, oneOf, allOf, $ref, $defs keywords and JSON Schema primitive types, not just 'properties' - Apply same raw schema handling to azure-ai _shared.py for consistency - Add unit tests for both openai and azure-ai response_format conversion Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
cc0cfaaac8
commit
6b47cdbf52
@@ -636,6 +636,27 @@ class RawOpenAIChatClient( # type: ignore[misc]
|
||||
if format_type in {"json_object", "text"}:
|
||||
return {"type": format_type}
|
||||
|
||||
# Handle raw JSON schemas (e.g. {"type": "object", "properties": {...}})
|
||||
# by wrapping them in the expected json_schema envelope.
|
||||
# Detect by checking for JSON Schema primitive types or known schema keywords.
|
||||
json_schema_keywords = {"properties", "anyOf", "oneOf", "allOf", "$ref", "$defs"}
|
||||
json_schema_primitive_types = {"object", "array", "string", "number", "integer", "boolean", "null"}
|
||||
if format_type in json_schema_primitive_types or (
|
||||
format_type is None and any(k in response_format for k in json_schema_keywords)
|
||||
):
|
||||
schema = dict(response_format)
|
||||
if schema.get("type") == "object" and "additionalProperties" not in schema:
|
||||
schema["additionalProperties"] = False
|
||||
# Pop title from schema since OpenAI strict mode rejects unknown keys;
|
||||
# use it as the schema name in the envelope instead.
|
||||
name = str(schema.pop("title", None) or "response")
|
||||
return {
|
||||
"type": "json_schema",
|
||||
"name": name,
|
||||
"schema": schema,
|
||||
"strict": True,
|
||||
}
|
||||
|
||||
raise ChatClientInvalidRequestException("Unsupported response_format provided for Responses client.")
|
||||
|
||||
def _get_conversation_id(
|
||||
|
||||
Reference in New Issue
Block a user