Fix Opus 4.6 thinking blocks, re-add Amazon Nova models

- Opus 4.6 returns multiple content blocks (thinking + text); was only
  reading content[0] which was the thinking block (just '{')
- Now iterates all blocks and extracts only type:'text' blocks
- Added debug logging for Bedrock response structure
- Re-added Nova Pro, Nova Lite, Nova Micro with correct region metadata
This commit is contained in:
Daniel Onyejesi 2026-03-24 18:05:27 -04:00
parent 8f0f9ff9e6
commit e4faf07a6d
2 changed files with 29 additions and 1 deletions

View file

@ -190,9 +190,29 @@ async function callBedrock(messages, model, temperature, maxTokens) {
var response = await bedrockClient.send(command);
var responseBody = JSON.parse(new TextDecoder().decode(response.body));
// Debug: log response structure for troubleshooting
if (Array.isArray(responseBody.content)) {
console.log('[Bedrock] Model:', modelId, '| Blocks:', responseBody.content.map(function(b) { return b.type; }).join(', '), '| stop_reason:', responseBody.stop_reason);
}
// Opus 4.6+ may return multiple content blocks (thinking + text).
// Extract all text blocks, skipping thinking blocks.
var textContent = '';
if (Array.isArray(responseBody.content)) {
responseBody.content.forEach(function(block) {
if (block.type === 'text' && block.text) textContent += block.text;
});
// Fallback: if no text blocks found, try first block
if (!textContent && responseBody.content[0]) {
textContent = responseBody.content[0].text || '';
}
} else {
textContent = responseBody.content || '';
}
return {
success: true,
content: responseBody.content[0].text,
content: textContent,
model: modelId,
provider: 'bedrock',
usage: {

View file

@ -46,6 +46,14 @@ var BEDROCK_MODELS = [
{ id: 'anthropic/vendor-model-3.5-haiku', name: 'vendor model 3.5 Haiku', cost: '~$0.002', tag: 'VALUE', category: 'smart',
bedrockId: 'anthropic.agent-config-3-5-haiku-20241022-v1:0', regions: ['us-west-2', 'us-east-1', 'us-east-2'] },
// ── Amazon Nova (on-demand, fast + cheap) ──
{ id: 'amazon/nova-pro', name: 'Amazon Nova Pro', cost: '~$0.008', tag: 'SMART', category: 'smart',
bedrockId: 'amazon.nova-pro-v1:0', regions: ['us-east-1', 'ap-southeast-2', 'ap-southeast-3', 'eu-west-2', 'me-central-1'] },
{ id: 'amazon/nova-lite', name: 'Amazon Nova Lite', cost: '~$0.001', tag: 'FAST', category: 'fast',
bedrockId: 'amazon.nova-lite-v1:0', regions: ['us-east-1', 'ap-northeast-1', 'ap-southeast-2', 'ap-southeast-3', 'eu-north-1', 'eu-west-2', 'me-central-1'] },
{ id: 'amazon/nova-micro', name: 'Amazon Nova Micro', cost: '~$0.0004', tag: 'CHEAPEST', category: 'fast',
bedrockId: 'amazon.nova-micro-v1:0', regions: ['us-east-1', 'ap-southeast-2', 'eu-west-2'] },
// ── Meta Llama (on-demand, good for clinical summarisation) ──
{ id: 'meta/llama-4-maverick', name: 'Llama 4 Maverick', cost: '~$0.005', tag: 'NEW', category: 'smart',
bedrockId: 'meta.llama4-maverick-17b-instruct-v1:0', regions: ['us-east-1', 'us-east-2', 'us-west-1', 'us-west-2'] },