Elffuss BraidHub

kikocis/continue public

fix empty message bedrock openai adapter bug
Changeset91054b807bf2e526364f182ff1cc5e1390aaa8620208986b8ea7036792947111
AuthorDallin Romney <dallinromney@gmail.com> · 2025-07-07 15:29 -07:00
CommitterDallin Romney <dallinromney@gmail.com> · 2025-07-07 15:29 -07:00
Parentse317d4ccae55

Browse the files at this changeset

1 file changed

modified packages/openai-adapters/src/apis/Bedrock.ts +16 −9
@@ -181,7 +181,10 @@
181181 const trimmedContent =
182182 typeof message.content === "string"
183183 ? message.content.trim()
184- : JSON.stringify(message.content);
184+ : message.content
185+ .map((c) => c.text)
186+ .join("\n")
187+ .trim();
185188
186189 if (hasAddedToolCallIds.has(message.tool_call_id)) {
187190 currentBlocks.push({
@@ -208,15 +211,19 @@
208211 }
209212
210213 // ASSISTANT messages
211- const content = message.content;
212- if (content) {
213- if (typeof content === "string") {
214- currentBlocks.push({ text: content });
215- } else {
216- content.forEach((part) => {
217- currentBlocks.push(this._oaiPartToBedrockPart(part));
218- });
214+ if (typeof message.content === "string") {
215+ const trimmedText = message.content.trim();
216+ if (trimmedText) {
217+ currentBlocks.push({ text: trimmedText });
219218 }
219+ } else {
220+ message.content?.forEach((part) => {
221+ const text = part.type === "text" ? part.text : part.refusal;
222+ const trimmedText = text.trim();
223+ if (trimmedText) {
224+ currentBlocks.push({ text: trimmedText });
225+ }
226+ });
220227 }
221228
222229 // TOOL CALLS