"""Criterion 2 under PRODUCTION (top2): the reused answer must be the CURRENT prompt's answer. Noise divergence is allowed; answering the PREVIOUS turn's question is not. W asks for ALPHA, P asks for BETA. The reused P must not answer ALPHA. """ import json, urllib.request, hashlib, re URL="http://127.0.0.1:8300/v1/chat/completions" def ask(prompt, mt=64, temp=0): body={"model":"glm-5.3-exl3","messages":[{"role":"user","content":prompt}],"max_tokens":mt, "temperature":temp,"return_token_ids":True} r=urllib.request.Request(URL,data=json.dumps(body).encode(),headers={"Content-Type":"application/json"}) d=json.loads(urllib.request.urlopen(r,timeout=3600).read()) st=d.get("tensorfold",{}) or {} m=d["choices"][0]["message"] txt=(m.get("content") or "") + "\n" + (m.get("reasoning_content") or "") ids=st.get("token_ids") or [] return st.get("cached"), hashlib.sha256(json.dumps(ids).encode()).hexdigest()[:16], txt.upper(), ids unit="The service validated the payload and emitted a structured record with stable ids. " stale=0; tot=0; noise=0 for it in range(6): base=unit*(70+it*9) W=base+"\nReply with exactly the single word: ALPHA" P=base+"\nReply with exactly the single word: BETA" cW,sW,tW,_=ask(W) cR,sR,tR,idR=ask(P) cC,sC,tC,idC=ask(P) beta_r = "BETA" in tR; alpha_r = "ALPHA" in tR and not beta_r beta_c = "BETA" in tC same = sR==sC tot+=1 stale += alpha_r noise += (not same) print(f"it{it}: warm={cW} reused={cR} cold={cC} | reused_says_BETA={beta_r} says_ALPHA={alpha_r} " f"cold_says_BETA={beta_c} | identical={same}", flush=True) print(f"\nSTALE (reused answered the WARM question): {stale}/{tot}") print(f"noise-level divergence (sha differs, allowed): {noise}/{tot}") print("### SEMANTIC DONE")