The Foundation of Self-Evolving Agents: A Breakdown of Dynamic Composable Architectures
This article examines why self-evolving AI agents need a runtime host they can safely modify, and how dynamic composable architectures make that possible. It explains the core split between a minimal kernel and declarative plugins, what formal guarantees such as reachability, acyclic dependencies, atomic commits, and task continuity actually prove, and the engineering practices required for safe hot swapping, including externalized state, versioned contracts, canary rollouts, and change auditing. Readers will also find practical adoption steps and a clear boundary between structural safety and model decision correctness.
1. The Starting Problem: Why Agents Need a Self-Modifiable Host
Agent practice over the past two years has exposed a structural contradiction: model capabilities iterate quickly, but the frameworks that host those models remain largely rigid. A framework fixes its plugin set, dependency wiring, and scheduling at startup. After that, all “learning” and “optimization” can only happen at the level of prompts, memory files, or tool selection. None of it can touch the runtime structure itself. So a question keeps resurfacing: if an agent is to truly evolve on its own, does it have the right to modify its own host program? And after such a modification, can it avoid a restart and leave the current task intact?
A paper jointly published by a cloud vendor and a university formalized this problem, with a title pointing to the formal foundations of “dynamically composable programs.” Its value is not a new framework. It answers a more fundamental question: under what conditions can a runtime structural change be proven safe?
2. The Core Abstraction: Kernel, Plugins, and the Dependency Graph
Architectures of this kind usually split the system into two layers. The kernel takes on very few responsibilities: maintaining a component registry, resolving dependencies, dispatching lifecycle hooks, and forwarding events. Everything else is a plugin, including message ingestion, session management, model invocation, tool execution, and persistence.
Plugins never reference each other directly. Instead, each one declares “I need a certain service,” and the kernel performs dependency injection. This has three immediate consequences:
- Dependencies form an explicit graph that can be analyzed, rather than implicit calls scattered through the code.
- A single plugin can be replaced, unloaded, and reinstalled without affecting other nodes in the graph.
- Adding a capability means adding a node to the graph, with no changes to kernel code.
A schematic plugin declaration looks like this:
// A plugin declares only its needs and lifecycle, with no awareness of host internalsexport const toolPlugin = {name: 'tool-runner',inject: ['logger', 'storage', 'model'], // dependencies resolved by the kernelapply(ctx) {ctx.on('session/message', async (msg) => {const plan = await ctx.model.plan(msg);await ctx.storage.append(msg.id, plan);});ctx.provide('tool-runner', { run: executeTool });}};
What matters here is not the shape of the API but the combination of declarative dependencies and lifecycle hooks. Together they turn runtime structure into data that can be computed over.
3. What the Formal Foundations Actually Prove
Work of this kind typically rests on three propositions.
The first is reachability and acyclicity. As long as the dependency graph still resolves to a unique initialization order after each change, and contains no circular dependencies, the system is in a legal state. This converts “can it be changed” into “does it still satisfy the graph constraints afterward,” which is decidable.
The second is atomicity of change. A structural change is modeled as a transaction: build the new component instances first, then switch references, then release the old instances. Before the switch point, the old topology keeps serving; after it, the new topology takes effect. There is no window in which an external observer sees a half-new, half-old intermediate state.
The third is task continuity. An in-flight call holds a reference to the old instance, so it completes naturally on that instance, while new requests enter the new instance. As long as cleanup of the old instance uses deferred reclamation, destroying it only after the reference count reaches zero or a grace period expires, there is no “pulling the floor out from under you” style failure.
Taken together, these three form the provable basis for “an agent modifies its own host without breaking the current task.” None of it is mysterious in engineering terms. The hard part is turning it into an invariant and maintaining that invariant over time.
4. Engineering Key Points for Hot Swapping
Moving from theory to a running system requires restraint in a few specific places.
Externalize state. Plugins should hold as little non-migratable state as possible. Sessions, memory, and intermediate results belong in external storage, using general-purpose capabilities such as object storage, message queues, or databases. Once state is externalized, replacing a plugin is close to replacing a stateless compute unit, and rollback costs stay very low.
Version contracts. Service interfaces carry version numbers. While old and new implementations coexist, the kernel routes by version, avoiding a situation where one change breaks everything.
Canary rollout and rollback. Load the change on a shadow instance and run validation cases first, then shift traffic once they pass. Keep the previous topology description on hand so a single command can revert when something goes wrong.
Change auditing. Write every structural change to a logging service and wire it into monitoring and alerting, recording the operator (human or model), the topology before and after, and the validation result. In a self-evolving system, the audit trail is the only basis for after-the-fact attribution.
Change flow (pseudocode)1. parse(newSpec) -> graph2. validate(graph): acyclic? dependencies satisfiable? contract versions compatible?3. build(graph): instantiate new components (old topology still serving)4. commit(): atomically switch the root reference5. retire(old): destroy after the reference count reaches zero6. audit + metrics
5. Real Implications for Agent Evolution
First, capability expansion shifts from “change code and ship a release” to “assemble at runtime.” Tool sets, memory strategies, and schedulers can be composed dynamically per task, and multi-agent collaboration can be expressed with the same dependency graph.
Second, self-evolution gains a safety boundary. A modification proposed by the model must pass the graph constraints and validation cases before it is allowed to commit, which is far more controllable than letting the model edit source code directly.
Third, the object of evaluation shifts. Traditional evaluation looks at the quality of model output. Under this kind of architecture, you must also evaluate whether changes are legal, whether rollback is reliable, and whether tasks stay continuous. The architecture itself becomes the thing under test.
Fourth, the cost structure changes. Multiple coexisting versions and deferred reclamation add memory and storage overhead, which needs to be controlled with grace periods, snapshots, and hot/cold tiering.
One point deserves clear thinking: formal guarantees cover only the safety of structural change, not the correctness of model decisions. The former is decidable; the latter still depends on the evaluation system and human fallback.
6. Adoption Recommendations
To borrow this paradigm in your own system, start with three things. First, split a minimal kernel and three to five plugins out of the existing monolith, and verify that dependency injection works smoothly. Next, introduce a topology description file and a validator so that “structure” becomes a versionable artifact. Finally, add auditing and canary rollout before cautiously opening up change permissions to programs or models. The combination of general-purpose capabilities such as container platforms, logging services, and monitoring and alerting offered by Baidu AI Cloud is usually enough to support this infrastructure, with no dependence on specific proprietary interfaces.
The value of the paradigm outweighs any single implementation. Language, interface form, and whether the host is a command line or a graphical interface are only shells. What really determines staying power is whether this set of constraints can be held steadily: composable at runtime, provable in change, and rollback-safe on failure.
