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. Theresults 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:
- Compute
price = ceiling((lower + upper) / 2)withround_ratio. - If the answer is Yes, set
lower = price. - If the answer is No, set
upper = price - 1. - Record the step, quoted price, and answer atomically.
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 emitsskip. 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.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.
