concept
Bounded agent state machines
Offline bounded lookup state machine; budgets are fixed synthetic units.
Formal Syntax & Structure
artificial-intelligence syntaxartificial-intelligence
run(observations, limits, cancel_at=None)Working Example
Example Snippetartificial-intelligence
def run(observations, limits, cancel_at=None): # Trusted, nonnegative integer limits: steps, tokens, cost, ticks. # Each fake lookup reserves one step, two tokens, three cost units, # and one tick. No actual clock, money or external calls. if len(limits) != 4 or any(type(x) is not int or x < 0 for x in limits): raise ValueError("invalid limits") used = [0, 0, 0, 0] trace = [] attempts = 0 for observation in observations: if cancel_at is not None and attempts >= cancel_at: return "cancelled", used, trace proposed = [a+b for a,b in zip(used, (1,2,3,1))] if any(a>b for a,b in zip(proposed, limits)): return "budget", used, trace used = proposed attempts += 1 trace.append("lookup") if observation == "found": return "done", used, trace if observation != "retry": return "escalated", used, trace return "escalated", used, trace
print(run(["retry", "found"], [2,4,6,2]))print(run(["retry", "found"], [1,4,6,2]))print(run(["retry", "found"], [2,4,6,2], 1))