MCPcopy Create free account
hub / github.com/anomalyco/opencode / extractResponseText

Function extractResponseText

packages/opencode/src/cli/cmd/github.shared.ts:10–18  ·  view source on GitHub ↗
(parts: SessionV1.Part[])

Source from the content-addressed store, hash-verified

8 * Throws only for truly empty responses.
9 */
10export function extractResponseText(parts: SessionV1.Part[]): string | null {
11 const textPart = parts.findLast((p) => p.type === "text")
12 if (textPart) return textPart.text
13
14 // Non-text parts (tools, reasoning, step-start/step-finish, etc.) - signal summary needed
15 if (parts.length > 0) return null
16
17 throw new Error("Failed to parse response: no parts returned")
18}
19
20/**
21 * Formats a PROMPT_TOO_LARGE error message with details about files in the prompt.

Callers 2

chatFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected