Reference
Dense cheatsheets — the pages you pin while building.
Python
Python: JSON, types, and dicts
json.loads/dumps, dict key sets, and the action object {tool, args} used everywhere on Joeven.
Python stdlib for agents
The modules Joeven Try-it boxes actually use: json, re, math, hashlib, copy, collections.
Errors, retries, and fail-closed
Return error dicts from tools, retry only timeout/parse/rate_limit, never retry unknown_city.
Math
Vectors, dot product, cosine
The geometry behind RAG: lists of floats, dot product, L2 norm, cosine in [0, 1] for TF vectors.
Probability and sampling
Bernoulli entropy, expected cost, greedy vs weighted sample — decoding in one page.
Softmax and attention weights
Numerically stable softmax, attention as weighted sum, why you subtract max(logits).
LLM APIs
Chat messages and roles
system / user / assistant / tool roles, ordering, and what not to put in a system prompt.
Tokens, context, and cost
Rough token math, why loops multiply cost, and what to trim first.
Structured output and JSON schemas
Force {tool, args} or vendor tool_calls; reject extra keys; repair once then fail.
Agent patterns
ReAct loop
Thought → Action → Observation until finish; parse text to the same {tool, args} runtime.
Tool schemas and registries
Name → callable, JSON args, error dicts, allowlists. The model never gets globals()[name].
Plan-and-execute vs ReAct
When to write a plan first, when to interleave, and why a supervisor state machine beats a swarm.
Memory, traces, and scratchpads
Transcript vs side trace vs long-term memory. What to store, hash, and drop.
Safety
Prompt injection
Untrusted text in pages, tickets, and users. Delimit observations, never execute them, enforce citations and allowlists.
Human approval gates
Approve a digest of tool+args, not a bare id. Mutate never runs on missing/deny/tamper. Stop while waiting.
Sandboxes, allowlists, and exec
Path allowlists, host allowlists, tiny builtins, blocklists as defense-in-depth — not as the only wall.