MCPcopy Create free account
hub / github.com/Noumena-Network/code / joinTextAtSeam

Function joinTextAtSeam

src/utils/messages.ts:2514–2524  ·  view source on GitHub ↗

* Concatenate two content block arrays, appending `\n` to a's last text block * when the seam is text-text. The API concatenates adjacent text blocks in a * user message without a separator, so two queued prompts `"2 + 2"` + * `"3 + 3"` would otherwise reach the model as `"2 + 23 + 3"`. * * Blo

(
  a: ContentBlockParam[],
  b: ContentBlockParam[],
)

Source from the content-addressed store, hash-verified

2512 * when b is an SR-wrapped attachment.
2513 */
2514function joinTextAtSeam(
2515 a: ContentBlockParam[],
2516 b: ContentBlockParam[],
2517): ContentBlockParam[] {
2518 const lastA = a.at(-1)
2519 const firstB = b[0]
2520 if (lastA?.type === 'text' && firstB?.type === 'text') {
2521 return [...a.slice(0, -1), { ...lastA, text: lastA.text + '\n' }, ...b]
2522 }
2523 return [...a, ...b]
2524}
2525
2526type ToolResultContentItem = Extract<
2527 ToolResultBlockParam['content'],

Callers 1

mergeUserMessagesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected