# Jev parallel questioning: 13 questions in one request

> Learn how to use Jev parallel questioning and speculative fan-out to ask multiple questions in a single request, including mixing three question types, code…

Source: https://gaodong.ai/en/jev/3-workflow/01-parallel-questions

---

# Parallel Questioning and Speculative Fan-Out: 13 Questions in One Request {#并行提问与投机扇出-一次请求问-13-个问题}

In the previous stage[Everyday Use](/jev/2-daily/00-hub), you learned five ways of asking questions, but the examples were either single-question requests or just dabbled with three to five questions. This lesson packs them all into one request — Jev parallel questioning: per official real tests, 13 questions packed into a single request, compared to sending 13 requests one question per request, is **cheaper by 12.2x and faster by 10.0x**, with exactly the same answers.

The second topic is speculative fan-out: ask the "possibly needed" questions up front too, and let the code decide which answers to use once they come back. The official Patterns document lists it as the first of four architectural patterns, and it's the foundation the rest of the lessons in this stage build on repeatedly.

## What You'll Be Able to Do After This Lesson {#学完你能做什么}

- Ask multiple questions in parallel with one Jev request: mix the Choice / Score / Noul question types; the official examples run fine with 5 and 13 questions
- Write both halves of speculative fan-out: the model answers everything at once, and the code decides per branch which answers to read and which to ignore
- Reproduce the official 13-question real test: 12.2x cheaper, 10.0x faster, answers unchanged (with a re-run method that needs no API key)
- Judge true dependencies: state the three official criteria for "must send a second request," and stop splitting requests based on gut feeling

## Your Current Pain Points {#你现在的困境}

- My ticket triage is a chain of serial requests: first ask the category, wait for the answer, then if it's a bug ask the severity, if it's a refund ask whether it was explicitly stated… a single ticket takes three or four round trips, and latency and the bill climb together
- I've thought about asking all the questions at once, but I'm afraid "too many questions will confuse the model" — will stuffing in two extra questions make the answers I finally tuned to be stable drift?
- The call code my coding agent generates is always one question per request, and I thought it was my own prompt being written wrong

## When to Use This Technique {#什么时候用这一招}

When you need to:

- Ask multiple questions about the same material: ticket triage, document compliance checks, tagging one message with multiple labels
- Where some of the questions "might not be needed" — you have to wait for the classification result to know which answers are relevant
- Control cost and latency: the bigger the material, the more money you waste with one request per question

And you don't want to:

- Split requests into a chain to save a few questions' worth of tokens, resending the material N times
- Maintain a state machine of "which question to ask first, and which to ask next once the answer comes back"
- Guess whether "adding questions will skew the other answers"

## 🎒 Preparation Before Starting {#🎒-开始前的准备}

- [ ] Completed [Efficient Workflow: Four Architectural Patterns and Working with Coding Agents](/jev/3-workflow/00-hub): you know that this lesson's speculative fan-out is the first of the four patterns, and the following lessons all build on it
- [ ] Have run through[the first request](/jev/1-start/03-install-first-request): `.venv` contains `typesafe-sdk`, and `TYPESAFE_API_KEY` is in the environment variables
- [ ] Roughly remember the syntax of [Choice](/jev/2-daily/02-choice), [Score](/jev/2-daily/03-score), [Noul](/jev/2-daily/04-noul) (it's fine if you've forgotten — Step 1 provides the full code)

## Core Idea {#核心思路}

First, remember the three key facts from the official primitives documentation:

- **Parallel**: every question in the request is evaluated in parallel against the same state — adding questions barely changes response time, only costing the question tokens for those extra questions
- **Independent**: one question's answer is not a hidden context for another question — adding or removing questions leaves the other answers unchanged
- **State dominates**: the material makes up the vast majority of each request — N single-question requests resend the material N times, while batch questioning sends it only once

The official definition of speculative fan-out (from the TypeSafe fan-out pattern page):

> Put all the questions the system needs into a single request — including the speculative ones — and let the code decide afterwards which are relevant.

Why dare to ask "possibly unneeded" questions up front? The official explanation: all questions are evaluated in parallel, so adding questions usually has little impact on response time; asking a question you might not need is nearly free.

The complete triage flow for a ticket looks like this (the structure of the official example):

```text
support ticket
   │  One request: ticket + 5 questions
   ▼
┌──────────────────────────────────────┐
│ category（Choice）                   │
│ bug_severity (Score)                │  Evaluated in parallel
│ has_reproducible_steps (Noul)        │  Independent of each other
│ refund_requested（Noul）             │
│ frustration（Score）                 │
└──────────────────────────────────────┘
   │  One response: 5 answers
   ▼
Your code: branch on category
   Read what needs reading, ignore what isn't used
```

The difference between the two approaches:

| Comparison dimension | One request per question × 13 | One request with 13 questions |
|---|---|---|
| Round trips | 13 times | 1 time |
| Material tokens | Paid 13 times | Paid 1 time |
| Response time | 13 latency segments summed | Nearly unchanged when adding questions |
| The "may not be needed" question | Wait for the earlier answers first to know whether to ask | Ask up front and ignore if unused |
| Answer | Same (officially tested) | Same (officially tested) |

For how to supply the material and what goes in state, see the [State 状态](/jev/2-daily/01-state) lesson; every question in this lesson is asked against the same state.

## Follow along{#跟我做}

### Step 1: Jev's first taste of parallel questioning—5 questions packed into one request{#第-1-步-jev-并行提问初体验——5-个问题装进一个请求}

**Why**: Ticket triage is the example scenario on the official fan-out pattern page. Real tickets often mix several kinds of issues in one message; classifying first and then "asking follow-ups as needed" takes several round trips. Ask all 5 questions up front and get everything back in a single request.

This is the ticket used by the official Playground example—deliberately mixed: duplicate charge + cannot log in + wants Apple Pay + impatient. Create `fanout_triage.py`:

```python
from typesafe_sdk import Choice, Noul, Score, TypeSafeClient

ticket = (
    "Hi, I placed an order (#98423) last Thursday and was charged twice. "
    "I also can't log in after the site update, and adding Apple Pay "
    "would be really helpful. This is getting frustrating."
)

questions = {
    "category": Choice(
        instructions="Determine the broad category of this support ticket",
        criteria={
            "bug_report": "The user is reporting something that is broken or producing errors",
            "billing": "Charges, invoices, refunds, subscriptions",
            "feature_request": "The user is requesting new functionality",
            "account": "Login, permissions, profile, security",
        },
    ),
    "bug_severity": Score(
        instructions="How severe is the reported issue",
        criteria=[
            "Cosmetic; no impact to functionality",
            "Broken or degraded feature; workaround exists",
            "Blocking issue; no workaround exists",
        ],
    ),
    "has_reproducible_steps": Noul(
        instructions="The user describes specific steps to reproduce the issue"
    ),
    "refund_requested": Noul(
        instructions="The user is explicitly asking for a refund or credit"
    ),
    "frustration": Score(
        instructions="How frustrated the user appears",
        criteria=[
            "Calm, matter-of-fact",
            "Frustrated but civil",
            "Very angry",
        ],
    ),
}

with TypeSafeClient() as client:
    response = client.system_one(state=ticket, questions=questions)

print(response.answers["category"].choice)
print(response.answers["bug_severity"].score)
print(response.answers["has_reproducible_steps"].noul)
print(response.answers["refund_requested"].noul)
print(response.answers["frustration"].score)
```

The ticket text, the 5 questions, and the description of each option are all verbatim from the official Playground example, not a word changed.

Run:

```bash
.venv/bin/python fanout_triage.py
```

**You should see**: five lines of answers. The first line is one of the four categories; the second and fifth lines are 0–2 scores (they can land between two levels); the third and fourth lines are 0–1 probabilities. The official docs do not publish expected values for this mixed ticket—go by the actual numbers in your response, but the 5 answers are guaranteed to appear **simultaneously** in one response.

Note the speculative questions among them: `bug_severity` and `has_reproducible_steps` are only useful when `category` is bug_report; `refund_requested` is only useful when it is billing. The official NOTE explains: ask them all up front, because adding questions has little impact on response time; if the ticket turns out to be a feature request, the bug severity result is irrelevant and the code path simply ignores it.

- [ ] One request gets 5 answers, with no loop and no second call in the code

### Step 2: Route with code—ignore speculative answers when they should be ignored{#第-2-步-用代码路由——投机答案该忽略就忽略}

**Why**: The other half of speculative fan-out lives in the code. The model returns all 5 answers; "which answers count on this path" is decided by your if/else.

The routing code from the official fan-out pattern page (triage.py verbatim; the handler functions are official placeholder names—replace them with your own business logic):

```python
category = response.answers["category"]
bug_severity = response.answers["bug_severity"]
bug_repro = response.answers["has_reproducible_steps"]
refund = response.answers["refund_requested"]
frustration = response.answers["frustration"]

if category.choice == "bug_report":
    if bug_severity.score > 1.5 and bug_repro.noul > 0.6:
        escalate_to_engineering(ticket_id, severity="high")
    else:
        add_to_bug_backlog(ticket_id)

elif category.choice == "billing":
    if refund.noul > 0.7:
        route_to_billing_with_flag(ticket_id, refund_likely=True)
    else:
        route_to_billing(ticket_id)

elif category.choice == "feature_request":
    log_feature_request(ticket_id)

# Frustration is useful regardless of category
if frustration.score > 1.5:
    flag_for_priority_response(ticket_id)
```

Threshold table:

| Branch | Gating condition | Action (placeholder function) |
|---|---|---|
| bug_report | severity > 1.5 and repro > 0.6 | Escalate to the engineering team |
| bug_report (all others) | — | Add to the bug backlog |
| billing | refund > 0.7 | Route to the billing team and tag |
| billing (all others) | — | Route to the billing team |
| feature_request | — | Log the feature request |
| Any category | frustration > 1.5 | Prioritized response |

Three points to read:

- **Some answers are destined never to be read.** When category lands on billing, nobody looks at the `bug_severity` answer—asked, unused, and no loss: that is speculation
- **frustration does not enter any if/elif.** The official comment, verbatim: Frustration is useful regardless of category—it sits as a separate gate outside all the branches
- **The whole decision tree needs only one call.** Official summary: speculative questions are ignored when irrelevant and save a round trip when relevant

**You should see**: whichever option category lands on, the code takes that branch and the other branches do not execute. If you just want to see the flow, replace the placeholder functions with something like `print("escalate")`. The officials likewise have not published the expected routing result for this ticket.

- [ ] I can name the two questions whose answers go unread in the billing branch (answer: bug_severity, has_reproducible_steps)

### Step 3: Reproduce the official 13-question benchmark—12.2x cheaper, 10.0x faster{#第-3-步-复现官方-13-问实测——12-2-倍便宜、10-0-倍快}

**Why**: "Adding questions barely increases response time, and answers don't affect each other" should not remain just a claim. The official Parallel questions cookbook ran a controlled experiment; this step looks at its setup and results, and gives a way to re-run it without an API key.

Experiment setup:

- Material: the Wikipedia entry on GDPR, pinned to revision 1363040264, measured at 53,777 characters (about 54 thousand)
- 13 questions: 8 Noul + 2 Choice + 3 Score, covering the 13 things a compliance team needs to check
- Each sending method run 5 times: one request holding 13 questions vs. one question per request sent 13 times; compare the means (any drift?) and the standard deviations (any added noise?)
- Model jev-1.12, priced at $0.042/Mtok input, $0 output (as of 2026-09)

What do the 13 questions look like? Three samples:

| Question ID | Type | What it asks |
|---|---|---|
| breach_72h | Noul | Must a personal data breach be reported to the regulator within 72 hours? |
| instrument_type | Choice | Which kind of EU legal instrument is GDPR? (Regulation / Directive / Treaty / Recommendation) |
| compliance_burden | Score | How heavy is the compliance burden GDPR imposes on organizations? (5-level scale) |

**Result one: batched or not, the answers don't change.** Of the 13 questions, 11 (2 Choice + 3 Score + 6 of the 8 Noul) were exactly identical across all 5 repetitions, with a standard deviation of 0.0 under both sending methods; the remaining breach_72h and criminal_penalties carried a bit of run-to-run noise, with the means of both sending methods agreeing within the noise. Official conclusion: the noise is a property of the questions themselves, not something batching adds—batching neither shifts the answers nor increases variance.

**Result two: cost and time differ by 12.2x / 10.0x.**

| Sending method | Number of calls | Cost | Total time |
|---|---|---|---|
| One request packs 13 questions | 1 | $0.000497 | 0.27s |
| 13 requests, one question per request | 13 | $0.006090 | 2.71s |

The official explanation: the single-question sending method resends the 53,777-character entry 13 times, while the batched-question method sends it only once. The total time in the table sums the 13 single-question latencies (assuming they run one after another); sending them concurrently can shrink the time gap, but the 13x token cost stays the same. The larger the document, the closer the savings get to the full 13x.

Re-run (no API key needed):

```bash
pip install ipython 'cooksafe>=0.2.0,<0.3.0'
```

Then download `json_cache.json` from the official examples repository (github.com/typesafe-ai/typesafe-public-examples/tree/main/cookbooks/parallel_questions), put it in the run directory, and follow the script on the cookbook page.

**You should see**: the numbers in Result One and Result Two reproduce exactly as they are—the cache replays the very batch of calls from the official measurement, and only deleting `json_cache.json` will trigger a real run again.

One small gotcha: at startup the script still reads the `TYPESAFE_API_KEY` environment variable, and the client errors out immediately without a key. Just set a placeholder value before replaying (e.g., `export TYPESAFE_API_KEY=dummy`)—cache-hit calls never actually send requests, so the placeholder key is never used.

::: tip 💡 When the numbers in the two documents conflict, the cookbook wins
When primitives.md cites the same experiment, it says 11.5x cheaper and 9.6x faster; the original cookbook text says 12.2x / 10.0x. This site consistently uses the original cookbook text (12.2x / 10.0x).
:::

- [ ] I can state the three conclusions of the official measurement: answers unchanged, 12.2x cheaper, 10.0x faster

### Step 4: Identify true dependencies—when to actually send a second request {#第-4-步-判断真依赖——什么时候才发第二次请求}

**Why**: Jev parallel questioning has one hard boundary: questions within the same request are independent of each other, and one answer cannot serve as context for another question. So for code that "first asks for the category, then uses the answer to decide what to ask next," should it actually be split into two requests?

The official criterion is just one: **the code cannot construct the second request without the first answer**. Specifically, three cases:

1. You need the answer to fetch more data into state (the answer determines where to fetch what)
2. You need the answer to decide what goes into state
3. You need the answer to pick the options for the next question

Outside these three: fold it into the first request and combine the answers in code once they come back. The official wording: two requests are the exception, not the rule.

Three official "true dependency" examples (all from the cookbook):

| Cookbook | Why the second request is unavoidable |
|---|---|
| Skill suggestion | First rank the skill catalog, fetch the full text of the top three, then re-evaluate against better evidence—without the ranking you don't know which three to fetch |
| Structure recovery | First ask whether each line break cuts off a sentence, then assemble the lines into blocks based on the answers—the blocks simply don't exist before the first request is answered |
| Hierarchical classification | The answer at each level of Choice determines which options the next level's request offers |

One last question about quantity—how many questions can a single request actually hold?

- **There is no upper limit on the number of questions**. The limits are on size: 64k per request, 32k per question (both include state); see [Models and Pricing](/jev/reference/02-models-pricing) for details
- Questions are usually shorter than state, so state accounts for the bulk of both limits
- If it really won't fit: split into several requests **sharing the same state**

- [ ] Each of my "second requests" maps to one of the three criteria, rather than "it feels safer to ask later"

## Checkpoint ✅ {#检查点-✅}

- [ ] A single request mixing all three question types runs successfully, and the 5 answers are each retrieved by ID
- [ ] My routing code has a branch where "the answer is available but not read"
- [ ] I can state the official measurement: 13 questions, 12.2x cheaper, 10.0x faster, answers unchanged
- [ ] I can state the three criteria for true dependencies: fetch data into state / determine state composition / pick options for the next question
- [ ] I know there is no upper limit on the number of questions; the limits are the two context sizes, 64k / 32k

## Pitfall reminders {#踩坑提醒}

### ❌ One question per request (a disaster zone for coding agents) {#❌-一题一请求-coding-agent-重灾区}

The official primitives doc's TIP says verbatim: coding agents fall into the "one question per request" habit even more easily than humans do. TypeSafe Agent Skill specifically corrects this—having the agent pack many questions into each request, including questions that only matter for part of the input.

The right approach: fold all questions sharing the same state into one request. When you review code written by an agent and see a for loop sending one question at a time, that's this exact problem.

### ❌ Saving "might-need" questions for a second request {#❌-把「可能需要」的问题留到第二次请求}

The symptom: first ask category, wait for the answer, then send the severity / refund request. The official smart-home demo explicitly calls this path "the wrong way" (the wrong way: sequential API calls)—it optimizes for the fewest number of questions, and ends up far slower and far more expensive than one batched ask.

