Visitar URL original
Python: Invalid schema for response_format 'ManagerSelectionResponse' · Issue #3049 · microsoft/agent-framework · GitHub
Skip to content

Python: Invalid schema for response_format 'ManagerSelectionResponse' #3049

Closed

Description

HI,

Current Setup : i have created multiple agents in AIFoundry with gpt4.1 model, each agent will have list of MCP apis attached to them under actions section

Error Info :
Error 1 :

Coordinator: {"selected_participant":"Agent1","instruction":"<instruction>","finish":false,"final_message":null}executor broke JSON is invalid: Expecting value: line 1 column 1 (char 0)

Error 2 : Coordinator/ manager agent JSON is getting duplicated as shown below

Coordinator: {"selected_participant":"<agentname>","instruction":"<instruction>","finish":false,"final_message":null}{"selected_participant":"<agentname>","instruction":"<instruction>","finish":false,"final_message":null}executor broke 1 validation error for ManagerSelectionResponse
  Invalid JSON: trailing characters at line 1 column 208 [type=json_invalid, input_value='{"selected_participant":...e,"final_message":null}', input_type=str]
   For further information visit https://errors.pydantic.dev/2.12/v/json_invalid

After which i came across below 2 link and i have tried what ever is suggest in those but the issue still exists.

  1. Python: agent_framework.exceptions.ServiceResponseException: <class 'agent_framework_azure_ai._client.AzureAIClient'> service failed to complete the prompt: Error code: 400 - {'error': {'message': "Invalid schema for response_format 'ManagerSelectionResponse'.... #2681
  2. Python: fix: GroupChat ManagerSelectionResponse JSON Schema for OpenAI Structured Outpu… #2750

I have tried to provide strict agent instructions to not generate improper json and also tried providing additional_chat_options as shown below :

response_schema = {
            "title": "ManagerSelectionResponse",
            "type": "object",
            "description": "Response from manager agent with speaker selection decision.",
            "properties": {
                "selected_participant": {
                    "anyOf": [{"type": "string"}, {"type": "null"}],
                    "default": None,
                    "title": "Selected Participant",
                    "description": "Name of participant to speak next (None = finish conversation)",
                },
                "instruction": {
                    "anyOf": [{"type": "string"}, {"type": "null"}],
                    "default": None,
                    "title": "Instruction",
                    "description": "Optional instruction to provide to the selected participant",
                },
                "finish": {
                    "type": "boolean",
                    "default": False,
                    "title": "Finish",
                    "description": "Whether the conversation should be completed",
                },
                "final_message": {
                    "anyOf": [{"type": "string"}, {"type": "null"}],
                    "default": None,
                    "title": "Final Message",
                    "description": "Optional text content for final message",
                },
            },
            # OpenAI strict mode requires all properties to be in required array
            "required": ["selected_participant", "instruction", "finish", "final_message"],
            "additionalProperties": False,
        }

        managerAgent = ChatAgent(            
                chat_client= AzureAIAgentClient(
                    credential=credential,
                    project_endpoint = os.getenv("AZURE_PROJECT_ENDPOINT"),
                    model_deployment_name = os.getenv("AZURE_MODEL_DEPLOYMENT"),         
                    agent_id="<agent_id>"
                ),    
                name="Coordinator" ,
                additional_chat_options={
                "response_format": {
                    "type": "json_schema",
                    "json_schema": {
                        "name": response_schema["title"],
                        "strict": True,
                        "schema": response_schema,
                    },
                },
            }                     
        )

        
        workflow = (
                GroupChatBuilder()
                .set_manager(managerAgent, display_name="Orchestrator")
                .participants([<agent list>])  
                .build()
            )

I also noticed in above issue links they have utilized AzureOpenAIChatClient but in my project i have used AzureAIAgentClient.

Note :

  1. All the agents which are configured inside the workflow return basic string as output not JSON.
  2. i am doing async for event in workflow.run_stream(user_message): to obtain agent streaming output.

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Jan 6, 2026
  2. changed the title [-]Invalid schema for response_format 'ManagerSelectionResponse'[/-] [+]Python: Invalid schema for response_format 'ManagerSelectionResponse'[/+] on Jan 6, 2026
  3. moonbox3 commented on Jan 12, 2026

    @moonbox3
    Contributor

    This should already be fixed? We need to add a model_config = ConfigDict(extra="forbid") to the Pydantic model -- which should be there. What version of the package are you using, GokulNathan (@legendgokul) ?

  4. legendgokul commented on Jan 12, 2026

    @legendgokul
    Author

    Currently using agent-framework 1.0.0b251001

  5. moonbox3 commented on Jan 12, 2026

    @moonbox3
    Contributor

    Currently using agent-framework 1.0.0b251001

    We've had a lot of fixes since October 1. :) I remember fixing this bug a long time ago. Please consider upgrading to our latest version (1.0.0b260107). There are breaking changes from October 1 as we work to solidify the APIs. You can find latest syntax and samples here: https://github.com/microsoft/agent-framework/blob/main/python/samples/getting_started/workflows/orchestration/group_chat_agent_manager.py

  6. moonbox3 commented on Jan 12, 2026

    @moonbox3
    Contributor

    Closing the issue for now. If you continue to hit problems, please either re-open or file a new issue. Thank you.

  7. legendgokul commented on Jan 12, 2026

    @legendgokul
    Author

    sorry the current project contains version : 1.0.0b251218 ( DEC 19 release ), still we are facing same issue.
    I will try updating my project to latest Jan 8th release and will validate if the issue still exists.

  8. legendgokul commented on Jan 12, 2026

    @legendgokul
    Author

    HI Evan Mattson (@moonbox3) i have validated with latest version and i am still able to see above mentioned issues.

    JSON validation error (attempt 1/3)
    Error: 1 validation error for ManagerSelectionResponse
      Invalid JSON: trailing characters at line 1 column 171 [type=json_invalid, input_value='{"selected_participant":...e,"final_message":null}', input_typ
    Retrying...
    
    User 0571eb93-4edd-4414-8263-4f9bfa78b204 is not connected. Message queued or dropped.
    
    Coordinator: {"selected_participant":"AgentName","instruction":"<input question>","finish":false,"final_message":null} 
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

pythonUsage: [Issues, PRs], Target: PythonworkflowsUsage: [Issues, PRs], Target: Workflows

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions