Agents In Fields

In the case studied here, the field values generated by agents following the optimal policy at spacetime points $\{x\}$ are identical to the field values produced by the Euler-Lagrange equation of motion. The usual narrative and the agentic narrative are very closely related.

Share
Agents In Fields
An agent in a field. September 6, 2025.

In the previous post, we derived the equation of motion for a classical relativistic scalar field in 1+1 dimensions $\phi(x, t)$. What we found is that the values of the field at each point in spacetime could be computed by solving a second order differential equation. Using periodic boundary conditions in the space dimension, this became an initial value problem, where given the initial conditions of the field at its inception (call it $t=0$, where we provide field values $\phi(x, t=0)$ and their temporal derivatives $\partial \phi /\partial t$ at $t=0$), we could then compute all the subsequent field values for all future times deterministically by stepping forward in time.

There is a connection between this sort of mathematical problem and the notion of agents, in that each steps forward in time by solving some sort of problem and then outputting its solution (or in the case of an agent, selecting an action).

In the case of the field values in an initial value problem, the differential equation deterministically produces the next timestep field value. Explicitly for the field we considered in the last post for the $\phi^4$ potential, we found the field value at time index $k+1$ at spatial site index $n$ by computing

$$\phi_n^{\,k+1} = 2\phi_n^{\,k} - \phi_n^{\,k-1} + \frac{\epsilon_0^2}{2}\left[\phi_{n+1}^{\,k} - 2\phi_n^{\,k} + \phi_{n-1}^{\,k}\right] - \frac{\epsilon_0^2\,\epsilon_1^2}{2}\left[\tilde h \pm \phi_n^{\,k} + \frac{\tilde\lambda}{6}\bigl(\phi_n^{\,k}\bigr)^{3}\right]$$

Given a set of four local field values $ \{ \phi_n^{\,k}$, $\phi_n^{\,k-1}$, $\phi_{n+1}^{\,k}$, $\phi_{n-1}^{\,k} \}$ and four dimensionless parameters $ \{ \epsilon_0, \epsilon_1, \tilde{h}, \tilde{\lambda} \}$, the next step field value $\phi_n^{\,k+1}$ then follows.


What I'd like to explore here is a strange kind of situation where for some points in our discretized space there sits an agent. The actions available to this agent will map exactly to the allowed field values. In the case of a classical scalar field this just means the action space for the agent is just a single real number. But we should be able to use this construction for arbitrary fields.

In this initial investigation, I want the agent to "take over responsibility" for generating its field values from the deterministic evolution implied by the equation of motion.


Let's take a look at what can we say about the situation where some of the field values come from the Euler-Lagrange equations, and some from decision-making agents.

The length scale $L=Na$ is the 'size' of the spatial dimension; $L$ and $a$ have units of length. Let's assume that $N \gg 1$, so that the dimensionless spatial lattice spacing $a/L = 1/N \ll 1$. Let's also assume that the time step $\delta$ is the same as $a$.

We then have something like the picture below, where each lattice point indexed by integers $(n, k)$ has a real-valued field value $\phi_n^{\,k}$, which is either the deterministic evolution of the field under its equation of motion, or the $k^{th}$ action in a sequence of actions taken by an agent living on spatial site $n$. There are $0..N$ agents, from none to a maximum of one per spatial lattice site. If there is an agent on a site, its observations are the cells colored in blue (light blue for one site away, and dark blue for its own site), and their action is to set the value of $\phi$ for the purple cell (one step into the future). In this picture, we could imagine sites $n=2$ and $n=4$ each having agents making decisions about their field values, where we explicitly show the observation and action space for the $n=2$ agent at $k=2$ and the $n=4$ agent at $k=8$.

Space-Time Grid
Time
Space

The restriction of the observation space to just be nearest neighbors is the imposition of locality on the agents. Here we assume everything is local.

If we still want the physics of the world to not depend on the labeling of the x-axis, even with the agents in it, that means each site has to at the very least be capable of developing the same physics whether or not there is an agent on it. If at least one of them were not, different points in space would have different laws of physics. Note that this is not exactly the same thing as all agents being the same agent. What we impose is that the internal structure of each agent be the same, but what they learn could be different.

To be concrete, here is a specific neural net we use in what follows. There are four real numbers in the observation space (the blue squares), six hidden units, and one real number in the action space (the purple square).

Neural Network Visualization
Local Update Network
🤎
Something strange here worth noting. The universe is supposed to be made up only of a single field $\phi$, but we just assumed agents living in it have access to neural nets. These neural nets are not made out of the field. The reason we can do this at all is that both the field and the neural net are running on computers. Fundamentally both types of things are made out of bits and operations on bits. This is the first glimpse of a separation I'm going to try to pin down in a later post. In some of our universes there is a categorical separation between what I'm going to call worldstuff (the stuff of the universe the agent observes and acts on) and mindstuff (the stuff the agent uses to learn and think).

We need to specify reward now. Let's assume that all there is available to the agents are the observations of the field values and the action it is currently taking. That means that reward for an agent at spatial site $n$ has to be some function $g$ of these $r_n=g(\phi_n^{\,k}, \phi_n^{\,k-1}, \phi_n^{\,k+1}, \phi_{n+1}^{\,k}, \phi_{n-1}^{\,k})$. Let's substitute $u=\phi_n^{\,k}$, $v=\phi_n^{\,k-1}$, $w=\phi_n^{\,k+1}$, $y=\phi_{n+1}^{\,k}$ and $z=\phi_{n-1}^{\,k}$.

We know that $r$ can't be a function of $n$ (that would mean physics was different at different sites). So there is a universal reward $r=g(u, v, w, y, z)$, independent of the site the agent sits on. In addition we specify that the reward must be Poincare invariant. What this means is that since we want physics to be the same in all inertial frames, the reward itself (which drives behavior of the agents) has to have this property, otherwise agents would develop different policies at different sites, breaking the relativity constraint.

The key observation here is that imposing the exact same conditions to $r$ as we did to $\cal{L}$ gives the exact same functional form for $r$ for the same reasons. The explicit derivation of why $\cal{L}$ looks the way it does applies exactly to $r$. Namely, assuming all the same things we did in the previous post,

$r(\phi) = {{1}\over{2}} \left[ -\left({{\partial \phi}\over{dt}}\right)^2 + \left({{\partial \phi}\over{dx}} \right)^2 \right] - r_0(\phi)$

All possible functions at spacetime point $(x, t)$ sharing the constraints we used to write down ${\cal L}$ look like this, up to multiplicative factors.


In the previous post, we went from the Lagrangian density to the equation of motion by first writing down the action, and then finding conditions on the field such that small deviations around special configurations did not change the action (this latter generating the Euler-Lagrange equation of motion). Let's see how this same sequence plays out for an agent.

Discretizing the reward on our grid gives

$$r _{n,k} = \frac{1}{2\delta ^{2}}\Bigl[\bigl(\phi _{n+1} ^{k}-\phi _n ^{k}\bigr)\bigl(\phi _n^{k}-\phi _{n-1} ^{k}\bigr) - \bigl(\phi _n ^{k+1}-\phi _n ^{k}\bigr)\bigl(\phi _n ^{k}-\phi _n^{k-1}\bigr)\Bigr] - r _0(\phi _n ^{k})$$

We can find the optimal policy for an agent with this reward using the Bellman equation for the optimal state-value function