The right approach: ask speculative questions up front. Asking two extra questions is nearly free (just two questions' worth of tokens), while the round trip you save is real money.

### ❌ Cramming a whole chain of judgments into one instructions {#❌-一个-instructions-塞一整串判断}

"Analyze this ticket and decide the best way to handle it" is not a good question—the System One model is optimized for fast, focused judgments, and a good question is one an expert could settle in a second. When a judgment depends on multiple factors: one factor per question, with answers weighted and merged in code—this is exactly the main dish of the [Composite Scoring](/jev/3-workflow/03-composite-scoring) lesson.

### ❌ Being afraid to add questions for fear of "skewing already-tuned answers" {#❌-不敢加题-怕「把调稳的答案带偏」}

The official measurement answered this point directly: 13 questions produced identical answers under both sending methods (Step 3); each question is evaluated independently, and adding or removing questions doesn't change other answers. What you should fear is a vaguely written question, not the number of questions.

## Advanced techniques (optional) {#进阶技巧-可选}

**See the full product shape of speculative fan-out.** The official smart-home demo (with video) runs the whole playbook for you: one sentence, "turn off all the lights in the house," backs a long chain of questions—request category, target domain, device type, action on the device... Among them, the question "what action to take on the lights" is already being asked before you even know whether the user is commanding the lights. The demo also shows TypeSafe paired with an LLM: when a compound request is detected, the LLM splits it into atomic commands; for chitchat, it falls back to a conversational LLM—in the official wording, this TypeSafe step is much faster than an LLM, and the latency it adds to the overall system is negligible.

**Skim how-to manual item 6 before writing questions.** The official how-to-build-with-system-one manual lists "Ask a lot of questions" as a way to maximize "intelligence per dollar": questions are evaluated in parallel, code combines the signals, and no serial round trips are added.

**Let the coding agent fix itself.** If your agent keeps writing one question per request, install the TypeSafe Agent Skill (covered in detail in the [Developing with Claude Code](/jev/3-workflow/04-coding-agents) lesson): once installed, the call code your agent generates will proactively pack questions into requests in batches, including the speculative ones.

## Lesson summary {#本课小结}

✅ Jev parallel questioning = pack all questions on the same state into a single request: mix three question types, evaluate them in parallel and independently, and adding more questions barely increases response time.

✅ Speculative fan-out = also ask ahead the questions that "might be needed"; the model answers all of them, and your code decides per branch which ones to read and which to ignore.

✅ Backed by official real-world testing: 13 GDPR regulatory briefing questions, one request vs 13 requests — 12.2x cheaper, 10.0x faster, with identical answers.

✅ Only send a second request when there is a real dependency: fetching data into state / deciding state composition / picking options for the next question — anything beyond these three criteria is just an excuse.

✅ No cap on quantity, only on size: 64k per-request / 32k per-question; if it doesn't fit, have several requests share the same state.

Key facts at a glance:

| Item | Value | Source |
|---|---|---|
| 13-question real test | 12.2x cheaper, 10.0x faster, identical answers | docs/cookbooks/parallel_questions.md |
| Cost / time | $0.000497 / 0.27s (batched) vs $0.006090 / 2.71s (13 requests) | same as above |
| 13-question composition | 8 Noul + 2 Choice + 3 Score, each dispatch method run 5 times | same as above |
| GDPR entry | 53,777 characters, fixed revision 1363040264 | same as above |
| Ticket triage 5 questions | category (Choice), bug_severity (Score), has_reproducible_steps (Noul), refund_requested (Noul), frustration (Score) | docs/patterns/fan-out.md |
| Routing thresholds | severity > 1.5 and repro > 0.6 escalate; refund > 0.7 tag; frustration > 1.5 priority response | same as above |
| Context limits | 64k per-request / 32k per-question, no cap on number of questions | docs/models.md, docs/primitives.md |

Note: primitives.md cites the real test as 11.5x / 9.6x; the cookbook's original text of 12.2x / 10.0x is authoritative.

## Next lesson preview {#下一课预告}

After getting back a batch of answers in one request, the next topic is "how to use the answers": the next lesson [Smart Routing: Intent Classification with Confidence Gating](/jev/3-workflow/02-smart-routing).

You will learn:

- Classify intent with Choice and rate complexity with Score, retrieving both in parallel in a single request
- Put brakes on automation: if confidence is below the threshold, hand off to a human first; only dispatch once it passes the threshold
- Scale thresholds with risk: checking a balance passes at 0.6, while approving a transfer requires 0.85 or higher
