Skip to content

fix(agent): stop auto-answering questions before desktop connects#2677

Draft
adamleithp wants to merge 1 commit into
mainfrom
posthog-code/fix-question-auto-dismiss
Draft

fix(agent): stop auto-answering questions before desktop connects#2677
adamleithp wants to merge 1 commit into
mainfrom
posthog-code/fix-question-auto-dismiss

Conversation

@adamleithp

Copy link
Copy Markdown
Contributor

Problem

Users reported that the agent's question prompts (AskUserQuestion) were sometimes auto-dismissed or auto-answered without any interaction — the agent would continue as if the question had been answered. It was intermittent, which pointed at a race.

Closes #2550

Changes

In createCloudClient.requestPermission, questions only relayed to the desktop when session.hasDesktopConnected was already true. That flag starts false for cloud-initialized sessions and only flips true once the desktop's SSE stream attaches. A question fired during that startup window fell through to the auto-approve path and silently picked the first option — surfacing as "Question answered"/"Answer received".

Now questions always relay and wait, exactly like plan approvals. The permission_request is buffered and replayed when the desktop connects (and persisted to the log), so an early question is no longer auto-answered.

How did you test this?

  • Updated question-relay.test.ts: the test that previously asserted questions auto-approve without a desktop now asserts they relay and stay pending until answered (regression test).
  • Ran pnpm --filter @posthog/agent test question-relay — all 43 tests pass.
  • Ran pnpm --filter @posthog/agent typecheck and biome lint on the changed files — clean.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code from a Slack thread

AskUserQuestion tool calls were intermittently being auto-answered (surfacing as "Question answered"/"Answer received") without any user interaction.

In createCloudClient.requestPermission, questions only relayed to the desktop when session.hasDesktopConnected was already true. That flag starts false for cloud-initialized sessions and only flips true once the desktop's SSE stream attaches. If the agent fired a question during that startup window, it fell through to the auto-approve path and silently selected the first option — the race that made it intermittent.

Treat questions like plan approvals: always relay and wait. The permission_request is buffered by broadcastEvent and replayed when the desktop connects (and persisted to the log), so an early question is no longer auto-answered.

Generated-By: PostHog Code
Task-Id: 4c98167b-4c73-424e-9f2c-0e1200d41041
@github-actions

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit e1ea1a8.

@greptile-apps

greptile-apps Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(agent): stop auto-answering question..." | Re-trigger Greptile

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.

Question tool skips and responds no answer

1 participant