@@ -356,6 +356,7 @@ public override void Write(Utf8JsonWriter writer, ContentBlock value, JsonSerial
356356}
357357
358358/// <summary>Represents text provided to or from an LLM.</summary>
359+ [ DebuggerDisplay ( "Text = \" {Text}\" " ) ]
359360public sealed class TextContentBlock : ContentBlock
360361{
361362 /// <inheritdoc/>
@@ -366,9 +367,13 @@ public sealed class TextContentBlock : ContentBlock
366367 /// </summary>
367368 [ JsonPropertyName ( "text" ) ]
368369 public required string Text { get ; set ; }
370+
371+ /// <inheritdoc/>
372+ public override string ToString ( ) => Text ?? "" ;
369373}
370374
371375/// <summary>Represents an image provided to or from an LLM.</summary>
376+ [ DebuggerDisplay ( "{DebuggerDisplay,nq}" ) ]
372377public sealed class ImageContentBlock : ContentBlock
373378{
374379 /// <inheritdoc/>
@@ -388,9 +393,13 @@ public sealed class ImageContentBlock : ContentBlock
388393 /// </remarks>
389394 [ JsonPropertyName ( "mimeType" ) ]
390395 public required string MimeType { get ; set ; }
396+
397+ [ DebuggerBrowsable ( DebuggerBrowsableState . Never ) ]
398+ private string DebuggerDisplay => $ "MimeType = { MimeType } , Length = { DebuggerDisplayHelper . GetBase64LengthDisplay ( Data ) } ";
391399}
392400
393401/// <summary>Represents audio provided to or from an LLM.</summary>
402+ [ DebuggerDisplay ( "{DebuggerDisplay,nq}" ) ]
394403public sealed class AudioContentBlock : ContentBlock
395404{
396405 /// <inheritdoc/>
@@ -410,12 +419,16 @@ public sealed class AudioContentBlock : ContentBlock
410419 /// </remarks>
411420 [ JsonPropertyName ( "mimeType" ) ]
412421 public required string MimeType { get ; set ; }
422+
423+ [ DebuggerBrowsable ( DebuggerBrowsableState . Never ) ]
424+ private string DebuggerDisplay => $ "MimeType = { MimeType } , Length = { DebuggerDisplayHelper . GetBase64LengthDisplay ( Data ) } ";
413425}
414426
415427/// <summary>Represents the contents of a resource, embedded into a prompt or tool call result.</summary>
416428/// <remarks>
417429/// It is up to the client how best to render embedded resources for the benefit of the LLM and/or the user.
418430/// </remarks>
431+ [ DebuggerDisplay ( "{DebuggerDisplay,nq}" ) ]
419432public sealed class EmbeddedResourceBlock : ContentBlock
420433{
421434 /// <inheritdoc/>
@@ -433,12 +446,16 @@ public sealed class EmbeddedResourceBlock : ContentBlock
433446 /// </remarks>
434447 [ JsonPropertyName ( "resource" ) ]
435448 public required ResourceContents Resource { get ; set ; }
449+
450+ [ DebuggerBrowsable ( DebuggerBrowsableState . Never ) ]
451+ private string DebuggerDisplay => $ "Uri = \" { Resource . Uri } \" ";
436452}
437453
438454/// <summary>Represents a resource that the server is capable of reading, included in a prompt or tool call result.</summary>
439455/// <remarks>
440456/// Resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.
441457/// </remarks>
458+ [ DebuggerDisplay ( "Name = {Name}, Uri = \" {Uri}\" " ) ]
442459public sealed class ResourceLinkBlock : ContentBlock
443460{
444461 /// <inheritdoc/>
@@ -503,6 +520,7 @@ public sealed class ResourceLinkBlock : ContentBlock
503520}
504521
505522/// <summary>Represents a request from the assistant to call a tool.</summary>
523+ [ DebuggerDisplay ( "Name = {Name}, Id = {Id}" ) ]
506524public sealed class ToolUseContentBlock : ContentBlock
507525{
508526 /// <inheritdoc/>
@@ -531,6 +549,7 @@ public sealed class ToolUseContentBlock : ContentBlock
531549}
532550
533551/// <summary>Represents the result of a tool use, provided by the user back to the assistant.</summary>
552+ [ DebuggerDisplay ( "{DebuggerDisplay,nq}" ) ]
534553public sealed class ToolResultContentBlock : ContentBlock
535554{
536555 /// <inheritdoc/>
@@ -575,4 +594,37 @@ public sealed class ToolResultContentBlock : ContentBlock
575594 /// </remarks>
576595 [ JsonPropertyName ( "isError" ) ]
577596 public bool ? IsError { get ; set ; }
597+
598+ [ DebuggerBrowsable ( DebuggerBrowsableState . Never ) ]
599+ private string DebuggerDisplay
600+ {
601+ get
602+ {
603+ if ( IsError == true )
604+ {
605+ return $ "ToolUseId = { ToolUseId } , IsError = true";
606+ }
607+
608+ // Try to show the result content
609+ if ( Content . Count == 1 && Content [ 0 ] is TextContentBlock textBlock )
610+ {
611+ return $ "ToolUseId = { ToolUseId } , Result = \" { textBlock . Text } \" ";
612+ }
613+
614+ if ( StructuredContent . HasValue )
615+ {
616+ try
617+ {
618+ string json = StructuredContent . Value . GetRawText ( ) ;
619+ return $ "ToolUseId = { ToolUseId } , Result = { json } ";
620+ }
621+ catch
622+ {
623+ // Fall back to content count if GetRawText fails
624+ }
625+ }
626+
627+ return $ "ToolUseId = { ToolUseId } , ContentCount = { Content . Count } ";
628+ }
629+ }
578630}
0 commit comments