Skip to main content
This example adapts questions within one interview. Each Yes/No response narrows the next offer; other respondents have independent state. The Machine computes the next price and stopping condition. Survey continues to own navigation.

Build and run the complete example

Everything needed for this example is defined on this page. Use an EDSL build that includes the Machine and Runner APIs documented in this manual. Execute the following four Python blocks in order in one session, or concatenate them into one script. They require EDSL and the Python standard library; no repository example modules or external data files are needed. The scripted run makes no model API calls. Four scripted respondents have integer thresholds 0, 37, 65, and 100. Starting from the assumed range 0..100, their final intervals are respectively 0..0, 37..37, 65..65, and 100..100. The first three need six questions; the last needs seven. This makes no live model calls.

1. Define the Machine

The Machine keeps an inclusive integer interval and an observation history. Every accepted response narrows that interval and records the quoted price atomically.

2. Construct the Survey

Each respondent gets a separate state scope. The survey declares a bounded number of question slots and skips those the Machine no longer needs.

3. Define the scripted respondents

These agents have known integer thresholds for checking the result. Only the answering function reads that simulation trait; the Machine receives Yes/No responses.

4. Run and inspect the answers

Model("test") supplies the Jobs model dimension. The agents above answer locally, and QuestionCompute evaluates the routing gates without a model call.

Watch one respondent’s offers change

The follow-up Python blocks use the definitions and Results created above. The results variable above contains four independent interviews. R1’s scripted threshold is 37: they answer Yes exactly when the offer is at most 37. The Machine does not read that hidden simulation trait; it only receives the Yes/No answers. After the sixth response, the interval has one integer left. The seventh multiple-choice question is skipped. Notice that a Yes at 37 alone did not end the search: values 38 through 49 were still consistent until later No answers ruled them out.

Compare precision with a smaller question budget

The same respondent can be surveyed with only two offers. This is a new study state, not a continuation of the completed run above:
An interval is the result. A limited budget does not justify replacing it with an exact estimate or describing it as a statistical confidence interval.

Integer search policy

The scope key is [study_id, respondent_id]. State holds inclusive integer lower and upper bounds and an ordered observation history. At each step:
  1. Compute price = ceiling((lower + upper) / 2) with round_ratio.
  2. If the answer is Yes, set lower = price.
  3. If the answer is No, set upper = price - 1.
  4. Record the step, quoted price, and answer atomically.
Stop when the interval width is at most tolerance or max_questions have been answered. precise distinguishes tolerance completion from budget exhaustion. Defaults use exact integer units, no floating point or currency conversion. The authoring helper permits at most 32 question slots. The single command is observe(step, answer), where answer is Yes or No. A fresh step must equal the current history length. Earlier identical observations are no-ops; changed answers and out-of-order observations reject without changing bounds. A completed or explicitly closed search refuses new observations while retaining valid historical retries.

Fixed Survey slots, adaptive content

The adapter constructs a bounded sequence of computed price questions and multiple-choice questions. Before each slot it reads the personal Machine view. The computed question emits the price only when this slot is the next unfinished step; otherwise it emits skip. An ordinary Survey skip rule suppresses that question and its associated state write. A final read reports the interval. This also supports partial resumption: a new job with the saved state map skips old slots, keeps their original observations, and continues the remaining search. The tests interrupt after two responses, restore the Survey, and finish without counting either response twice. Fully completed searches ask no further choices. Model-path tests inspect every quoted price in the actual prompts and saved presentation metadata. Scripted respondents use the read view to make their choice. The presentation contract distinguishes the direct question object from a rendered model prompt.

Interrupt after two answers, then resume

This intentionally interrupted survey has the full seven-slot definition but ends after its second response. Restoring the original Survey preserves the state map ID, so the next job continues that same personal search.
The two None answers in the second Results object mean those questions were not asked in that job. Their earlier observations remain in the shared-state history. Calling build_survey() again instead would create a fresh state map and restart the search. Resuming also requires the same study and respondent IDs.

Assumptions and design findings

The threshold must be an integer inside the assumed initial range, and the respondent must buy at every price at or below it. An endpoint result does not prove that the true value lies within the range: all-Yes responses also fit values above the upper bound, and all-No responses can reflect values below the lower bound. Interpret those cases as potentially censored. Noisy or changing preferences need another elicitation policy; this deterministic search provides no confidence interval or inconsistency diagnosis. The tests compare every transition with an independent integer-search reference, check boundary values, early precision, limited budgets, stale steps, concurrent duplicate observations, restart/replay, isolated scopes, and fresh-process execution. This construction exposes the cost of fixed Survey slots: the authoring helper must allocate a maximum number of slots and generate gates, even when the Machine finishes early. It demonstrates current navigation without introducing a new Machine-driven survey engine. Stable IDs and one logical search per respondent scope remain host responsibilities; do not treat simultaneous differing responses from two sessions as independent searches. The default definition is 9,017 JSON bytes; its six-observation corpus replay peaks at 4,642 host budget steps per transition. The corpus profiler reproduces these host-specific measurements.