Assign conditions once, on the server, and store the assignment. Pin every prompt and model to a version ID. Log each call with that ID, and write fallback rules before launch. On an existing prototype this typically takes 80 to 160 engineering hours, about $6,800 to $13,600 at $85 an hour.
How do I compare prompting strategies or models in a randomized classroom study without breaking the experiment?
Why reliability is a validity question
In an AI comparison study, the treatment is the prompt and model a student actually received. If the app silently switches models during an outage, or a teammate edits a prompt in week three, then some students got a condition nobody designed. A software defect becomes a protocol deviation. It weakens your efficacy claim even if no one notices it until analysis.
Program officers and reviewers read this the same way. A study with no record of which version each student saw is a demo with outcomes data attached. The engineering work below makes the condition column in your dataset trustworthy.
Condition assignment: randomize once, store it, never recompute
- Pick the unit before you write code. Students in the same classroom talk to each other, so many classroom studies randomize by class or by teacher, which is cluster randomization. Your analysis plan sets this, not the engineers.
- Assign on the server. Never randomize in the browser or from a hash of something that can change, like an email address. Write the assignment to a table with the unit ID, condition, timestamp, randomization seed and stratum.
- Make it sticky. A student who logs in on a Chromebook, then on a phone, then after a password reset still gets the same condition. Test that case on purpose.
- Stratify if the protocol says so. Balancing by school, grade or prior score is easy to do at assignment time and impossible afterward.
- Hide the condition from the interface. Labels like
condition_bshould never show up in URLs, page titles or error messages that students or teachers can see. That protects blinding where your IRB protocol requires it.
Versioning prompts and models
Treat each condition as a frozen configuration, not as text in a code file. A configuration holds the system prompt, any few-shot examples, the model identifier, temperature and other sampling settings, the maximum output length, and any retrieval sources. Give it an ID and a content hash, and store both with every logged call.
- Use the provider’s dated model snapshot, not an alias that tracks the latest release. An alias can change under you mid-study.
- Freeze configurations at launch. Any change after that gets a new ID, a dated entry in a change log and a note to the PI, so the change appears in your methods section.
- Check where each provider’s snapshot sits in its deprecation schedule before the pilot starts. A model retired in month four of a six-month study forces an unplanned version change.
What to log for every model call
Log at the call level, not the session level. When a reviewer asks why one condition had shorter responses, you need to tell a design effect apart from truncation or timeouts.
| Field | Why it matters |
|---|---|
| Pseudonymous student ID, unit ID, condition | Links the output to the assignment without storing names |
| Configuration ID and hash | Shows exactly which prompt and model the student saw |
| Model identifier returned by the API | Catches cases where the provider served something other than what you requested |
| Full rendered prompt and full response | Lets you reconstruct the interaction and code it qualitatively |
| Token counts, latency, finish reason | Separates truncated or slow responses from real condition effects |
| Errors, retries, fallback flag | Lets you exclude or model affected interactions |
| Server timestamp in UTC | Orders events across time zones and devices |
Student text sent to a model may be an education record. Your data use agreement with each district, and the provider’s data-retention terms, decide what you can send and store. Your institution’s counsel or compliance office signs off on that design, not the vendor.
Fallback behavior when an API fails
Model APIs rate-limit, time out and go down. Decide the rule for each condition before launch and write it into the protocol. The worst option is the one many prototypes have by default: quietly retrying on a different model.
| Fallback | Effect on the study | When to use it |
|---|---|---|
| Retry the same configuration with backoff, 2–3 attempts | None, as long as retries are logged | Always, as the first step |
| Show a neutral ‘try again’ message | Missing data, flagged by condition | Default when retries fail |
| Serve a pre-generated response for the same condition | Small, if the response was made with the same configuration | Fixed item sets where you can generate responses in advance |
| Switch to another model | Contaminates the condition | Only if the protocol defines it and every case is flagged |
Watch failure rates by condition during the pilot. If one model fails 5% of the time and the other fails 0.5%, missing data stops being random, and your analyst needs to know in week one, not at the end of the study.
Reproducibility, and a realistic path to launch
Language model outputs are not fully deterministic, even at temperature zero, so you cannot promise byte-for-byte reruns. What you can promise is a complete record: frozen configurations in version control, the deployed code commit tagged for each study wave, the assignment table, and the call log. Together they let another team re-run the same inputs on the same snapshots and compare.
Worked example: two prompting strategies, 20 classrooms
- Week 1: lock the randomization unit and analysis plan with the PI, then design the configuration and log schema. About 20 hours.
- Weeks 2–3: build server-side assignment, the configuration registry and call logging. About 50 hours.
- Week 4: add fallback rules, a per-condition monitoring view and load tests at class size, such as 30 students submitting at once on a school network. About 30 hours.
- Week 5: dry run with research staff on student test accounts, then freeze the configurations and tag the release. About 20 hours.
That is about 120 hours, or about $10,200 at $85 an hour, inside the 80–160 range. The work grows with more conditions, more providers, or an assignment rule that changes over time, such as adaptive designs. We have built on this kind of timeline before: a research prototype taken to a district-approved classroom pilot in under 30 days, with 20 teachers across two districts and 100+ framework-compliant problems generated.
Frequently asked questions
Should I randomize by student or by classroom in an AI tutoring study?
It depends on how much students in the same class influence each other and on what your analysis can handle. Student-level randomization gives more statistical power but risks contamination when students compare answers. Many classroom studies randomize by class or teacher instead. Your methodologist and IRB protocol should set this before any code is written.
Can I update a prompt in the middle of a study?
You can, but treat it as a protocol change. Give the new prompt a new configuration ID, record the date and the reason, and tell your analyst so the change can be modeled or reported. Editing a prompt in place with no version record makes the affected data hard to defend.
What happens if the model provider retires a model during my study?
You will have to move to a new snapshot, which is a version change in one or more conditions. Check each provider’s published deprecation dates before launch and pick snapshots that outlast your data collection window. If a retirement is unavoidable, plan the switch at a natural break, such as between units, and document it.
Is it safe to send student responses to a commercial model API?
That depends on your data use agreements with the districts, your IRB approval and the provider’s data-handling terms. Common steps include sending pseudonymous IDs instead of names, removing identifying details from free text where possible, and using settings that keep the provider from retaining data. Your institution’s counsel or compliance office makes the final call.
How much engineering time does an AI condition comparison layer take?
Adding server-side assignment, versioned configurations, call-level logging and fallback rules to an existing prototype typically takes 80–160 hours. The low end covers two conditions on one provider. More conditions, several providers, adaptive assignment or strict data-residency rules push the estimate toward the top of that range or past it.
Related answers
Planning an AI comparison study or a classroom pilot?
We will review the technical section of your proposal or your pilot plan for free in a 30-minute session. Bring the prototype’s repository or a demo, your pilot timeline, and your funder’s and IRB’s requirements. Start a conversation.