run-llama/LlamaIndexTS

ValidationException when using bedrock claude model with multi-agent

Open

#2,133 opened on Jul 23, 2025

 (4 comments) (0 reactions) (0 assignees)TypeScript (524 forks)auto 404
good first issuehelp wanted

Repository metrics

Stars
 (3,078 stars)
PR merge metrics
 (PR metrics pending)

Description

Not sure if this is a bug, some mistake on my end, or weird LLM io.

Test code:

import "dotenv/config.js";
import { tool } from "llamaindex";
import { multiAgent, agent } from "@llamaindex/workflow";
import { z } from "zod";
import { Bedrock } from '@llamaindex/aws';


const claude = new Bedrock({
    model: process.env.CLAUDE_3_SONNET_MODEL_ID as string, // same as BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_SONNET
    region: process.env.BEDROCK_REGION, //i have tried with both apac and us models
    credentials: {
      accessKeyId: process.env.AWS_ACCESS_KEY_ID as string,
      secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY as string
    }
});

// Create a weather agent
const weatherAgent = agent({
  name: "WeatherAgent",
  description: "Provides weather information for any city",
  tools: [
    tool(
      {
        name: "fetchWeather",
        description: "Get weather information for a city",
        parameters: z.object({
          city: z.string(),
        }),
        execute: ({ city }) => `The weather in ${city} is sunny`,
      }
    ),
  ],
  llm: claude,
  verbose: true,
});

const jokeTool = tool(() => "Baby Llama is called cria", {
  name: "joke",
  description: "Use this tool to get a joke",
});

// Create a joke-telling agent
const jokeAgent = agent({
  name: "JokeAgent",
  description: "Tells jokes and funny stories",
  tools: [jokeTool], // Using the joke tool defined earlier
  llm: claude, //claude doesnt work!
  canHandoffTo: [weatherAgent], // Can hand off to the weather agent
  verbose: true,
});

// Create the multi-agent workflow
const agents = multiAgent({
  agents: [jokeAgent, weatherAgent],
  rootAgent: jokeAgent, // Start with the joke agent
  verbose: true,
});

// Run the workflow
const result = await agents.run(
  "Give me a morning greeting with a joke and the weather in San Francisco"
);
console.log(result.data.result);

Output:

[Agent JokeAgent]: Starting agent
<path>\llamaindex-test\node_modules\@aws-sdk\client-bedrock-runtime\dist-cjs\index.js:1750
  const exception = new ValidationException({
                    ^

ValidationException: Malformed input request: #: subject must not be valid against schema {"required":["messages"]}#/tools/0: required key [input_schema] not found#/tools/0: required key [type] not found#/tools/0: extraneous key [description] is not permitted#/tools/0/name: #/tools/0/name: joke is not a valid enum value#/tools/0: required key [type] not found#/tools/0: required key [display_height_px] not found#/tools/0: required key [display_width_px] not found#/tools/0: extraneous key [description] is not permitted#/tools/0/name: #/tools/0/name: joke is not a valid enum value#/tools/0: required key [type] not found#/tools/0: extraneous key [description] is not permitted#/tools/0/name: #/tools/0/name: joke is not a valid enum value, please reformat your input and try again.
    at de_ValidationExceptionRes (<path>llamaindex-test\node_modules\@aws-sdk\client-bedrock-runtime\dist-cjs\index.js:1750:21)
    at de_CommandError (<path>llamaindex-test\node_modules\@aws-sdk\client-bedrock-runtime\dist-cjs\index.js:1567:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async <path>\llamaindex-test\node_modules\@smithy\middleware-serde\dist-cjs\index.js:36:20
    at async <path>\llamaindex-test\node_modules\@smithy\core\dist-cjs\index.js:193:18
    at async <path>\llamaindex-test\node_modules\@smithy\middleware-retry\dist-cjs\index.js:320:38
    at async <path>\llamaindex-test\node_modules\@aws-sdk\middleware-logger\dist-cjs\index.js:33:22
    at async Bedrock.streamChat (<path>/llamaindex-test/node_modules/@llamaindex/aws/dist/llm/bedrock/index.js:1481:26)
    at async response.<computed> (<path>/llamaindex-test/node_modules/@llamaindex/core/decorator/dist/index.js:90:34)
    at async FunctionAgent.takeStep (<path>/llamaindex-test/node_modules/@llamaindex/workflow/dist/index.js:94:26) {
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 400,
    requestId: '33d21fd9-d94e-4795-9208-e75b066d97f0',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  }
}

Node.js v22.15.0

Originally posted by @tersimdev in https://github.com/run-llama/LlamaIndexTS/discussions/2125

Contributor guide