\section{Formal Syntax: The Agentic Operad}

To formalize the composition of agents, we define the Operad of Wiring Diagrams, denoted as WAgent. An operad
can be understood as a ``grammar'' for connecting operations (boxes) via typed wires. It defines which agent
topologies are valid and allows us to reason about the properties of the composite system based solely on the
properties of its components~\cite{vagner2015algebras}.

\subsection{The Typing Rules}

In WAgent, every wire carries a specific Type $\tau\in T$.
\begin{equation}
T = \{\text{Text}, \text{JSON}, \text{Image}, \text{Error}, \text{ToolCall}\}.
\tag{6}
\end{equation}
These types correspond to biological molecular specificity (e.g., a specific transcription factor only binds to
a specific DNA sequence). A connection is valid if and only if the type of the output port of Agent $A$ matches
the type of the input port of Agent $B$.

\subsection{The Composition Operations}

The operad defines three fundamental operations for combining agents. Any complex agentic architecture, no
matter how large, can be decomposed into these three primitives.

\subsubsection{Parallel Composition ($\otimes$)}

Two agents, $A$ and $B$, execute simultaneously with no information exchange:
\begin{equation}
A \otimes B.
\tag{7}
\end{equation}
\begin{itemize}[leftmargin=*]
\item \textbf{Biological Analogy:} Two genes located on different chromosomes expressing proteins independently.
\item \textbf{Constraint:} This operation is valid only if the internal state spaces $S_A$ and $S_B$ are disjoint.
If they share a mutable memory store, the operation leaves the \textbf{independent-state interpretation} and
requires an explicit \textbf{resource-sharing} structure (e.g., a shared state component or a Resource Sharing
decorator).
\end{itemize}

\subsubsection{Serial Composition ($\circ$)}

The output of Agent $A$ is piped directly into the input of Agent $B$:
\begin{equation}
B \circ A.
\tag{8}
\end{equation}
\begin{itemize}[leftmargin=*]
\item \textbf{Biological Analogy:} A Signal Transduction Pathway (Protein A activates Protein B).
\item \textbf{Formal Verification:} This allows for static type checking of agent graphs. If Agent $A$ outputs
Natural Language but Agent $B$ expects JSON Schema, the composition is undefined in WAgent. This moves runtime
\textbf{type/schema mismatch} errors to ``compile-time'' architectural errors.
\end{itemize}

\subsubsection{Contraction / Trace ($Tr$)}

A feedback loop where an output port of Agent $A$ is wired back into one of its own input ports:
\begin{equation}
Tr(A).
\tag{9}
\end{equation}
\begin{itemize}[leftmargin=*]
\item \textbf{Biological Analogy:} Autoregulation (Homeostasis) or Positive Feedback.
\item \textbf{Software Implication:} This is the topological definition of Agency. A ``stateless'' LLM is a simple
morphism. An ``Agent'' is a morphism wrapped in a Trace operation, allowing it to observe its own previous
outputs (Chain-of-Thought).
\end{itemize}

\subsection{Theorem: Topological Error Suppression}

We now use this formalism to show that the Coherent Feed-Forward Loop (CFFL) provides stronger error suppression
guarantees than a direct connection for high-stakes tasks.

\paragraph{Network Motif 1 (Coherent Feed-Forward Loop).}
A topological structure where Signal $X$ activates $Z$ directly, but also activates $Y$ which gates $Z$. The node
$Z$ functions as an AND gate: it fires if and only if $X \wedge Y$.

\paragraph{Theorem 1 (Error Suppression in CFFL).}
Let $A_{\mathrm{gen}}$ be a generator agent and $A_{\mathrm{ver}}$ be a verifier agent. Let
$P(E_{\mathrm{gen}})$ (resp.\ $P(E_{\mathrm{ver}})$) be the probability of a hallucination (error) in any single
generation step of $A_{\mathrm{gen}}$ (resp.\ $A_{\mathrm{ver}}$).
\begin{itemize}[leftmargin=*]
\item \textbf{Case 1: Direct Link (Serial).} The system fails if $A_{\mathrm{gen}}$ hallucinates.
\[
P(\mathrm{Fail}_{\mathrm{direct}}) = P(E_{\mathrm{gen}}).
\]
\item \textbf{Case 2: CFFL Topology.} The system requires the logical conjunction of the Generator's request
($X$) and the Verifier's approval ($Y$). Assuming the Verifier's error mode is independent of the Generator's
(e.g., different prompt strategy or model temperature), the probability that both agents simultaneously
hallucinate a ``Go'' signal for a destructive action is:
\[
P(\mathrm{Fail}_{\mathrm{CFFL}}) = P(E_{\mathrm{gen}}\wedge E_{\mathrm{ver}})
= P(E_{\mathrm{gen}})\times P(E_{\mathrm{ver}}).
\]
\end{itemize}
Since $0\le P(E_{\mathrm{gen}}),P(E_{\mathrm{ver}})\le 1$, it follows that
\[
P(E_{\mathrm{gen}})P(E_{\mathrm{ver}})\le \min\{P(E_{\mathrm{gen}}),P(E_{\mathrm{ver}})\},
\]
with strict inequality whenever both probabilities lie in $(0,1)$.

\paragraph{Proof.}
In WAgent, the CFFL is defined as a morphism involving a ``Copy'' operation $\Delta_X:X\to X\otimes X$ and an
``AND-Merge'' operation $\mu: Z\otimes Y \to \mathrm{Out}$. The existence of the $\mu$ box in the wiring diagram
structurally enforces \textbf{conjunctive gating}; statistical independence (or low correlation) between error
modes is an additional modeling assumption that can be encouraged by diversity in prompts/models. This shows
that certain safety properties are a property of the topology, not just the prompt engineering.

