Skip to content

feat(cli): suppress newsletter prompt in non-interactive sessions#4258

Open
eyalb181 wants to merge 1 commit into
metalbear-co:mainfrom
eyalb181:suppress-prompts-in-agent-context
Open

feat(cli): suppress newsletter prompt in non-interactive sessions#4258
eyalb181 wants to merge 1 commit into
metalbear-co:mainfrom
eyalb181:suppress-prompts-in-agent-context

Conversation

@eyalb181
Copy link
Copy Markdown
Member

@eyalb181 eyalb181 commented May 10, 2026

Summary

Suppresses the in-CLI newsletter prompt in non-interactive sessions (CI, AI agent runners, piped output). The session counter is not bumped either, so automated runs don't push human users past prompt thresholds before a human ever sees one.

Detected via MIRRORD_PROGRESS_MODE, stderr TTY status, and well-known CI / agent env vars (CI, GITHUB_ACTIONS, CIRCLECI, GITLAB_CI, BUILDKITE, JENKINS_URL, TRAVIS, TF_BUILD, CLAUDECODE, CURSOR_AGENT, AIDER_CHAT).

Validation

Tested end-to-end against the staging cluster from a Claude Code agent session (CLAUDECODE=1, stderr piped). With session_count primed near a prompt threshold:

Binary Pre session_count Post session_count Verdict
This PR 19 19 counter not bumped, gate fires before prompt path
Installed 3.198.0 (no fix) 4 5 counter bumped, demonstrating the behavior this fix changes

Test plan

  • CI passes
  • Interactive mirrord exec → prompt fires when threshold reached
  • CI=true mirrord exec → no prompt, no counter bump
  • mirrord exec | cat → no prompt
  • Subsequent interactive run shows the human's next threshold (counter wasn't inflated)

🤖 Generated with Claude Code

@eyalb181 eyalb181 force-pushed the suppress-prompts-in-agent-context branch from 9a5691d to d1dba82 Compare May 11, 2026 09:18
The newsletter prompt is meant for humans who can act on it (clicking
through to subscribe). Surfacing it to an automated caller — a CI
pipeline, an AI coding agent like Claude Code or Cursor, or any
stdout-captured invocation — has two failure modes:

1. The prompt is noise in the agent's tool output, eating context
   tokens and potentially confusing the model (e.g. interpreting
   ">> mirrord newsletter" as an instruction to run that command).
2. The persisted session counter ticks once per run regardless of
   who's running. An agent doing trial-and-error workflows can
   blow through every prompt threshold (5, 20, 100) in a single
   session — meaning when a human user later sits down at the
   same machine, the prompts they'd otherwise see have already
   fired and been missed.

Add an `interactive_session` module with a heuristic that returns
false for:
- `MIRRORD_PROGRESS_MODE=json` or `=off` (output being parsed)
- Stderr not connected to a TTY (output piped/captured)
- Well-known CI / agent env vars set: CI, GITHUB_ACTIONS,
  CIRCLECI, GITLAB_CI, BUILDKITE, JENKINS_URL, TRAVIS, TF_BUILD,
  CLAUDECODE, CURSOR_AGENT, AIDER_CHAT

When the heuristic returns false, `suggest_newsletter_signup`
returns early without bumping `session_count`, preserving the
human user's prompt cadence.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@eyalb181 eyalb181 force-pushed the suppress-prompts-in-agent-context branch from d1dba82 to 8a44ce6 Compare May 11, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant