gemini-cli - 💡(How to fix) Fix [AgentProtocol] Introduce generic notice events for system notifications [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#25038Fetched 2026-04-10 03:45:07
View on GitHub
Comments
0
Participants
1
Timeline
5
Reactions
0
Author
Participants
Assignees
Timeline (top)
labeled ×2assigned ×1parent_issue_added ×1unlabeled ×1

In the stable `useGeminiStream`, the UI explicitly listens for and handles platform-specific warnings like `ContextWindowWillOverflow`, `MaxSessionTurns`, and `ChatCompressed`. This forces the UI to contain business logic and messaging specific to the Gemini platform.

To decouple the TUI and support a generic `AgentProtocol`, we should translate these internal platform events into a unified `notice` event. The UI will simply render these notices based on their severity level, acting purely as a display layer.

Note: Errors are already handled by the existing `error` event, and interactive warnings (like Loop Detection) are handled via `elicitation`. The `notice` event is strictly for non-interactive, non-fatal system information.

Error Message

Note: Errors are already handled by the existing `error` event, and interactive warnings (like Loop Detection) are handled via `elicitation`. The `notice` event is strictly for non-interactive, non-fatal system information.

Root Cause

In the stable `useGeminiStream`, the UI explicitly listens for and handles platform-specific warnings like `ContextWindowWillOverflow`, `MaxSessionTurns`, and `ChatCompressed`. This forces the UI to contain business logic and messaging specific to the Gemini platform.

To decouple the TUI and support a generic `AgentProtocol`, we should translate these internal platform events into a unified `notice` event. The UI will simply render these notices based on their severity level, acting purely as a display layer.

Note: Errors are already handled by the existing `error` event, and interactive warnings (like Loop Detection) are handled via `elicitation`. The `notice` event is strictly for non-interactive, non-fatal system information.

RAW_BUFFERClick to expand / collapse

Parent tracking issue: #22702

Context

In the stable `useGeminiStream`, the UI explicitly listens for and handles platform-specific warnings like `ContextWindowWillOverflow`, `MaxSessionTurns`, and `ChatCompressed`. This forces the UI to contain business logic and messaging specific to the Gemini platform.

To decouple the TUI and support a generic `AgentProtocol`, we should translate these internal platform events into a unified `notice` event. The UI will simply render these notices based on their severity level, acting purely as a display layer.

Note: Errors are already handled by the existing `error` event, and interactive warnings (like Loop Detection) are handled via `elicitation`. The `notice` event is strictly for non-interactive, non-fatal system information.

Tasks

  • Add a `notice` event to `AgentEvents` in `packages/core/src/agent/types.ts`:
    • e.g., `notice: { level: 'debug' | 'info' | 'warning', message: string, data?: Record<string, unknown> }`
  • Update `LegacyAgentProtocol` to translate Gemini-specific events into generic `notice` events:
    • Map `ContextWindowWillOverflow` to a `warning` notice.
    • Map `MaxSessionTurns` to a `warning` notice.
    • Map `ChatCompressed` to an `info` notice.
  • Refactor `useAgentStream.ts` to listen for the `notice` event and render it in the UI (e.g., using existing info/warning UI components), removing the need to track individual platform events.

Relevant Files

  • `packages/core/src/agent/types.ts`: Define the `notice` event.
  • `packages/core/src/agent/legacy-agent-session.ts`: Map internal Gemini events to the new `notice` event.
  • `packages/cli/src/ui/hooks/useAgentStream.ts`: Implement a single handler for `notice` events.

Acceptance Criteria

  • Platform warnings (token limits, session limits, chat compression) are successfully displayed in the UI during an active `useAgentStream` session.
  • The UI handles all of these via a single `notice` event handler.
  • No Gemini-specific event handling logic exists in `useAgentStream.ts` for these notifications.

extent analysis

TL;DR

To decouple the TUI and support a generic AgentProtocol, add a notice event to AgentEvents and update LegacyAgentProtocol to translate Gemini-specific events into this unified event.

Guidance

  • Define the notice event in packages/core/src/agent/types.ts with the specified properties (e.g., level, message, data).
  • Update LegacyAgentProtocol in packages/core/src/agent/legacy-agent-session.ts to map Gemini-specific events to the new notice event, following the specified mappings (e.g., ContextWindowWillOverflow to a warning notice).
  • Refactor useAgentStream.ts in packages/cli/src/ui/hooks to listen for the notice event and render it in the UI using existing info/warning UI components.

Example

// packages/core/src/agent/types.ts
export interface AgentEvents {
  // ...
  notice: {
    level: 'debug' | 'info' | 'warning';
    message: string;
    data?: Record<string, unknown>;
  };
}

Notes

This solution assumes that the existing error event and elicitation handling for interactive warnings will continue to function as intended, and that the new notice event will only be used for non-interactive, non-fatal system information.

Recommendation

Apply the workaround by adding the notice event and updating the LegacyAgentProtocol to translate Gemini-specific events, allowing the UI to handle these events in a unified way.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

gemini-cli - 💡(How to fix) Fix [AgentProtocol] Introduce generic notice events for system notifications [1 participants]