Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .trunk/configs/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"minilm",
"modfile",
"modusdb",
"modusgraph",
"Msgf",
"mydb",
"mydgraph",
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## UNRELEASED

- feat: initial implementation of Modus Agents [#840](https://github.com/hypermodeinc/modus/pull/840)
- feat: persistence and lifecycle improvements for Modus Agents [#843](https://github.com/hypermodeinc/modus/pull/843)

## 2025-05-06 - CLI 0.17.4

Expand Down
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.24.2
go 1.24.3

use (
./lib/manifest
Expand Down
26 changes: 23 additions & 3 deletions runtime/actors/actorsystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ import (
"context"
"time"

"github.com/hypermodeinc/modus/runtime/db"
"github.com/hypermodeinc/modus/runtime/logger"
"github.com/hypermodeinc/modus/runtime/pluginmanager"
"github.com/hypermodeinc/modus/runtime/plugins"
"github.com/hypermodeinc/modus/runtime/wasmhost"

goakt "github.com/tochemey/goakt/v3/actor"
)
Expand Down Expand Up @@ -45,18 +47,36 @@ func Initialize(ctx context.Context) {

logger.Info(ctx).Msg("Actor system started.")

pluginmanager.RegisterPluginLoadedCallback(reloadAgentActors)
pluginmanager.RegisterPluginLoadedCallback(loadAgentActors)
}

func reloadAgentActors(ctx context.Context, plugin *plugins.Plugin) error {
for _, pid := range _actorSystem.Actors() {
func loadAgentActors(ctx context.Context, plugin *plugins.Plugin) error {
// reload modules for actors that are already running
actors := _actorSystem.Actors()
runningAgents := make(map[string]bool, len(actors))
for _, pid := range actors {
if actor, ok := pid.Actor().(*WasmAgentActor); ok {
runningAgents[actor.agentId] = true
if err := actor.reloadModule(ctx, plugin); err != nil {
return err
}
}
}

// spawn actors for agents with state in the database, that are not already running
// TODO: when we scale out with GoAkt cluster mode, we'll need to decide which node is responsible for spawning the actor
agents, err := db.QueryActiveAgents(ctx)
if err != nil {
logger.Err(ctx, err).Msg("Failed to query agents from database.")
return err
}
host := wasmhost.GetWasmHost(ctx)
for _, agent := range agents {
if !runningAgents[agent.Id] {
spawnActorForAgent(host, plugin, agent.Id, agent.Name, true, &agent.Data)
}
}

return nil
}

Expand Down
Loading
Loading