{"record":{"id":"ca595383ba86f256","repo":"microsoft/autogen","slug":"output-schema-must-have-a-title","errorCode":null,"errorMessage":"Output schema must have a title","messagePattern":"Output schema must have a title","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/AutoGen.OpenAI/Agent/OpenAIChatAgent.cs","lineNumber":185,"sourceCode":"        {\n            foreach (var f in openAIFunctionDefinitions)\n            {\n                option.Tools.Add(f);\n            }\n        }\n\n        if (options?.StopSequence is var sequence && sequence is { Length: > 0 })\n        {\n            foreach (var seq in sequence)\n            {\n                option.StopSequences.Add(seq);\n            }\n        }\n\n        if (options?.OutputSchema is not null)\n        {\n            option.ResponseFormat = ChatResponseFormat.CreateJsonSchemaFormat(\n                jsonSchemaFormatName: options.OutputSchema.GetTitle() ?? throw new ArgumentException(\"Output schema must have a title\"),\n                jsonSchema: BinaryData.FromObjectAsJson(options.OutputSchema),\n                jsonSchemaFormatDescription: options.OutputSchema.GetDescription());\n        }\n\n        return option;\n    }\n\n    private static ChatCompletionOptions CreateChatCompletionOptions(\n        float? temperature = 0.7f,\n        int? maxTokens = 1024,\n        int? seed = null,\n        ChatResponseFormat? responseFormat = null,\n        IEnumerable<ChatTool>? functions = null)\n    {\n        var options = new ChatCompletionOptions\n        {\n            Temperature = temperature,\n            MaxOutputTokenCount = maxTokens,","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/dotnet/src/AutoGen.OpenAI/Agent/OpenAIChatAgent.cs#L167-L203","documentation":"ArgumentException thrown in CreateChatCompletionsOptions when GenerateReplyOptions.OutputSchema (a JsonSchema.Net JsonSchema) has no title and the code needs a name for ChatResponseFormat.CreateJsonSchemaFormat. Structured-output mode requires a named schema; an anonymous schema cannot be registered as a JSON schema response format.","triggerScenarios":"Passing new GenerateReplyOptions { OutputSchema = schema } where schema was built without a title (e.g. JsonSchema from a raw JSON string lacking a \"title\" property, or a JsonSchemaBuilder chain without .Title(...)).","commonSituations":"Loading JSON schemas from files/strings for structured output; building schemas via FromType without setting a title; schema authored externally (Apicurio/TypeChat style) with title omitted.","solutions":["Set a title on the schema before passing it: JsonSchemaBuilder...Title(\"MyOutput\").Build(), or add \"title\" to the raw JSON","Build the schema with JsonSchema.Net's builder or FromType<T>() on a named class, which derives a title","Verify options.OutputSchema.GetTitle() returns non-null before calling the agent"],"exampleFix":"// before\nvar schema = JsonSchema.FromText(\"{\\\"type\\\":\\\"object\\\"}\");\nvar opts = new GenerateReplyOptions { OutputSchema = schema }; // throws\n\n// after\nvar schema = JsonSchemaBuilder.FromType<MyResponse>().Title(\"MyResponse\").Build();\nvar opts = new GenerateReplyOptions { OutputSchema = schema };","handlingStrategy":"validation","validationCode":"if (options?.OutputSchema?.GetTitle() is null) { /* set title before calling agent */ }","typeGuard":"static bool SchemaHasTitle(JsonSchema s) => s.GetTitle() is not null;","tryCatchPattern":"catch (ArgumentException ex) when (ex.Message == \"Output schema must have a title\") { /* add .Title(...) and retry */ }","preventionTips":["Build output schemas with JsonSchemaBuilder and always set .Title(name)","Validate external schema files contain \"title\" at load time"],"tags":["autogen","dotnet","openai","json-schema","structured-output"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}