Agent performs unexpected behavior

In the “AAA Qualification Mock Exam” agent created with UiPath Studio Web, the following behavior is occurring differently than expected.
This behavior was observed during a debug execution in UiPath Studio Web.
What could be causing this?

Expected behavior: After answering 60 questions, scoring them should assess questions 1 to 60.

Observed behavior: After answering 60 questions and performing the scoring, questions 1 to 22’s response history is not visible, hence only questions 23 to 60 are scored.
To have all questions scored, it is necessary to scroll back through the chat history and present the response history for questions 1 to 22.

Overview of the AAA Qualification Mock Exam: It selects 60 questions randomly from a pre-created pool of 150 questions, presenting them in a one-by-one format.
After completing 60 questions, scoring is performed. The “Mock Exam Question & Answer Explanation Agent” handles question presentation and post-scoring explanations, while the “Question Extraction Flow” randomly extracts the 60 questions.

Agent Properties
Temperature: 0
Maximum tokens per response: 128000

@noobFpath

As per my understanding this is due to context window limitation or the input/output token limits of the LLM model you have selected.

I would suggest using memory store to store/retrieve agent context so it will be able to score based on all the questions.

@noobFpath
This behavior is most likely related to LLM conversation context window limitations and how agent use chat history, rather than the scoring logic itself.​‌

When scoring starts, the model only receives the currently loaded history in the context.​‌

Questions 1-22 are no longer present in the active chat context, so the model can only see and score questions 23-60.

I would recommend Conversational agent only for this use case, or you can try agent memory also.

Hi @noobFpath ,
Save each question and answer in a structured variable or persistent storage as the exam runs. After question 60, pass all saved answers to the scoring logic instead of reading them back from the chat history.

Use this flow:
Ask Question → Save Answer → Next Question → After 60 → Score saved answers

Thanks

Hi @noobFpath,

I don’t think scoring is the problem. The agent can only grade what it can still see in the chat history, and with 60 questions it looks like Q1–Q22 are no longer being passed to the model. That’s why it works when you paste them back in.

Changing max tokens won’t help here. Max tokens only controls the length of the agent response and not how much history the model reads.

Agent memory may not help because it is meant for learning from past cases, not for keeping the answers of one running chat.

I recomment saving each answer outside the chat.

  1. Add a tool that saves the question number, the user’s answer and the correct answer after every reply, in Excel or a database.
  2. Add a second tool that reads all saved answers back.
  3. In the prompt, tell the agent to save every answer, and after question 60 to score only from what the second tool returns.

@Ankit9510
Thank you for your response.
I will try to see if I can solve it your way.