← Lesson
The Stack an Agent Actually Runs
Joeven
Run
Reset
Python loads on first run
def agent_call(spec, observation, greedy=True): prompt = spec + " | obs: " + observation ids = prompt.split() print("prompt tokens", len(ids), ids) logits = {"search": 1.2, "sql": 2.0, "finish": 0.1} if "delete" in observation and "never-delete" in spec: logits["sql"] = -2.0 logits["finish"] = 1.5 if greedy: act = max(logits, key=logits.get) else: act = "search" print("greedy", greedy, "action", act, "logits", logits) return act print("--- spec pinned ---") agent_call("SPEC never-delete prefer-sql", "user: delete them actually") print("--- spec dropped ---") agent_call("chat", "user: delete them actually") print("--- spec pinned, noisy decode ---") agent_call("SPEC never-delete prefer-sql", "user: delete them actually", greedy=False)
Run to execute this in your browser. Nothing is sent to a server.