langchain-aws icon indicating copy to clipboard operation
langchain-aws copied to clipboard

Frequent "list index out of range" validation errors.

Open peterkarman1 opened this issue 2 months ago • 1 comments

When using ChatBedrockConverse, I am frequently getting the following error message:

in _make_api_call\n    raise error_class(parsed_response, operation_name)\nbotocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the Converse operation: The model returned the following errors: {"error":{"message":"ErrorEvent { error: APIError { type: \\"BadRequestError\\", code: Some(400), message: \\"list index out of range\\", param: None } }","type":"invalid_request_error"}}

This is happening with all Qwen models (sometimes deepseek but seems far less frequent. Hard to recreate). This seems to happen when there have been 30+ tool calls by the agent. Unfortunately I can't paste my exact inputs here but I can say the context length is around 11,000 tokens (using a simple characters/4 to count tokens).

Is there any way to figure out what is going on? This seems to be getting worse.

Here is a sample of my model

ChatBedrockConverse(
            model="qwen.qwen3-coder-480b-a35b-v1:0",
            temperature=0.5,
            max_tokens=AppConfig.MAX_OUTPUT_TOKENS,
            region_name=region_name,
            stop=None,
            client=client,
        )

And this is my agent

        agent = create_react_agent(
            model=llm,
            tools=tools,
            prompt=SystemMessage(content=prompt),
            debug=Env.LLM_VERBOSE,
            checkpointer=checkpointer,
        )

peterkarman1 avatar Oct 15 '25 00:10 peterkarman1

For some reason, retrying the calls works in general. Not sure why this is happening. Perhaps we need a way to specify other error types to be retryable as this comes back as a validation error and is not retryable by botocore

peterkarman1 avatar Oct 21 '25 17:10 peterkarman1