Skip to content

Agent hint for gh event listen: add an opt-out, and show it only when the caller polls #15113

Open

Description

@shauneccles

Describe the feature or problem you'd like to solve

Since 2.105.0 (#15077), gh api repos/O/R/pulls/N/..., gh pr view and gh pr create print a nine-line gh event listen hint on stderr whenever an agent is detected. Nothing turns it off: gh help environment and gh config have no key for it, so the only escape is to unset AI_AGENT, CLAUDECODE and friends for every gh call, which also removes the agent from the User-Agent.

We don't poll. Our agents wait on pull requests through a self-hosted service (below), and they call gh api .../pulls/N/comments or gh pr view for one-off reads: listing unanswered review threads, fetching a comment id to reply to, checking a field. Every one of those reads now carries the hint. An agent's stderr goes straight into its context window, where it stays and is re-read on each later model call until the context is compacted.

Measured from our Claude Code transcripts between installing 2.105.0 (2026-11-18 10:54 UTC) and 2026-11-20 07:50 UTC, about 45 hours:

Transcripts containing the hint 38 (9 sessions and their subagents)
Hints printed 162
One hint ~810 characters, ~195 tokens
Tokens added to context ~32,000
Tokens re-read by later model calls before compaction ~8.0 million

The five sessions with the most hints, each counted with its subagents:

Session Hints Tokens added Tokens re-read
A 62 12,300 2.6M
B 51 10,100 3.5M
C 26 5,100 1.0M
D 8 1,600 0.34M
E 6 1,200 0.15M

Method: each hint's length times the number of distinct model requests after it in the same transcript, up to the next compaction. Token counts use o200k_base as a stand-in tokenizer. Most re-reads are prompt-cache hits, so the bigger costs are context-window room and earlier compaction.

Proposed solution

  1. An opt-out, in the style of GH_NO_UPDATE_NOTIFIER: for example GH_NO_AGENT_HINTS=1 or gh config set agent_hints disabled, listed in gh help environment.
  2. Show the hint for polling, not for the first read. Print it only when the same pull request has been read several times within a few minutes, or at most once per pull request per day, using the cache directory to remember. A single GET of /pulls/N/comments is not a wait loop.
  3. Make it one line, such as hint: to wait for this pull request, see gh event listen --help. The details are already in that help text.

Additional context

We wait on pull requests through our own watcher rather than gh event listen. What the Events API would need for us to switch is platform feedback, so it is in the Event Streams preview discussion (https://github.com/orgs/community/discussions/211595), not here. This issue is only about the hint gh prints.

Activity

  1. cli-triage commented on Nov 20, 2026

    @cli-triage

    Version 2.105.0 documents the new agent hint, but gh help environment does not list a way to disable it. The selected source build has the same environment help. This means the requested opt-out is not currently supported through a documented environment variable. The report also identifies a clear behavior gap: one-off reads receive guidance intended for polling, and repeated multi-line stderr output can add avoidable agent context. Tracking an opt-out and less repetitive presentation as an enhancement makes sense. The exact suppression policy can be decided during design.

    Supporting reports

    Generated by issue triage.

  2. added
    enhancement
    gh-api
    on Nov 20, 2026
  3. github-actions commented on Nov 20, 2026

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

    Unless you see the help wanted Contributions welcome label, we are not currently looking for external contributions for this feature.

    If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

  4. removed
    needs-triage
    on Nov 20, 2026
  5. babakks commented on Nov 21, 2026

    @babakks
    Member

    Thanks for the detailed report and the numbers behind it, @shauneccles! 🙏

    The measurements are really helpful, and you're right that a one-off read is not a wait loop. Here are my thoughts on each proposal:

    1. Opt-out: This makes sense to me. An environment variable in the style of GH_NO_UPDATE_NOTIFIER, along with a matching gh config option for a persistent setting, would let setups like yours, which already have their own way of waiting, turn the hint off without having to hide the agent from gh.
    2. Hinting only when polling: @williammartin and I talked about this approach in the early days of development, but left it out because of its complexity. Detecting polling means tracking calls and storing state between invocations, which gets tricky when several sessions or subagents work on the same pull request. On top of that, not every environment is writable. Agents increasingly run in sandboxes, where storing that state would fail, so those agents would never be hinted at all.
    3. A one-line hint pointing at the help: I looked into this approach as well, but the evals showed that pointing agents at gh event listen --help is not an effective way to get them to use the command, so I kept the copyable command in the hint.

    I'll keep this open as an enhancement and update here once I've settled on the opt-out.

    @BagToad, I'd love to hear your thoughts on this.

  6. added
    gh-event
    on Nov 21, 2026
  7. kym6464 commented on Nov 21, 2026

    @kym6464

    (My 2 cents in case it's helpful) With this approach, you need a way to ensure it only fires once per session. Otherwise, you are costing people money and hurting their agents' performance by wasting precious context.

    In Claude Code, you could do this via a plugin + claude-state (I often use this "one-time hint" pattern to inject point-in-time context). I personally would not install a GitHub CLI plugin that does only this one thing (I'd rather create a shim that unsets these env vars). However, if the plugin had other benefits, I may consider it, and that would unlock a lot of cool use cases for the GitHub CLI team.

    You could technically do this in the CLI itself: you already read the harness's env vars, and Claude Code exposes CLAUDE_CODE_SESSION_ID, so a marker file per session ID in the cache dir would work (if the write fails, fall back to today's behavior). But the CLI still can't know when the hint has left the agent's context (compaction, subagents, etc), which is why I think a proper solution requires integrating with each harness.

  8. Blondie0123 commented on Nov 22, 2026

    @Blondie0123
  9. aw632 commented on Nov 24, 2026

    @aw632

    It's incredibly annoying that gh event listen runs all the time when event listening is not even available to all accounts, or even the vast majority of accounts. It's noise with no resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgh-apigh-event

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions