<?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: hon6</title>
    <description>The latest articles on DEV Community by hon6 (@hon6).</description>
    <link>https://dev.to/hon6</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%2F4223280%2Fc429a64c-3dcc-43a2-8d4a-966c84f34c64.png</url>
      <title>DEV Community: hon6</title>
      <link>https://dev.to/hon6</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hon6"/>
    <language>en</language>
    <item>
      <title>Where Claude Code and Codex keep /goal state, and how one open-source app reads both</title>
      <dc:creator>hon6</dc:creator>
      <pubDate>Tue, 03 Nov 2026 01:43:10 +0000</pubDate>
      <link>https://dev.to/hon6/where-claude-code-and-codex-keep-goal-state-and-how-one-open-source-app-reads-both-340a</link>
      <guid>https://dev.to/hon6/where-claude-code-and-codex-keep-goal-state-and-how-one-open-source-app-reads-both-340a</guid>
      <description>&lt;p&gt;Both Claude Code and Codex now have &lt;code&gt;/goal&lt;/code&gt;: you give a session a condition that can be checked, and the agent keeps working round after round until the condition is met. It is a good fit for long, well-defined jobs such as "get every unit test passing" or "first paint under 1.5 s and Lighthouse above 90", the kind of task where an agent would otherwise stop halfway and write a confident summary.&lt;/p&gt;

&lt;p&gt;The interesting part for tool builders is that the two agents record goals in completely different places. This post walks through both formats, using the implementation in &lt;a href="https://github.com/hon6/kiteline" rel="noopener noreferrer"&gt;Kiteline&lt;/a&gt;, an open-source desktop app (Mac, Windows, Linux) that follows Claude Code, Codex and other agent sessions and shows their progress on a phone. All the code mentioned below is in &lt;code&gt;watcher/kiteline-watch.py&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn2g6ec9zgnev6wbwrjv3.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn2g6ec9zgnev6wbwrjv3.jpg" alt="A session with an active goal: the goal bar above the message box shows the round, time spent and the last check" width="800" height="1739"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Claude Code: &lt;code&gt;goal_status&lt;/code&gt; attachments in the transcript
&lt;/h2&gt;

&lt;p&gt;Claude Code writes each session as a JSONL transcript. Once a goal is set, extra lines appear with &lt;code&gt;type: "attachment"&lt;/code&gt; and &lt;code&gt;attachment.type: "goal_status"&lt;/code&gt;. The fields tell you what happened:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Line&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;{met: false, sentinel: true, condition}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Goal set&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;{met: true, sentinel: true}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Goal cleared (&lt;code&gt;/goal clear&lt;/code&gt;, or an unrecoverable error)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;{met: false, condition, reason}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;One check: not met yet, &lt;code&gt;reason&lt;/code&gt; says what is missing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;{met: true, condition, reason, iterations, durationMs, tokens}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Goal met, with rounds, time and tokens&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;{failed: true, …}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The check decided the goal can't be met&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The check at the end of each round is itself a model call that judges the condition and explains why. Pauses show up as system lines instead, such as &lt;code&gt;Goal paused · &amp;lt;cause&amp;gt; · …&lt;/code&gt; or &lt;code&gt;Goal still active · &amp;lt;cause&amp;gt; · retrying in N min&lt;/code&gt;, which are easy to match:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;_GOAL_PAUSED_RE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;^Goal paused(?: after (\d+) automatic retries)? · (.+?) · &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;_GOAL_RETRY_RE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;^Goal still active · (.+?) · retrying in (\d+) min&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;_GOAL_ERROR_RE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;^Goal cleared after an unrecoverable error \((.+?)\)&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A small state machine (&lt;code&gt;ClaudeGoal&lt;/code&gt;) consumes these lines: the "set" line opens a goal, every check bumps &lt;code&gt;checks&lt;/code&gt; and stores the reason, and met / failed / cleared change the state. If the transcript was truncated or resumed and the "set" line is missing, it picks up from the first check it sees.&lt;/p&gt;

&lt;h2&gt;
  
  
  Codex: a &lt;code&gt;thread_goals&lt;/code&gt; table in local SQLite
&lt;/h2&gt;

