<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: professor-js</title>
    <description>The latest articles on DEV Community by professor-js (@professorjs).</description>
    <link>https://dev.to/professorjs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2170353%2F14e294e1-7554-4598-ab5f-f2a73ce29913.png</url>
      <title>DEV Community: professor-js</title>
      <link>https://dev.to/professorjs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/professorjs"/>
    <language>en</language>
    <item>
      <title>Restraint as Architecture: A Zero-Dependency State Machine for Agents</title>
      <dc:creator>professor-js</dc:creator>
      <pubDate>Mon, 30 Nov 2026 06:29:45 +0000</pubDate>
      <link>https://dev.to/professorjs/restraint-as-architecture-why-i-built-a-zero-dependency-state-machine-for-agents-4ld0</link>
      <guid>https://dev.to/professorjs/restraint-as-architecture-why-i-built-a-zero-dependency-state-machine-for-agents-4ld0</guid>
      <description>&lt;p&gt;Most autonomous agent setups start as an unconstrained &lt;code&gt;while&lt;/code&gt; loop around a model and tools. In practice, that tends to break down in three familiar ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Runaway loops &amp;amp; idle polling:&lt;/strong&gt; Re-running failing tool calls or busy-polling unchanged state until the budget is gone.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Amnesia on restart:&lt;/strong&gt; Crashes or timeouts wipe active subproblems and budgets—or worse, naive transcript replays risk repeating non-idempotent side effects.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unstructured concurrency:&lt;/strong&gt; Background workers mutating shared state without coordination, producing race conditions and non-reproducible traces.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;FTR.cc&lt;/strong&gt; (&lt;em&gt;"Three Problems. Three Threads. One Process."&lt;/em&gt;) approaches this as a single-process cooperative state machine in &lt;strong&gt;Python 3.10+ (standard library only, GNU GPLv3)&lt;/strong&gt; rather than a prompt wrapper.&lt;/p&gt;

&lt;h3&gt;
  
  
  How It's Structured
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Three bounded proposal generators:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Thread 0 (Present):&lt;/strong&gt; Reactive event/timer handling that schedules future checks instead of busy-polling.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Thread X (Past):&lt;/strong&gt; Episodic memory and consolidation that turns repeated failures into policy rules (&lt;code&gt;avoid:&amp;lt;action&amp;gt;&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Thread hmzs26 (Future):&lt;/strong&gt; Bayesian hypothesis tracking and bounded best-first planning aimed at high-information-gain steps.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Marginal-value scheduler &amp;amp; true idle (&lt;code&gt;theta_wake&lt;/code&gt;):&lt;/strong&gt; Scores candidate actions by utility, urgency, information gain, novelty, confidence, cost, and fixation penalty—and enters &lt;code&gt;LIGHT_IDLE&lt;/code&gt;, &lt;code&gt;DEEP_IDLE&lt;/code&gt;, or &lt;code&gt;HIBERNATE&lt;/code&gt; when nothing clears &lt;code&gt;theta_wake&lt;/code&gt; (checked &lt;em&gt;before&lt;/em&gt; starvation credit so fairness doesn't invent busywork).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hash-chained WAL &amp;amp; atomic snapshots:&lt;/strong&gt; Logs &lt;code&gt;intent&lt;/code&gt; before external side effects and &lt;code&gt;result&lt;/code&gt; after, using deterministic idempotency keys and torn-tail truncation on crash recovery.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Run It Yourself (Zero Dependencies)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/hmzs26/FTR.cc.git
&lt;span class="nb"&gt;cd&lt;/span&gt; FTR.cc

&lt;span class="c"&gt;# Unit &amp;amp; fault-injection tests&lt;/span&gt;
python3 -m unittest discover -s tests -v

&lt;span class="c"&gt;# Synthetic benchmarks &amp;amp; ablations&lt;/span&gt;
python3 experiments/run_experiments.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the synthetic benchmarks (details in &lt;code&gt;paper/FTR_cc_Unified_Paper.md&lt;/code&gt;), the reference runtime in &lt;code&gt;src/ftr.py&lt;/code&gt; handles delayed results (&lt;code&gt;t=60&lt;/code&gt;) with &lt;code&gt;1&lt;/code&gt; poll and &lt;code&gt;1&lt;/code&gt; scheduled check instead of dozens of wasted polls, halts unfixable tool errors after &lt;code&gt;2&lt;/code&gt; attempts via fixation penalty, and preserves &lt;code&gt;41/41&lt;/code&gt; identical state hashes across 6 WAL crash-injection points with &lt;code&gt;0&lt;/code&gt; duplicate side effects.&lt;/p&gt;

&lt;h3&gt;
  
  
  Honest Scope &amp;amp; Where Feedback Helps Most
&lt;/h3&gt;

&lt;p&gt;Right now the benchmarks run in a &lt;strong&gt;deterministic simulated environment&lt;/strong&gt; rather than wired to live stochastic LLM APIs, and operational restraint isn't a substitute for semantic/alignment guardrails.&lt;/p&gt;

&lt;p&gt;I'd love honest feedback on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Where the &lt;strong&gt;marginal-value / &lt;code&gt;theta_wake&lt;/code&gt; sleep gate&lt;/strong&gt; could still over-sleep or miss urgent work under tricky inputs.&lt;/li&gt;
&lt;li&gt;Any &lt;strong&gt;WAL / crash-recovery edge cases&lt;/strong&gt; you spot in &lt;code&gt;src/ftr.py&lt;/code&gt; or &lt;code&gt;tests/test_ftr.py&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Live LLM adapter&lt;/strong&gt; trade-offs (especially content-addressed caching and token cost modeling) as a next step.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Repo:&lt;/strong&gt; &lt;code&gt;https://github.com/hmzs26/FTR.cc&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>architecture</category>
      <category>agents</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
