Skip to content

fix(agent): let wizard_ask re-collect a field the downstream call rejected - #1367

Merged
Gilbert09 merged 1 commit into
mainfrom
posthog/ask-correction-carve-out
Oct 5, 2026
Merged

Gilbert09 merged 1 commit into
mainfrom
posthog/ask-correction-carve-out

Conversation

@Gilbert09

Copy link
Copy Markdown
Member

Problem

The seeded warehouse task is the one step of a wizard run that stops to collect live credentials, and a credential the user mistypes — or one PostHog's API rejects for a permission the key lacks — is the normal case, not the edge case. The connection forms behind it are unforgiving: several have a field whose valid value looks very much like a different value the same provider hands out, so a plausible-looking answer that fails validation is routine.

Two pieces of wizard-owned prompt text disagree about what happens next:

  • WIZARD_ASK_SUBJECT_DESCRIPTION tells the agent to reuse the same subject when it is "re-asking after a validation failure", and the ask caps are built around that: a cancelled or timed-out call is refunded, and the adjacency nudge is counted per subject precisely so a legitimate second call about one thing is not blocked.
  • The global wizard_ask commandment said, with no exception: "do not re-ask in text or call wizard_ask again for the same fields."

The commandment ships in the system prompt, so it is the one that wins. Telemetry for this flow carries an agent reporting exactly that conflict — it read the prohibition as absolute after a downstream permission error and abandoned the source for the browser fallback rather than letting the user correct one field. That is the loss the in-CLI source setup exists to avoid, and it costs the run a source the user had already agreed to connect and supplied most of the values for.

Changes

src/agent/commandments.ts — split the final rule of the wizard_ask block in two:

  • Keep the prohibition where it was aimed: do not re-ask in text, and do not call wizard_ask again to confirm a field the user already answered.
  • Add the correction carve-out. When whatever the agent handed an answer to rejects it, ask again for only the rejected fields, reuse the same subject, and name what was rejected and what a valid value looks like. Bounded ("stop after a couple of attempts on one subject") so the carve-out cannot turn into a retry loop, and explicitly not extended to a dismissed or timed-out ask — the result already names those fields and their reason, and that stays a decline the agent falls back from.

No behaviour change to the caps, the bridge, or either tool facade. This aligns the commandment with the contract subject already advertises.

Test plan

  • vitest run — 3436 tests pass across 204 files, including the 5 updated per-axis prompt snapshots.
  • tsc --noEmit, eslint, and prettier --check clean on the touched files.
  • New assertions in src/agent/__tests__/commandments.test.ts pin both halves: the carve-out survives (the agent may re-ask rejected fields, reusing the subject), and a dismissed or timed-out ask is still not a correction. The existing "do not re-ask" assertion is unchanged and still passes.

Created with PostHog Desktop

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings September 26, 2026 13:06
@Gilbert09
Gilbert09 requested a review from a team as a code owner September 26, 2026 13:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci ai-observability
  • /wizard-ci basic-integration
  • /wizard-ci feature-flags
  • /wizard-ci mcp-analytics
  • /wizard-ci replay-vision
  • /wizard-ci revenue
  • /wizard-ci self-driving
  • /wizard-ci warehouse
  • /wizard-ci warehouse-seeded

Test an individual app:

  • /wizard-ci ai-observability/anthropic
  • /wizard-ci ai-observability/google-adk
  • /wizard-ci ai-observability/groq
Show more apps
  • /wizard-ci ai-observability/manual-capture
  • /wizard-ci ai-observability/openai
  • /wizard-ci ai-observability/openai-agents
  • /wizard-ci ai-observability/opentelemetry
  • /wizard-ci ai-observability/vercel-ai
  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/flutter
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci feature-flags/django
  • /wizard-ci feature-flags/next-js
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci replay-vision/javascript-node
  • /wizard-ci replay-vision/next-js
  • /wizard-ci replay-vision/react-vite
  • /wizard-ci revenue/stripe
  • /wizard-ci self-driving/astro
  • /wizard-ci self-driving/fastapi
  • /wizard-ci self-driving/nuxt
  • /wizard-ci self-driving/react-router
  • /wizard-ci self-driving/sveltekit
  • /wizard-ci warehouse/monorepo-env
  • /wizard-ci warehouse/multi-source-next
  • /wizard-ci warehouse/stripe-node
  • /wizard-ci warehouse/zero-source
  • /wizard-ci warehouse-seeded/next-stripe
  • /wizard-ci warehouse-seeded/next-stripe-declined

Test against a Context Mill branch:

  • /wizard-ci all context-mill:my-branch

Add context-mill:<branch> to any command above to pin the Context Mill branch. It defaults to main.

Results will be posted here when complete.

@Gilbert09 Gilbert09 added the stamphog Auto-merge stamp for automated PRs label Sep 26, 2026 — with PostHog

@johncwaters johncwaters left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved by hand after checking the automated review.

Rebase the correction carve-out onto the current main branch and preserve the updated commandments tests.
@Gilbert09
Gilbert09 force-pushed the posthog/ask-correction-carve-out branch from 19de647 to a502b2a Compare October 5, 2026 10:29
@Gilbert09
Gilbert09 enabled auto-merge (squash) October 5, 2026 10:30
@Gilbert09
Gilbert09 merged commit 690eae5 into main Oct 5, 2026
18 checks passed
@Gilbert09
Gilbert09 deleted the posthog/ask-correction-carve-out branch October 5, 2026 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stamphog Auto-merge stamp for automated PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants