Skip to content

Commit cc65763

Browse files
authored
test: Improved test coverage of normalizing claude 3 messages (#2893)
1 parent 6a83abf commit cc65763

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/unit/llm-events/aws-bedrock/bedrock-command.test.js

+18
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,24 @@ test('claude35 malformed payload produces reasonable values', async (t) => {
217217
assert.equal(cmd.temperature, undefined)
218218
})
219219

220+
test('claude35 skips a message that is null in `body.messages`', async (t) => {
221+
const malformedPayload = structuredClone(claude35)
222+
malformedPayload.body.messages = [{ role: 'user', content: 'who are you' }, null]
223+
t.nr.updatePayload(malformedPayload)
224+
const cmd = new BedrockCommand(t.nr.input)
225+
assert.equal(cmd.isClaude3(), true)
226+
assert.deepEqual(cmd.prompt, [{ role: 'user', content: 'who are you' }])
227+
})
228+
229+
test('claude35 handles defaulting prompt to empty array when `body.messages` is null', async (t) => {
230+
const malformedPayload = structuredClone(claude35)
231+
malformedPayload.body.messages = null
232+
t.nr.updatePayload(malformedPayload)
233+
const cmd = new BedrockCommand(t.nr.input)
234+
assert.equal(cmd.isClaude3(), true)
235+
assert.deepEqual(cmd.prompt, [])
236+
})
237+
220238
test('claude35 minimal command works', async (t) => {
221239
t.nr.updatePayload(structuredClone(claude35))
222240
const cmd = new BedrockCommand(t.nr.input)

0 commit comments

Comments
 (0)