Skip to content

Map: AI decisions in workflows, a decision step backed by Jev #240

Open
11 of 12 issues completed
Open

Description

@Silthus

Destination

Redrawn 2026-10-05 by Michael: one minimal draft PR. Revive PostHog/posthog#107832 (Harley Alexander's "Classify with Jev") on current master as a flag-gated function step, "AI decision (Jeeeeeeeeev)". It asks the PostHog-hosted Jev model on the AI gateway to pick one of the author's options and writes the answer and its confidence to workflow variables. The author branches on them with the regular conditional branch. Everything beyond that is a later improvement.

Notes

  • Parked (2026-11-14). Off the focus of the Workflows sprint of 16 to 27 Nov (Sprint - November 16 to November 27 PostHog/posthog#133091). Dispatch no new ticket; running lanes finish and settle. Tripwire: the sprint's focus items done, or 2026-11-25.
    Execution. This map carries execution: resolved specs publish implement tickets here, and shipped means a draft PR that qa-swarm handed off as ready for review. No merge authority: Michael reads, marks ready, and merges.

Grilling (Michael, 2026-10-05). Open decisions go to Michael through grilling tickets, per the Wayfinder default. The earlier autonomy waiver is withdrawn.

Public repo. These tickets are public. Slack thread contents, customer names, usage numbers, and internal metrics never go here. Slack context lives in a private note in Silthus/personal (workflows-jev-decisions.md), and tickets refer to it without quoting it.

PRs. Draft PRs on PostHog/posthog from branches on the Silthus/posthog fork, based on upstream/master (the fork's master is far behind). Fork CI is held as action_required, so the local gate stands in (see the fork-pr-ci-and-semgrep-gap memory).

Domain and prior art. Read before any ticket:

  • products/workflows/CONTRIBUTING.md and products/workflows/skills/building-workflows/references/graph-schema.md; the executor lives in nodejs/src/cdp/services/hogflows/.
  • products/ml_inference/backend/facade/ is the team-billed decisions facade (decide, decide_when_available, 16 options, 32 questions, is_ai_data_processing_approved, flag ml-inference-decisions). posthog/llm/system_one.py holds the wire types.
  • The HogQL decide() / jev() function (posthog/hogql/transforms/prompt_jev.py) shows how a batch caller budgets, dedupes, and maps a gateway 402 to "out of AI credits".
  • PostHog/posthog#107832 ("Classify with Jev" workflow step, closed by its author unmerged): a function template that calls a Django route through a scoped service JWT and writes jev_category / jev_confidence variables. Its reviews are useful evidence.
  • Map LLM action for workflows #1 and spec Spec: Generate text — an LLM action node for workflows #22 ("Generate text", an LLM node for workflows): settled decisions on templating, billing, failure modes, and mocked test walks that a decision step should stay consistent with.

Model. PostHog-hosted models through the AI gateway only. TypeSafe (third party) never receives customer data, so it is not a path for this step.

Casting. Choose worker models per the model selection policy: GPT-6.1 Sol through codex:codex-rescue for research and bounded implementation; Opus 5.5 for routine UI; Fable 5.1 for UI design with real ambiguity. Provider bridges are retired casts.

Skills. /tdd, /writing-user-facing-copy, /writing-ui-components, /improving-drf-endpoints, /implementing-mcp-tools, /writing-tests, /writing-pr-descriptions, qa-swarm.

Decisions so far

Not yet specified

  • Follow-ups from the AI decision step: decide route and action type in Django, reviving #107832 #248 build. A combined token budget for question plus options (at the spec's limits they can approach the model's 8,192-token window). A decision step whose edge loops back to itself bills one decision per pass. The shared token bucket warns on every Redis error. ml_inference opens a new HTTP client per decision. Template grandfathering ignores the action type for other non-function steps (pre-existing).
  • Rollout checklist. Keep workflows-ai-decision off until the Node runtime deploys; provision WORKFLOW_AI_DECISION_JWT_SECRET for web and the CDP worker; confirm the gateway bills hosted System One calls before the credits copy ships.
  • AI approval copy. The organization AI data processing switch speaks of third-party AI services, yet every Jev caller uses it as the gate. Whether a PostHog-hosted model needs different copy or a different gate.
  • Gateway billing and limits. Whether the AI gateway bills hosted System One calls above zero cost and applies its own per-team rate limits lives in PostHog/ai-gateway, which agents here cannot read. The spec treats it as an assumption to confirm.
  • Prompt management. Whether authors can version a decision's wording, as signals does with managed System One prompts.
  • Observability. How authors see decisions after a run: run logs, per-branch counts, LLM analytics traces, a confidence histogram.
  • Batch scale. What happens when a batch workflow sends thousands of people through the step at once: gateway rate limits, credit checks, and backpressure.
  • Score questions. Whether a 1-to-N score is a third mode or waits for a caller.

Out of scope

Activity

  1. Silthus commented on Oct 4, 2026

    @Silthus
    OwnerAuthor

    Charting evidence (upstream master at 39cc02e, 2026-10-04)

    Code facts that every ticket starts from. Paths are repo-relative.

    System One today

    • PostHog-hosted models on the AI gateway: posthog/hogference/jevk5-fp8-0.2 (default almost everywhere) and posthog/hogference/jeeves-0.1. Gateway caps: 16 options per choice, 32 questions per request.
    • products/ml_inference/backend/facade/ exposes decide (flag ml-inference-decisions), decide_when_available (region and AI data processing approval only, caller owns the flag) and decide_unchecked. Requests bill the customer team through team_id in X-PostHog-Properties. privacy_mode is supported. Available on US and EU Cloud, not self-hosted.
    • HogQL decide() / jev() (posthog/hogql/transforms/prompt_jev.py) batches rows into one request, dedupes inputs, pre-checks AI credits with is_team_over_ai_credit_budget, and maps a gateway 402 to "out of AI credits".
    • Other callers: emoji search, taxonomic search intent, replay vision rerank and watch feed, error tracking severity, signals safety and actionability, navbar app ranking.
    • Node (nodejs/src), the Hog standard library and products/workflows have no System One access yet.

    Workflows today

    • No LLM or judgement step exists. "Create AI task" and "Run scout" are flag-gated function templates that call Django through an async function and a scoped JWT.
    • callInternalApi (nodejs/src/cdp/async-functions/internal-api-call.ts) is a synchronous in-cluster call that pushes {status, body} back onto the Hog stack. Conversations and customer analytics use it.
    • Any step can write workflow variables through output_variable (trackActionResult, 5 KB cap). A conditional_branch can filter on a workflow_variable, so a variable written by a decision can already drive a branch.
    • A native branching action type touches: SUPPORTED_ACTION_TYPES and serializer checks (products/workflows/backend/), graph_validation.py _branch_slot_count, the Node zod union and a new handler in hogflow-executor.service.ts, the frontend zod schema, step registry, config panel, palette branchEdges, branch labels in canvas and tree views, regenerated OpenAPI and MCP clients, tools.yaml and graph-schema.md. There is no backend flag mechanism for a new action type; FLAG_GATED_TEMPLATE_IDS gates function templates only.
    • Email template choice is fixed at save time (template_uuid copied into the step). Varying the email per person means branching to N email steps or liquid {% if %} in one body.
    • "Update person property" writes through $set ingestion, so a later branch on that property can read stale data. Branching on a variable avoids that.
  2. Silthus commented on Oct 5, 2026

    @Silthus
    OwnerAuthor

    Conductor handoff (2026-10-05). The conductor thread on devbox-michaelr-1 is settled at Michael's request. The only open work is AI decision v1: revive Classify with Jev as one minimal PR, driven by its own T3 thread on devbox-michaelr-3 (locator on #252). When #252 closes with its draft PR, record it in Decisions so far and close this map; everything else is closed or out of scope.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions