Skip to content

fix(orchestrator): record why an agent reported a task 'not needed' - #1195

Merged
edwinyjlim merged 2 commits into
mainfrom
posthog/skip-reason-not-needed-cause
Sep 3, 2026
Merged

fix(orchestrator): record why an agent reported a task 'not needed'#1195
edwinyjlim merged 2 commits into
mainfrom
posthog/skip-reason-not-needed-cause

Conversation

@Gilbert09

Copy link
Copy Markdown
Member

Problem

orchestrator task skipped carries a reason, and agent-not-needed is
documented in queue.ts as "the step did not apply here". But that value
records who decided the skip, not what they decided — and
complete_task's own guidance offers not needed for two different things:

Use status 'not needed' when the task does not apply to this project and
you cannot do it

For most steps that conflation is harmless. For the seeded data-source step it
is not, because that is the one step that stops to ask the user for
credentials. An agent that asked, got nothing back, and handed the user a
browser link reports not needed — and is then counted as having found that
the step did not apply to a project the wizard had already scanned and found
connectable sources in. By construction "did not apply" is almost never true
for this step, yet it is the bucket most of its skips land in.

The result is the majority of this step's skips sitting in a bucket whose
recorded meaning is wrong for them, and a funnel that cannot separate "nothing
here to connect" from "the user withheld a credential" from "an endpoint we
could not reach". Those want three different product responses.

Why

Raised from a read of this step's telemetry: agent-reported skips dominate its
skip count, while the agents' own end-of-task remarks describe cancelled
credential prompts and browser fallbacks — not inapplicable steps. The event
had no field that could tell the two apart.

Changes

  • NotNeededReason in queue.ts: a closed set of not-applicable /
    user-declined / blocked, recorded on the task next to skipReason.
  • complete_task gains an optional notNeededReason on both harness
    schemas — the zod shape and the pi typebox mirror. The orchestrator runs on
    pi, so a field present only on the MCP schema would not be in effect; the
    complete_task args now share one shape per harness and the parity test
    holds them level, the same way it already does for the handoff.
  • orchestrator task skipped gains not_needed_reason. Purely additive:
    reason and every other property are untouched, so existing dashboards keep
    reading the same numbers.
  • The value is checked against the declared set before it reaches the task.
    The pi harness hands tool arguments over unvalidated and an agent asked for
    a reason readily writes a sentence — a sentence about this step can name a
    database or a key, so it must not become an analytics dimension. Handoff
    prose still stays out of telemetry entirely, exactly as before.

Deliberately unchanged: which status an agent picks. Rewording the status
guidance would move runs between done / not needed / failed and break
the comparison this event is being read for. This adds the missing dimension
without moving anything.

Test plan

pnpm build && pnpm test && pnpm lint — 2599 tests pass, 0 lint errors (the
one warning in queue-tools.ts predates this branch, verified against main).

New tests:

  • queue.test.ts — each reason is recorded alongside the skip reason, stays
    unset when none is declared, reaches the transition listener (so the event
    carries it), and the type guard rejects free text
  • queue-tools.test.tsapplyComplete forwards a declared reason, drops an
    undeclared value, skips as before with none, the ask names every reason, and
    both harnesses offer the field

Created with PostHog Desktop

`SkipReason.AgentNotNeeded` records that the agent decided the skip, not what
it decided, and `complete_task` offers `not needed` both for "the step does
not apply to this project" and for "you cannot do it". For the one step that
stops to ask the user for credentials those are opposite outcomes, and both
land in a bucket documented as the first.

Add an optional `notNeededReason` to `complete_task` on both harness schemas —
a closed set of `not-applicable` / `user-declined` / `blocked` — carry it on
the task, and stamp it onto `orchestrator task skipped` as an additive
property. `reason` and every other property keep their current meaning.

The value is validated against the declared set before it reaches the task:
the pi harness passes tool arguments through unvalidated, and free text about
this step can name a credential.

Generated-By: PostHog Desktop
Task-Id: 93b396ed-9a30-4d56-bd97-6bd31c232436
@Gilbert09
Gilbert09 requested a review from a team as a code owner September 2, 2026 11:59
Copilot AI lite review requested due to automatic review settings September 2, 2026 11:59
@github-actions

github-actions Bot commented Sep 2, 2026

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 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/groq
  • /wizard-ci ai-observability/manual-capture
Show more apps
  • /wizard-ci ai-observability/openai
  • /wizard-ci ai-observability/openai-agents
  • /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 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.

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.

@edwinyjlim
edwinyjlim merged commit 821023a into main Sep 3, 2026
17 checks passed
@edwinyjlim
edwinyjlim deleted the posthog/skip-reason-not-needed-cause branch September 3, 2026 03:11
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.

3 participants