mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
DevUI: Serialize workflow input as string to maintain conformance with OpenAI Responses format (#2021)
Co-authored-by: Victor Dibia <chuvidi2003@gmail.com>
This commit is contained in:
co-authored by
Victor Dibia
parent
1aaf37dab8
commit
4201b9a122
@@ -182,7 +182,9 @@ internal sealed class ResponseInputJsonConverter : JsonConverter<ResponseInput>
|
||||
return messages is not null ? ResponseInput.FromMessages(messages) : null;
|
||||
}
|
||||
|
||||
throw new JsonException($"Unexpected token type for ResponseInput: {reader.TokenType}");
|
||||
throw new JsonException(
|
||||
"ResponseInput must be either a string or an array of messages. " +
|
||||
$"Objects are not supported. Received token type: {reader.TokenType}");
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
+14
@@ -344,6 +344,20 @@ public sealed class OpenAIResponsesSerializationTests : ConformanceTestBase
|
||||
Assert.NotNull(request.Input);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_InvalidInputObject_ThrowsHelpfulException()
|
||||
{
|
||||
// Arrange
|
||||
const string Json = "{\"model\":\"gpt-4o-mini\",\"input\":{\"input\":\"testing!\"},\"stream\":true}";
|
||||
|
||||
// Act & Assert
|
||||
var exception = Assert.Throws<JsonException>(() =>
|
||||
JsonSerializer.Deserialize(Json, OpenAIHostingJsonContext.Default.CreateResponse));
|
||||
|
||||
Assert.Contains("ResponseInput must be either a string or an array of messages", exception.Message);
|
||||
Assert.Contains("Objects are not supported", exception.Message);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_AllRequests_CanBeDeserialized()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user