gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Agent State Confusion: Agent adopts the context of a log file it is analyzing

Open hebenezer-m opened this issue 1 year ago • 2 comments

What happened?

When analyzing a long and complex session log file, the agent incorrectly adopted the context of the log's content as its current task. After receiving an ambiguous command ("Please continue"), instead of continuing the analysis of the log, the agent attempted to resume the last pending task described within the log file. This led to a complete deviation from the user's intended task.

What did you expect to happen?

The agent should maintain a clear separation between its current task context and the content of the data it is processing. When faced with an ambiguous command after a complex analysis, the agent should:

  1. Remain in the context of the current task (e.g., "analyzing the log").
  2. Ask for clarification from the user. For example: "Should I continue analyzing the log for more insights, or is there something else you'd like to do?" It should NOT adopt the state or tasks from the content of the file being analyzed.

Client information

$ gemini /about
# OS: Linux (Crostini Bookworm)
# Terminal: Konsole
# (User to fill in gemini-cli version if known)

Login information

N/A (This is a core agent behavior issue, not related to login method).

Anything else we need to know?

This issue appears to be a specific, reproducible instance of a broader class of "state degradation" or "context confusion" problems. While other issues (#3, #1) touch on loops and state degradation, this one highlights a critical flaw where the agent fails to distinguish between its operational context and the data it's analyzing. Fixing this would significantly improve the agent's reliability and prevent unpredictable behavior. The core problem seems to be a failure in context management, specifically in handling nested or ambiguous contexts.

hebenezer-m avatar Jul 22 '25 02:07 hebenezer-m

A very common (almost banal) error in most AIs (and some humans), see: https://en.wikipedia.org/wiki/Map%E2%80%93territory_relation for the ancient background thereof.

My practical tip: do separate that map from the territory for the model.

Manamama avatar Jul 22 '25 11:07 Manamama

Hello! As part of our effort to keep our backlog manageable and focus on the most active issues, we are tidying up older reports.

It looks like this issue hasn't been active for a while, so we are closing it for now. However, if you are still experiencing this bug on the latest stable build, please feel free to comment on this issue or create a new one with updated details.

Thank you for your contribution!

gemini-cli[bot] avatar Dec 03 '25 21:12 gemini-cli[bot]