MCPcopy Index your code
hub / github.com/coder/coder / appendStreamContentText

Function appendStreamContentText

coderd/x/chatd/chatdebug/model.go:761–805  ·  view source on GitHub ↗
(
	content []normalizedContentPart,
	partType string,
	delta string,
	streamDebugBytes *int,
)

Source from the content-addressed store, hash-verified

759}
760
761func appendStreamContentText(
762 content []normalizedContentPart,
763 partType string,
764 delta string,
765 streamDebugBytes *int,
766) []normalizedContentPart {
767 if delta == "" {
768 return content
769 }
770
771 remaining := maxStreamDebugTextBytes
772 if streamDebugBytes != nil {
773 remaining -= *streamDebugBytes
774 }
775 if remaining <= 0 {
776 return content
777 }
778 if len(delta) > remaining {
779 cut := 0
780 for _, r := range delta {
781 size := utf8.RuneLen(r)
782 if size < 0 {
783 size = 1
784 }
785 if cut+size > remaining {
786 break
787 }
788 cut += size
789 }
790 delta = delta[:cut]
791 }
792 if delta == "" {
793 return content
794 }
795
796 if len(content) == 0 || content[len(content)-1].Type != partType {
797 content = append(content, normalizedContentPart{Type: partType})
798 }
799 last := &content[len(content)-1]
800 last.Text += delta
801 if streamDebugBytes != nil {
802 *streamDebugBytes += len(delta)
803 }
804 return content
805}
806
807// appendStreamToolInput accumulates incremental tool-input deltas
808// per tool call ID so that parallel or sequential tool invocations

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected