Error Code 400 for Repetitive Prompt Patterns

Hello, I am having an issue which randomly occurred.
I am using a ReAct agent with LlamaIndex and the issue that started happening randomly is this error 400 code that says my prompt is repetitive. Although my prompt is very simple and it is what I have been using successfully before the error began.

I am currently testing with OpenAIAgent and I get the same message, but the system reruns itself and it is able to complete successfully.

This is the error code:
Error code: 400 - {‘error’: {‘message’: “Sorry! We’ve encountered an issue with repetitive patterns in your prompt. Please try again with a different prompt.”, ‘type’: ‘invalid_request_error’, ‘param’: ‘prompt’, ‘code’: None}}

My system is essentially based off of the following documentation:
LlamaIndex Finetuning a GPT3.5 ReAct Agent on Better Chain of Thought

This is my function:
def react_agent(query_engine_tools):
llm = OpenAI(model=“gpt-3.5-turbo-0613”, temperature=0.3)
base_agent = ReActAgent.from_tools(query_engine_tools, llm=llm, verbose=True)
response =
“Analyze AWS IAM”
“WHAT does IAM do?”
“WHO is able to manage it?”

1 Like

I have also encountered a similar error. The model was gpt-3.5-turbo-16k.
Commenting to share it’s not an isolated incident.

1 Like

I’ve experienced the same issue using the gpt-3.5-turbo-16k model.

In my script, I iterate over bodies of text sending chunks further for analysis. The error message you signaled only appeared once. Upon inspecting the prompt that had been sent to the model, I noticed there was one word inside which repeated itself numerous times in a row. Removing that word solved the issue.

Perhaps there’s something similar going on with your prompt?

I also have this issue and it’s blocking !! I’m running a script on tons of data!

EDIT: the reason is because of repetitive characters"\n\n.\n\n." etc… Basically it’s a pattern… I think OpenAI does this to protect against “brute-force/jailbreaks”

I am also getting the same error with my prompt. Have any one of you resolve it?

+1 same issue here. Running through ~100K inputs in chunks of 10K using the File & Batch API. 2 out of 10 files failed.

Does the OpenAI team have any inputs here?

Encountering the same issue. Any support from OpenAI?

You don’t think that we’re going to encounter the same prompt over a batch of data?

This issue is blocking.

Ah, okay. It looks like this issue is due to bad data that was injected into the prompt. I think the error message is misleading for some, and could use further elaboration to point API users toward bad data instead of what they think of as the prompt.