HomeRoadmapsAgent Memory Day 2
Conversational AI, Agent Memory & Multi-Turn Testing Β· Day 2 Β· 20 min

Model Parameter Sweeps & Determinism
Conversational AI, Agent Memory & Multi-Turn Testing β€” Day 2

Sweep temperature, top_p, seed, and max_tokens across repeated runs to measure output variance, verify seed reproducibility, and catch mid-JSON truncation failures.

⚑ Runtime: Python 3.10+ · Zero External Dependencies (unittest)🧠 Conversational AI & Agent Memory QE Lead
TemperatureTop-PSeed DeterminismMax TokensTruncation Gate
About this lab

Uncontrolled sampling parameters turn deterministic customer-servicing workflows into flaky systems. Today you will sweep combinations of temperature, top_p, seed, and max_tokens to enforce repeatability SLAs and detect truncated JSON payloads.

πŸ“¦Sample Codebase & Working Solution (Day 2)Available Now
View on GitHub

The official reference codebase for Day 2 is hosted in the repository. Clone the repository and navigate to day-2-model-parameters/test_day2.py to run the working solution.

Git Clone β€” Working Solution
git clone https://github.com/777abhi/agent-memory-testing-roadmap.git
cd agent-memory-testing-roadmap/day-2-model-parameters/test_day2.py
🏭Production Context & Regulated Servicing Implementation
πŸ’‘ Why We Are Doing This: A tight max_tokens budget silently clips structured tool calls or compliance disclosures, while unseeded high-temperature sampling produces inconsistent dispute status responses.
🏒 Real-World Production Usecase: CI parameter matrix asserting 100% seed determinism and 0% finish_reason=length truncation across structured servicing intents.
βš™οΈ How Implemented in Production: ModelParams, simulate_generation, and run_parameter_sweep in memlab/parameters.py.
Phase 1

Run Model Parameter Sweep Assertions

Execute the Day 2 parameter sweep suite to validate determinism and truncation detection.

Step 1.1: Run Day 2 Parameter Tests
Terminal β€” Run Day 2
npm run test:day2
Step 1.2: Sweep & Truncation Gate
memlab/parameters.py
sweep = run_parameter_sweep(
    intent="dispute_status",
    param_grid=[ModelParams(temperature=0.0, top_p=1.0, seed=42, max_tokens=64)],
    runs_per_config=6,
    min_exact_match_rate=1.0,
    max_truncation_rate=0.0,
)
Day 2 Key Learnings
  • Verified exact-match repeatability for zero-temperature and fixed-seed configurations.
  • Measured output variance across unseeded high-temperature runs to quantify sampling flakiness.
  • Caught finish_reason=length truncation and broken JSON closing delimiters when max_tokens is under-provisioned.

🧠 Knowledge Check

What failure mode does asserting finish_reason and valid JSON closing delimiters catch during a max_tokens sweep?