Reference/Python
Python stdlib for agents
The modules Joeven Try-it boxes actually use: json, re, math, hashlib, copy, collections.
Joeven browser examples stay on the stdlib. No NumPy, no requests.
Cheat sheet
| Module | Agent job |
|---|---|
json | actions, traces, reports |
re | ReAct parse, tokenize, redact |
math | cosine, softmax, sqrt |
hashlib | approval digests, file hashes |
copy.deepcopy | snapshot worlds |
collections.Counter | bag-of-words counts |
itertools | product of eval grids |
functools.lru_cache | cache embeddings of chunks |
dataclasses (optional) | typed traces on disk |
Regex fragments
| Pattern | Meaning |
|---|---|
[a-z]{3,} | tokens length ≥ 3 |
Thought:\s(.) | ReAct thought line |
sk-[A-Za-z0-9]{6,} | fake API keys to redact |
(?m)^# | markdown headings |
(?<=\.)\s+ | sentence split |
hashlib
python
import hashlib, json
def sha(obj):
blob = json.dumps(obj, sort_keys=True, separators=(class="tok-s">",", class="tok-s">":"))
return hashlib.sha256(blob.encode()).hexdigest()Always encode() — sha256 wants bytes.
copy
| Call | When |
|---|---|
dict(d) | shallow, values immutable/strings |
list(xs) | copy a log tail |
copy.deepcopy(world) | nested metrics dicts |
Watch out:exec/evalare stdlib and still hostile. Use only in the multi-agent classroom oracle with tiny__builtins__.