Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Commit ecad7be

Browse files
fix: trigger events correctly during agent reload (#846)
1 parent 60055e3 commit ecad7be

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
# Change Log
44

5-
## UNRELEASED
5+
## 2025-05-16 Runtime 0.18.0-alpha.2
66

77
- fix: reflection error in runtime when starting agent [#845](https://github.com/hypermodeinc/modus/pull/845)
8+
- fix: trigger events correctly during agent reload [#846](https://github.com/hypermodeinc/modus/pull/846)
89

910
## 2025-05-16 - Runtime and all SDKs 0.18.0-alpha.1
1011

runtime/actors/agents.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,13 +469,20 @@ func (a *wasmAgentActor) reloadModule(ctx context.Context, plugin *plugins.Plugi
469469

470470
logger.Info(ctx).Msg("Reloading module for agent.")
471471

472+
a.status = agentStatusSuspending
473+
if err := a.shutdownAgent(ctx); err != nil {
474+
logger.Err(ctx, err).Msg("Error shutting down agent.")
475+
return err
476+
}
477+
472478
// get the current state and close the module instance
473479
state, err := a.getAgentState(ctx)
474480
if err != nil {
475481
logger.Err(ctx, err).Msg("Error getting agent state.")
476482
return err
477483
}
478484
a.module.Close(ctx)
485+
a.status = agentStatusSuspended
479486

480487
// create a new module instance and assign it to the actor
481488
a.plugin = plugin
@@ -487,6 +494,7 @@ func (a *wasmAgentActor) reloadModule(ctx context.Context, plugin *plugins.Plugi
487494
a.module = mod
488495

489496
// activate the agent in the new module instance
497+
a.status = agentStatusRestoring
490498
if err := a.activateAgent(ctx); err != nil {
491499
logger.Err(ctx, err).Msg("Error reloading agent.")
492500
return err
@@ -498,6 +506,7 @@ func (a *wasmAgentActor) reloadModule(ctx context.Context, plugin *plugins.Plugi
498506
return err
499507
}
500508

509+
a.status = agentStatusRunning
501510
logger.Info(ctx).Msg("Agent reloaded module successfully.")
502511

503512
return nil

0 commit comments

Comments
 (0)