$V ^{*}(\mathbf{s}) = \max _{a \in \mathbb{R}} \left[ r(\phi(\mathbf{s}, a)) + \gamma \int _{\mathbb{R} ^{4}} P(\mathbf{s}' \mid \mathbf{s}, a) \, V ^{*}(\mathbf{s}') \, d\mathbf{s}' \right]$

In our case we have time-reversal symmetry ($\gamma=1$) and we've assumed the observations $\mathbf{s}$ at site $(n, k)$ are the four real numbers $\phi_n^{\,k}$, $\phi_n^{\,k-1}$, $\phi_{n+1}^{\,k}$, $\phi_{n-1}^{\,k}$ and the action output $a$ is a single real number $\phi_n^{\,k+1}$.

We know that given state $\mathbf{s} = [\phi_n^{\,k}, \phi_n^{\,k-1}, \phi_{n+1}^{\,k}, \phi_{n-1}^{\,k}]$ and action $a=\phi_n^{\,k+1}$, the resultant state $\mathbf{s}'$ is $\mathbf{s}' = [\phi_n^{\,k+1}, \phi_n^{\,k}, \phi_{n+1}^{\,k+1}, \phi_{n-1}^{\,k+1}]$ by definition (these are the next time step field values in each case).

Let's choose some notation to make what follows a bit easier. Let's define

$$\mathbf{s}_{n, k} = [s_1, s_2, s_3, s_4] \equiv [\phi_n^{\,k}, \phi_n^{\,k-1}, \phi_{n+1}^{\,k}, \phi_{n-1}^{\,k}]$$

Then

$$\mathbf{s}'_{n, k} = \mathbf{s}_{n, k+1} $$

The Bellman equation at site $(n, k)$ is

$V ^{*}(\mathbf{s}_{n, k}) = \max _{\phi_n^{\,k+1} \in \mathbb{R}} \left[ r _{n, k} + V ^{*}(\mathbf{s}_{n, k+1}) \right]$

First Order Optimality

For the value of the right hand side to be a max over $\phi_n^{\,k+1}$, we need the derivative of this term to be zero, so

${{\partial r _{n, k} }\over{\partial \phi_n^{\,k+1}}} + V ^{*} _ {1} (\mathbf{s}_{n, k+1}) = 0$

where $V ^{*} _ {1}$ denotes $\partial V ^ * / \partial s _ 1$ (the derivative with respect to the first component of $\mathbf{s}_{n, k+1}$, which is the action $a=\phi_n^{\,k+1}$).

Define the canonical momentum

$\pi _n ^ k \equiv V ^{*} _ {1} (\mathbf{s}_{n, k}) $

We can then rewrite the first-order condition above as

$\pi _ n ^ {k+1} = - {{\partial r _{n, k} }\over{\partial \phi_n^{\,k+1}}}$

The Envelope Theorem

The envelope theorem says that when you differentiate a maximized function with respect to a parameter, you can ignore how the maximizer itself shifts — only the direct dependence on the parameter matters.

We can use this here to differentiate the Bellman equation with respect to both the first and second slots of the state (what we called $s_1$ and $s_2$ above). If we do this we get the following two equations respectively:

$$ V _ 1 ^ * ( s _ {n, k}) = {{\partial r _ {n, k}}\over{ \partial \phi _ n ^ k}} + V _ 2 ^ * (s _ {n, k+1}) $$

$$ V _ 2 ^ * ( s _ {n, k} ) = {{\partial r _ {n, k}}\over{ \partial \phi _ n ^ {k - 1}}} $$

If we time-shift the second equation $ k \rightarrow k + 1$ and substitute it into the first, we get

$$ \pi _ n ^ k ={{\partial r _ {n, k}}\over{ \partial \phi _ n ^ k}} + {{\partial r _ {n, k + 1}}\over{ \partial \phi _ n ^ k}} $$

Substituting the first-order condition we derived previously gives

$$ {{\partial r _ {n, k - 1}}\over{ \partial \phi _ n ^ k}} + {{\partial r _ {n, k}}\over{ \partial \phi _ n ^ k}} + {{\partial r _ {n, k + 1}}\over{ \partial \phi _ n ^ k}} = 0$$

which in the continuum limit is

$$\boxed{ - {{\partial ^ 2 \phi}\over{\partial t ^ 2}} + {{\partial ^ 2 \phi}\over{\partial x ^ 2}} - {{\partial r _ 0 ( \phi)}\over{\partial \phi}} = 0}$$

which is the exact same equation of motion we got previously, assuming the identification of on-site reward with on-site potential.

The Upshot

In this context, Bellman optimality and the principle of stationary action are the same thing. Maximizing $\sum_{n, k} r_{n, k}$ for a set of agents at sites $\{n\}$ is what the Bellman recursion is solving. The extremization $\partial(\sum r)/\partial\phi_n^k=0$​ at every lattice point is the discrete Euler-Lagrange equation, and the first order condition plus envelope-theorem manipulation above is just the recursive way of deriving it from the value function. $\pi_n^k = \partial V^*/\partial\phi_n^k$​ is the lattice canonical momentum.

This correspondence result is well-known in the field of optimal control theory. The continuous-time analog of the Bellman equation is the Hamilton–Jacobi–Bellman equation. In the deterministic, undiscounted case we looked at here, this reduces to the Hamilton–Jacobi equation of classical mechanics, with the value function $V^*$ playing the role of Hamilton's principal function $S$, and the costate / Lagrange multiplier playing the role of canonical momentum $\pi= \partial S/\partial q $.

We Can Draw The Agent / Environment Boundary Arbitrarily In This Universe Without Changing Its Behavior

In the case studied here, the equations of motion determining the field values have the same functional form if they are derived from stationary action or from the Bellman equation. We can make the two identical by selecting the reward $r_0(\phi)$ to be the same as the potential $V(\phi)$.

🤎
The move that causes this equivalence is that the kinds of general functions that respect all our imposed constraints are quite restricted. We cannot choose reward arbitrarily. The reward function is fixed by meta-conditions we imposed on the rules of the universe, and agents acting optimally under this reward follow the exact same equations of motion as the Euler-Lagrange equations.

This is an example of a case where the choice of boundary between 'agent' and 'environment' does not change the (at least long-time, see below) physical evolution of the system. In the previous post, we introduced this concept by just stating this always had to be true. But here we have an example where we can quantitatively show that there are choices we can make that ensure this is the case. This is a fundamental property that emerges from the structure of this toy universe.

🤎
One of the possibilities for distinguishing the two is the short-time behavior of the two would be different. The agentic view must presumably first learn the optimal policy before it can start following it, whereas the Euler-Lagrange view does not require this. An experimental signature to differentiate these could look at very early field dynamics (in our Universe, this would mean timescales very close to when the relevant fields were "born"). We could look at the inflationary early universe to see if an agentic view might be consistent with an early "learning phase". (Caveat: I know absolutely nothing about inflation or cosmology.)

Here is a visualization of the case where two randomly selected sites have field values generated by agents instead of by the Euler-Lagrange equation of motion. In this case, both agents use the same neural net and share training data.

0.06
0.04
0.00
6.00
step 0 max|φ| 0.00 agents at —
policy network (4→6→1 with biases, shared by both agents)
smoothed reward (EMA, target = 0)