&lt;p&gt;Codex does not put goals in the rollout file. They live in &lt;code&gt;goals_N.sqlite&lt;/code&gt; under &lt;code&gt;CODEX_HOME&lt;/code&gt;, one row per thread:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="n"&gt;thread_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;objective&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;token_budget&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tokens_used&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;time_used_seconds&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;created_at_ms&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;updated_at_ms&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;thread_goals&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;status&lt;/code&gt; is one of &lt;code&gt;active&lt;/code&gt;, &lt;code&gt;paused&lt;/code&gt;, &lt;code&gt;blocked&lt;/code&gt;, &lt;code&gt;usage_limited&lt;/code&gt;, &lt;code&gt;budget_limited&lt;/code&gt; or &lt;code&gt;complete&lt;/code&gt;. Two details matter when you read this from another process:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Open it read-only&lt;/strong&gt; (&lt;code&gt;sqlite3.connect("file:...?mode=ro", uri=True)&lt;/code&gt;) so you never compete with Codex for the write lock.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cache by modification time&lt;/strong&gt; of both the database file and its &lt;code&gt;-wal&lt;/code&gt; file. If neither changed, reuse the last result, so polling every second costs nothing. If the table doesn't exist (an older Codex), remember that until the file changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  One snapshot for every agent
&lt;/h2&gt;

&lt;p&gt;Both sources are turned into the same shape, and every UI (phone, watch, desktop) only reads that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Retry failed payment callbacks automatically…"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"state"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"active"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
 &lt;/span&gt;&lt;span class="nl"&gt;"checks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"reason"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1 case still fails: a duplicate callback for the same order is booked twice"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the phone this becomes "Goal · round 3" in the session list, and a goal bar above the message box with the round, the time spent and the last check:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdfea4mgfhlvpoq8wbxbe.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fdfea4mgfhlvpoq8wbxbe.jpg" alt="Goal details: progress, time and what the last check said is still missing" width="800" height="1739"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The hard part: deciding that a goal has stopped
&lt;/h2&gt;

&lt;p&gt;Reading the formats is easy. Deciding that a goal has &lt;em&gt;stopped&lt;/em&gt; is not, and a wrong answer means a confusing push notification.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Sessions look idle between rounds.&lt;/strong&gt; The end-of-round check is a model call that can take a while, and during it the session looks idle. Treating "idle" as "stopped" would fire a notification every round. Kiteline only trusts explicit signals (the pause lines above, or a &lt;code&gt;[Request interrupted by user]&lt;/code&gt; marker) and otherwise waits for two minutes of idleness before calling a goal paused.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reading one step behind.&lt;/strong&gt; Early on, goal state was updated together with the general transcript reader. With very fast rounds, the "should we notify?" decision sometimes used the previous goal and announced a "done" that wasn't. &lt;code&gt;ClaudeGoal&lt;/code&gt; now polls the file itself from a byte offset (starting over if the file was rewritten and got shorter), so the snapshot always has the latest state.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;"Done" after every round.&lt;/strong&gt; A goal can run dozens of rounds overnight. While a goal is active, the per-round "finished" notification is suppressed; you only hear about it when it is met, can't be met, or stops.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fth7lpg0mxyez0uk8x6t8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fth7lpg0mxyez0uk8x6t8.jpg" alt="A goal that was achieved after 4 rounds" width="800" height="1739"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Claude Code keeps goals in &lt;code&gt;goal_status&lt;/code&gt; attachment lines in the transcript; Codex keeps them in the &lt;code&gt;thread_goals&lt;/code&gt; table of a local SQLite file.&lt;/li&gt;
&lt;li&gt;Normalise both into one snapshot and let the UI read only that.&lt;/li&gt;
&lt;li&gt;For "stopped", prefer explicit signals and wait long enough otherwise. Reporting late is better than reporting wrong.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The full implementation (&lt;code&gt;ClaudeGoal&lt;/code&gt;, &lt;code&gt;GoalBook&lt;/code&gt;, &lt;code&gt;codex_goals&lt;/code&gt;, &lt;code&gt;goal_command&lt;/code&gt;) is in &lt;a href="https://github.com/hon6/kiteline" rel="noopener noreferrer"&gt;hon6/kiteline&lt;/a&gt;. Claude Code is a product of Anthropic and Codex is a product of OpenAI; Kiteline is an independent third-party tool.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>productivity</category>
      <category>devtools</category>
    </item>
  </channel>
</rss>
