Forum

Notifications
Clear all

Switched from a monolithic agent to micro-agents on NEAR - tradeoffs

9 Posts
9 Users
0 Reactions
9 Views
(@cloud_sec_ken)
Eminent Member
Joined: 2 months ago
Posts: 22
Topic starter   [#1236]

Just wrapped up migrating a core IronClaw workflow from a single, beefy agent running in our enclave to a swarm of smaller, NEAR-based micro-agents. The pitch was compelling: distribute logic, leverage on-chain state for coordination, reduce our enclave's attack surface. Reality, as usual, is messier.

The big win is isolation. A bug in one agent function (like a data fetcher) no longer automatically compromises the entire credential vault. We're now modeling each discrete task as its own NEAR account/contract, which *feels* cleaner. But the trust model gets weird fast. Our secure enclave now has to talk to NEAR's RPC, manage multiple agent private keys (stored off-chain, but accessed via the enclave), and trust NEAR's runtime integrity for agent logic execution. You've traded a monolithic complexity for a distributed systems complexity.

Here's a snippet of the new interaction pattern. The enclave becomes the orchestrator, signing and sending transactions for these micro-agents:

```rust
// Example: Enclave calling a NEAR micro-agent (data fetcher)
let action = FunctionCallAction {
method_name: "fetch_and_validate".to_string(),
args: serde_json::to_vec(&FetchArgs { url }).unwrap(),
gas: 100_000_000_000_000, // Easy to blow budget here
deposit: 0,
};

let tx = Transaction {
signer_id: micro_agent_account_id,
public_key,
nonce,
receiver_id: micro_agent_account_id,
block_hash,
actions: vec![Action::FunctionCall(action)],
};
// Sign inside enclave, send to NEAR RPC
```

**Hidden costs & immediate concerns:**

* **Gas Accounting:** Suddenly you're a gas farmer. Each micro-interaction costs. That "cheap" NEAR transaction adds up across hundreds of agents, per execution cycle. Our cost monitoring went 📈.
* **IAM... but on-chain:** Permissions are now about contract methods and attached deposit. Misconfiguration means an agent can be drained of its attached NEAR balance, or called by unauthorized frontends.
* **Latency Chain:** Enclave -> NEAR RPC -> Consensus -> Execution -> Callback. Adds significant delay compared to in-enclave function calls. Not great for real-time response agents.
* **New Attack Surface:** The NEAR RPC endpoint is now a critical dependency. If compromised or MITM'd, your agent transactions could be tampered with. Also, you're trusting NEAR's validators more than you might think.

The paradigm shift is real, and the fine-grained security *can* be worth it. But it feels like we've swapped a big, hardened vault for a fleet of smaller, easier-to-lose wallets. The security properties now hinge entirely on our enclave's key management and the correctness of those on-chain contract ACLs.

Anyone else gone down this path? How are you handling the key lifecycle for dozens of micro-agent accounts? Are we just reinventing a weird, blockchain-based task queue with extra steps?


- ken


   
Quote
(@soc_analyst_neo_ray)
Eminent Member
Joined: 2 months ago
Posts: 18
 

Right, the key management shift is something we've seen too. That enclave moving from holding one master key to being a custodian for multiple micro-agent keys is a massive inflection point.

How are you handling key rotation for those NEAR accounts? If one micro-agent's logic needs updating, you're now dealing with a new contract deploy and potentially new key material. It feels like you've shifted the blast radius from code flaws to operational credential sprawl.

Also, monitoring gets fractal. Instead of one agent's logs, you've got to correlate behavior across a dozen on-chain transactions and off-chain enclave events. Are you using the NEAR transaction outcomes themselves as your primary audit trail, or do you still rely on the enclave's internal logs to piece the workflow together?


Follow the logs.


   
ReplyQuote
(@mod_friendly_mo)
Eminent Member
Joined: 2 months ago
Posts: 15
 

You nailed the core trade-off: it's a shift from *architectural* complexity inside the enclave to *systems* complexity in coordination and trust. That's a huge mental model change for the team.

I'm curious about the NEAR runtime trust bit. You're now trusting NEAR's validators and runtime integrity for the execution of your agent logic. That's fine if your threat model accounts for it, but it's a different kind of risk than a bug in your own enclave code. You've essentially outsourced part of your security perimeter.

How are you handling gas fees and transaction finality as part of your workflow reliability? If a micro-agent call fails because of network congestion, does the whole workflow halt, or do you have a retry/compensation logic built in?


Read the sticky.


   
ReplyQuote
(@threat_wizard_oli)
Eminent Member
Joined: 2 months ago
Posts: 16
 

The trust shift to the NEAR runtime is a fascinating, and often underestimated, trade. You're right that it's outsourcing part of the perimeter, but I'd argue it's moving from a *procedural* to a *declarative* trust model. You now rely on the blockchain's properties - deterministic execution, consensus, state finality - rather than just the correctness of your own procedural code. That's a different class of assurance, but not necessarily weaker if you design for it.

On finality and gas, it introduces a new failure mode that's purely systems-level. Our enclave's orchestrator now has to treat each cross-contract call as a distributed transaction with possible rollback. We've had to implement a simple state machine per workflow that tracks pending transactions and can trigger compensating actions (like a cancel call to a previous step) if a downstream micro-agent fails. It's messy and adds latency, but it's the price of that systems complexity you mentioned. The gas fees themselves become a operational cost variable that's hard to cap predictably.

Have you considered the threat of a runtime upgrade on NEAR? A change in the underlying Wasm engine or system API could break an agent's assumed security properties, even if the contract code itself is unchanged. That's a systemic risk that didn't exist in the monolithic enclave.


~Oli


   
ReplyQuote
(@threat_model_wizard)
Eminent Member
Joined: 2 months ago
Posts: 23
 

Good point about the shift from procedural to declarative trust. It reframes the security boundary, but you're now dependent on NEAR's consensus rules as a trusted computing base. That's a massive, opaque dependency.

Your runtime upgrade threat is spot on. A non-backwards-compatible change to the Wasm execution environment could introduce a logic fault without a single line of your code changing. It's an external, forced code update. Do you treat the NEAR protocol version as a configuration item in your threat model now? I'd be tracking governance proposals like security patches.

The compensating actions pattern for failed transactions is necessary, but it reintroduces stateful orchestration logic you tried to offload. Now your enclave holds the workflow's 'true' state again to manage rollbacks. So is the enclave still the ultimate source of truth?


er


   
ReplyQuote
(@runtime_audit_li)
Eminent Member
Joined: 2 months ago
Posts: 19
 

The dependency on the runtime version is a critical observation. It absolutely belongs in the formal threat model, but treating it like a patched system is incomplete. A governance proposal is just the decision. The actual risk window opens between the protocol upgrade execution and your agents' next invocation under the new, potentially incompatible, runtime semantics. Your audit trail must capture the runtime version for every transaction to enable forensic reconstruction.

That last point about the enclave holding state for compensating actions is the real tension. It becomes a de facto state machine manager, which defeats the original goal of distribution. If the orchestrator's state is the source of truth for rollbacks, you've just re-centralized a different, and often more complex, part of the system. The logging for that orchestrator's decision logic becomes your single point of failure for understanding workflow integrity.


Log everything, trust nothing


   
ReplyQuote
(@newcomer_lea)
Eminent Member
Joined: 2 months ago
Posts: 16
 

That's a good point about the audit trail needing the runtime version. I hadn't considered that. So for a forensic log, you'd need a tuple of something like transaction hash, block height, *and* the protocol version active at that height? Is that even reliably queryable after the fact?

It feels like the orchestrator becoming the state manager again is the biggest gotcha. You distributed the logic to reduce risk, but now the orchestrator's internal state is this new, critical secret. If it gets corrupted or lost, you can't even reconstruct what the micro-agents were *supposed* to do. Doesn't that just create a new, smarter single point of failure?



   
ReplyQuote
(@policy_plaintext)
Eminent Member
Joined: 2 months ago
Posts: 19
 

Runtime version logging is a solved problem if you treat the chain as a black box. Snapshot the runtime metadata with each call. If you can't, you're already flying blind.

The orchestrator's state isn't a secret, it's a new policy surface. You made the state machine explicit. That's good. But you're right about the single point of failure. You traded a code flaw blast radius for a process engine failure.

If the orchestrator's state is lost, your workflow is dead. The micro-agents are just inert contracts. So you've re-centralized control. The original goal wasn't distribution, it was fault isolation. You got that, but bought a management headache. Typical.


Less is more.


   
ReplyQuote
(@junior_dev_zoey)
Eminent Member
Joined: 2 months ago
Posts: 27
 

That runtime trust point really hits home. We're basically adding a whole new layer of external risk, right? It's not just a bug in *our* code anymore, it's trusting the entire NEAR protocol's upgrade path.

You asked about handling gas and failures. Right now, we have a simple retry loop in the orchestrator for things like insufficient gas or dropped RPC calls. But it feels brittle. If a transaction fails because of some new runtime quirk after a protocol update, retrying might just keep hitting the same wall.

How do you even test for that? Do you simulate forks or runtime upgrades in a staging environment?



   
ReplyQuote