<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="384586" data-post-id="384586">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="byu" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/byu/120/32032_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  byu
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<blockquote>
<p>Agent durability? Yes</p>
</blockquote>
<p>From reading 2.0’s docs and code, the concepts feel like there is some sort of analog/overlap with CQRS and Functional Event Sourcing. I haven’t thought it through, and am just spit-balling here  … I see vaguely see similarities and differences:</p>
<p>Not a critique in any way, just reconciling my own mental model of the approaches.</p>
<p>Both:</p>
<ul>
<li>keep the decision logic purely functional</li>
<li>makes outcomes explicit as data</li>
<li>lets infrastructure execute side-effects outside the core</li>
</ul>
<p>Differences:</p>
<ul>
<li>what is emitted
<ul>
<li>CQRS/ES Aggregates (i.e. Commanded or the Functional Deciders) use “events” as the canonical output.
<ul>
<li><code>events = f(command, state)</code></li>
</ul>
</li>
<li>Jido Actions have state+directives as the canonical output.
<ul>
<li><code>{state, directives} = f(command, state)</code></li>
</ul>
</li>
</ul>
</li>
<li>Ownership of side-effects:
<ul>
<li>CQRS/ES Aggregates: downstream observers own the decision about what side-effects to perform; more descriptive.</li>
<li>Jido Actions: agents (the producer) owns the decisions about side-effects; more prescriptive.</li>
</ul>
</li>
<li>State
<ul>
<li>CQRS/ES – state is a projection of events; events are the source of truth</li>
<li>Jido Agents – current agent state an object, and is snapshotted.</li>
</ul>
</li>
</ul>
<p>References:</p>
<ul>
<li><a href="https://thinkbeforecoding.com/post/2021/12/17/functional-event-sourcing-decider" rel="noopener nofollow ugc">Functional Event Sourcing: Deciders + Evolvers</a></li>
<li><a href="https://hex.pm/packages/commanded" rel="nofollow">Commanded</a></li>
</ul>
<p>Round about way to get to my question…</p>
<p>I see that Jido has Threads, and <a href="https://github.com/agentjido/jido/blob/0b376d5b52970d88b00f62e4456d92edee73d185/guides/storage.md?plain=1#L45" rel="noopener nofollow ugc">storage docs diagram</a> states that agent state is a projection of threads, and that the thread is “Replayable, auditable” , but it seems like that the current state is what is snapshotted and serialized into a datastore; that the <a href="https://github.com/agentjido/jido/blob/0b376d5b52970d88b00f62e4456d92edee73d185/lib/jido/agent.ex#L990" rel="noopener nofollow ugc">restoration</a> is loading the serialized state directly. Am I reading correctly that “state checkpointing” is the durability strategy employed? That threads are more for auditing purposes – or LLM conversation building–  instead of rebuilding state? What are your thoughts about the descriptive vs prescriptive nature of Aggregates vs Agents? Can we think of Agents as a kind of long lived Aggregate (DDD, not CQRS/ES)?</p>
<p>thanks ahead for clearing up my confusion <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="384586" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/jido-a-sdk-for-building-autonomous-agent-systems/68418/52">Post #51</a>
	                </div>
	            </div>
              <div id="likers-container-384586" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="384586"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #51"></div>
  </section>
</div>
    <div class="postbit" id="384605" data-post-id="384605">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mikehostetler" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mikehostetler/120/20620_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mikehostetler
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Regarding similarities to Commanded, CQRS and Functional Event Sourcing - yes, you are spot on. I’ve stayed away from any CQRS language when describing Jido simply because “Agents” as a pattern was still evolving. I found a few edge cases where Agents bend the rules of CQRS &amp; Event Sourcing enough that I didn’t want to add confusion.  Your list of differences is a good start, there’s a few others.</p>
<p>The book “Real World Event Sourcing” was a great resource for me and fingerprints from that book are all over Jido.  Sensors implement the Event Sourcing “gateway” as well etc.</p>
<p>I did my best to implement solid patterns across Jido in other places as well.</p>
<p>Actions and the lesser known <code>%Instruction</code> form a <a href="https://refactoring.guru/design-patterns/command" rel="noopener nofollow ugc">Command Pattern</a> upon which all of Jido is based. Being very intentional about the architectural boundaries here led to splitting this all out as the <code>jido_action</code> package.</p>
<p>If you squint a bit, Agent State can be termed as a specialized form of an Aggregate. Again, I didn’t pull out the Event Sourcing rules around Aggregates - I decided to optimize more for the developer experience etc.</p>
<blockquote>
<p>Am I reading correctly that “state checkpointing” is the durability strategy employed?</p>
</blockquote>
<p>Right now, yes. My strategy here hasn’t been super mature yet. The task for the 2.0 release was to stabilize the extension points - which was accomplished via <code>Jido.Storage</code> and <code>Jido.Persist</code> <a href="https://hexdocs.pm/jido/storage.html" class="inline-onebox" rel="noopener nofollow ugc">Persistence &amp; Storage — Jido v2.3.2</a></p>
<p>I envision extra packages for persistence to Redis and Postgres which will help dial this in.</p>
<p>I also really want to nail the clustered durability story as well - I’ve looked at a few solutions to this but don’t have anything concrete yet.</p>
<p>Hope that answers your question - happy to chat more!</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="384605" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/jido-a-sdk-for-building-autonomous-agent-systems/68418/53">Post #52</a>
	                </div>
	            </div>
              <div id="likers-container-384605" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="384605"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>