\begin{figure}[h]
\centering
\begin{tikzpicture}[>=Latex, node distance=12mm]
  \node[draw, rounded corners] (X) {User Request ($X$)};
  \node[draw, rounded corners, below=10mm of X] (Y) {Risk Assessor ($Y$)};
  \node[draw, rounded corners, right=22mm of X] (Z) {Executor ($Z$)};
  \node[draw, rounded corners, align=center] (AND) at (Z |- Y) {$\wedge$\\AND Gate};
  \node[draw, rounded corners, right=22mm of AND] (OUT) {Action};

  \draw[->] (X) -- node[above]{\small Type: Gen} (Z);
  \draw[->] (X) -- (Y);
  \draw[->] (Y) -- node[above]{\small Type: Check} (AND);
  \draw[->] (Z) -- (AND);
  \draw[->] (AND) -- (OUT);

	  \node[below=0mm of AND] {\small Validation Token};
	\end{tikzpicture}
	\caption{The CFFL implemented in WAgent. The Executor ($Z$) cannot act without the token from the Risk Assessor
	($Y$), topologically preventing unilateral execution without approval.}
	\end{figure}

\subsection{Quorum Sensing (Consensus \& Voting)}

\paragraph{Network Motif 2 (Quorum Sensing).}
A distributed topology where multiple agents emit a weak signal $\sigma$ into a shared environment. An effector
node $E$ activates if and only if the concentration $[\sigma] > \theta$.
\begin{itemize}[leftmargin=*]
\item \textbf{Biological Function:} Many bacteria (e.g., \emph{V. fischeri}) secrete auto-inducer molecules.
Individual bacteria do not react to low concentrations. However, once the population density reaches a threshold
(Quorum), the concentration of auto-inducers triggers a simultaneous, coordinated gene expression event (e.g.,
bioluminescence or biofilm formation).
\item \textbf{Agentic Isomorphism (Voting Ensembles):} In non-deterministic systems, a single agent's output is
noisy. By instantiating $N$ parallel agents (a Mixture of Experts), the system aggregates their outputs. The
final action is taken only if the ``concentration'' of a specific semantic token exceeds a confidence threshold.
This transforms weak, noisy individual signals into a robust, high-confidence collective action.
\end{itemize}

\subsection{Chaperone Proteins: Output Structural Validation}

\begin{itemize}[leftmargin=*]
\item \textbf{Biological Function:} Newly synthesized proteins emerge as linear chains that must fold into
precise 3D structures to function. Chaperone Proteins (e.g., GroEL-GroES) sequester unfolded proteins,
preventing aggregation and facilitating correct folding. If a protein fails to fold repeatedly, it is tagged for
degradation (Ubiquitination) to prevent toxic buildup.
\item \textbf{Agentic Isomorphism (Retry \& Repair Loops):} Generative models output unstructured token streams
(``linear chains''). However, downstream agents require strictly structured inputs (e.g., valid JSON Schemas).
A Validator Agent acts as a Chaperone: it intercepts the raw output, attempts to parse it into a formal schema
(``folding''), and if validation fails, returns the error trace to the generator for re-synthesis. This turns a
probabilistic string into a deterministic data structure.
\item \textbf{Categorical View:} The Chaperone acts as a \textbf{partial} retraction: there is an inclusion
$i:V\to S$ and a map $r:S\to V+\mathrm{Error}$ such that $r\circ i=\mathrm{inl}\circ \mathrm{id}_V$, and $r$ returns
$\mathrm{Error}$ on ill-formed text.
\end{itemize}

\subsection{Oscillator: Periodic Rhythms and Scheduling}

\paragraph{Network Motif 4 (Biological Oscillator).}
A topology that generates periodic behavior through delayed negative feedback. A node $A$ activates node $B$, which after a delay inhibits $A$, creating a self-sustaining cycle.

\begin{itemize}[leftmargin=*]
\item \textbf{Biological Function:} Oscillators underlie fundamental biological rhythms. The circadian clock regulates 24-hour cycles of gene expression. The cell cycle oscillator (Cyclin-CDK) drives periodic cell division. The heartbeat emerges from pacemaker cells with intrinsic oscillatory dynamics. These rhythms provide temporal organization to cellular processes.
\item \textbf{Agentic Isomorphism (Scheduled Tasks):} In agentic systems, oscillators map to periodic scheduling patterns:
\begin{itemize}
\item \textbf{Heartbeat Oscillator} $\to$ Health checks that verify system liveness at regular intervals
\item \textbf{Circadian Oscillator} $\to$ Daily maintenance tasks (log rotation, cache clearing, model refresh)
\item \textbf{Cell Cycle Oscillator} $\to$ Phased workflows with distinct stages (G1: gather, S: synthesize, G2: validate, M: execute)
\end{itemize}
\item \textbf{Formal Structure:} An oscillator is a Trace operation with a built-in delay element $\delta$:
\begin{equation}
\mathrm{Osc}(A) = Tr(A \circ \delta)
\tag{15}
\end{equation}
where $\delta: S \to S$ introduces temporal separation between activation and inhibition, preventing the system from reaching a fixed point.
\end{itemize}

The oscillator motif addresses a gap in typical agentic frameworks: most systems are purely reactive (responding to external stimuli) rather than proactive (generating internal rhythms). Biological systems maintain health through regular ``housekeeping'' independent of external input---a pattern that agentic systems should emulate for robustness.
