gemini-cli - 💡(How to fix) Fix [AgentProtocol] Enrich AgentEvent for granular tool lifecycle states [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#24993Fetched 2026-04-09 08:16:25
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Assignees
Timeline (top)
labeled ×2assigned ×1parent_issue_added ×1

Currently, the experimental useAgentStream hook loses visual fidelity compared to the stable useGeminiStream implementation. This is because standard tool lifecycle states are not explicitly formalized in the new AgentProtocol types. The UI currently has to rely on legacyState hacks or incomplete mappings to render progress.

To decouple the UI from internal scheduling, the protocol must act as the single source of truth for a tool's current status.

Root Cause

Context

Currently, the experimental useAgentStream hook loses visual fidelity compared to the stable useGeminiStream implementation. This is because standard tool lifecycle states are not explicitly formalized in the new AgentProtocol types. The UI currently has to rely on legacyState hacks or incomplete mappings to render progress.

RAW_BUFFERClick to expand / collapse

Parent tracking issue: #22702

Context

Currently, the experimental useAgentStream hook loses visual fidelity compared to the stable useGeminiStream implementation. This is because standard tool lifecycle states are not explicitly formalized in the new AgentProtocol types. The UI currently has to rely on legacyState hacks or incomplete mappings to render progress.

To decouple the UI from internal scheduling, the protocol must act as the single source of truth for a tool's current status.

Tasks

  • Formalize tool lifecycle states in the AgentProtocol event types:
    • status: 'pending' | 'pending_input' | 'executing' | 'succeeded' | 'errored' | 'aborted'
  • Update LegacyAgentProtocol to emit a tool_update event on every state transition.
  • Refactor the UI (useAgentStream.ts) to rely purely on the standard event status rather than legacyState for these specific status transitions.
    • Scope Note: ONLY remove legacyState dependency for status mapping; keep other legacyState fields intact for now to ensure a surgical change.

Relevant Files

  • `packages/core/src/agent/types.ts`: Define the new status union in `AgentEvent`.
  • `packages/core/src/agent/legacy-agent-session.ts`: Update `LegacyAgentProtocol` to emit status-enriched events.
  • `packages/cli/src/ui/hooks/useAgentStream.ts`: Update the event handler to use the new status field.
  • `packages/core/src/agent/event-translator.ts`: Update translation logic for status mapping.

Acceptance Criteria

  • The TUI accurately reflects a tool's progress through all intermediate states (pending, pending input, executing) using only the typed `AgentProtocol` event stream.

extent analysis

TL;DR

Update the AgentProtocol event types to include formalized tool lifecycle states and refactor the UI to rely on these standard event statuses.

Guidance

  • Formalize tool lifecycle states in the AgentProtocol event types by defining a status union with possible values: 'pending', 'pending_input', 'executing', 'succeeded', 'errored', and 'aborted'.
  • Update LegacyAgentProtocol to emit a tool_update event on every state transition, ensuring the UI receives accurate status updates.
  • Refactor the UI (useAgentStream.ts) to rely purely on the standard event status for specific status transitions, while keeping other legacyState fields intact.

Example

// packages/core/src/agent/types.ts
interface AgentEvent {
  // ...
  status: 'pending' | 'pending_input' | 'executing' | 'succeeded' | 'errored' | 'aborted';
}

// packages/core/src/agent/legacy-agent-session.ts
class LegacyAgentProtocol {
  // ...
  emitToolUpdate(status: 'pending' | 'pending_input' | 'executing' | 'succeeded' | 'errored' | 'aborted') {
    // ...
  }
}

Notes

This solution focuses on updating the AgentProtocol event types and refactoring the UI to rely on these standard event statuses. It does not address potential issues with the event-translator.ts file, which may require additional updates to ensure correct status mapping.

Recommendation

Apply workaround by updating the AgentProtocol event types and refactoring the UI, as this will allow for a more accurate representation of a tool's progress through intermediate states.

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] Enrich AgentEvent for granular tool lifecycle states [1 participants]