Skip to content

Invalid prompt escape while serializing settings #393

@xeo545x39

Description

@xeo545x39

What is the current behavior?

Serializer does not handle escaping JSON properly - new lines etc.

2026-01-27 11:22:45.620 [Error] Connect: System.Text.Json.JsonReaderException thrown '0x0A' is invalid within a JSON string. The string should be correctly escaped. LineNumber: 27 | BytePositionInLine: 39.

Steps to reproduce

Put new lines and other special characters to [SettingsSchema]settings.Agent.Think.Prompt property.

Expected behavior

Internal JSON for settings should be properly escaped.

Please tell us about your environment

Windows 11

Other information

System.Text.Json.JsonReaderException: '0x0A' is invalid within a JSON string. The string should be correctly escaped. LineNumber: 27 | BytePositionInLine: 39.
   at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
   at System.Text.Json.Utf8JsonReader.ConsumeStringAndValidate(ReadOnlySpan`1 data, Int32 idx)
   at System.Text.Json.Utf8JsonReader.ConsumeString()
   at System.Text.Json.Utf8JsonReader.ConsumeValue(Byte marker)
   at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
   at System.Text.Json.Utf8JsonReader.Read()
   at System.Text.Json.JsonDocument.Parse(ReadOnlySpan`1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack)
   at System.Text.Json.JsonDocument.ParseUnrented(ReadOnlyMemory`1 utf8Json, JsonReaderOptions readerOptions, JsonTokenType tokenType, Boolean allowDuplicateProperties)
   at System.Text.Json.JsonDocument.ParseValue(ReadOnlySpan`1 json, JsonDocumentOptions options)
   at System.Text.Json.Nodes.JsonNode.Parse(String json, Nullable`1 nodeOptions, JsonDocumentOptions documentOptions)
   at Deepgram.Clients.Agent.v2.WebSocket.Client.Connect(SettingsSchema options, CancellationTokenSource cancelToken, Dictionary`2 addons, Dictionary`2 headers)
   at Playground.Deepgram.DeepgramVoiceAssistant.ConfigureAndConnectAsync(CancellationToken cancellationToken) in 
xxx\Playground.Deepgram\DeepgramVoiceAssistant.cs:line 217

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions