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

Commit 758e079

Browse files
fix: subscribing to events should not be blocked by agent actor state (#910)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent bdf95ae commit 758e079

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
# Change Log
44

5-
## 2025-06-24 - Runtime v0.18.0
5+
## 2025-06-24 - Runtime v0.18.1
6+
7+
- fix: subscribing to events should not be blocked by agent actor state [#910](https://github.com/hypermodeinc/modus/pull/910)
8+
9+
## 2025-06-23 - Runtime v0.18.0
610

711
NOTE: These notes are inclusive of all preview releases in the v0.18.0 series.
812

@@ -38,7 +42,7 @@ Other items:
3842
- fix: time zone retrieval and logging [#906](https://github.com/hypermodeinc/modus/pull/906)
3943
- fix: update dockerfile to include legacy time zones [#909](https://github.com/hypermodeinc/modus/pull/909)
4044

41-
## 2025-06-24 - Go SDK v0.18.0
45+
## 2025-06-23 - Go SDK v0.18.0
4246

4347
NOTE: These notes are inclusive of all preview releases in the v0.18.0 series.
4448

@@ -62,7 +66,7 @@ Other items:
6266
- feat: return user and chat errors in API response [#863](https://github.com/hypermodeinc/modus/pull/863)
6367
- feat: delete collections features [#872](https://github.com/hypermodeinc/modus/pull/872)
6468

65-
## 2025-06-24 - AssemblyScript SDK v0.18.0
69+
## 2025-06-23 - AssemblyScript SDK v0.18.0
6670

6771
NOTE: These notes are inclusive of all preview releases in the v0.18.0 series.
6872

runtime/actors/agents.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,18 @@ func GetAgentInfo(ctx context.Context, agentId string) (*AgentInfo, error) {
168168
}, nil
169169
}
170170

171-
// If the actor is not found, or if the request timed out, we can check the database for the agent state.
172-
// This is useful for agents that are terminated or suspended, or just busy processing another request.
173-
if errors.Is(err, goakt.ErrActorNotFound) || errors.Is(err, goakt.ErrRequestTimeout) {
174-
return getAgentInfoFromDatabase(ctx, agentId)
171+
// If the actor is not responding, we can check the database for the agent state.
172+
// This is useful for agents that are still starting, are terminated or suspended, or just busy processing another request.
173+
allowedErrs := []error{
174+
goakt.ErrActorNotFound,
175+
goakt.ErrRequestTimeout,
176+
goakt.ErrRemoteSendFailure,
177+
goakt.ErrDead,
178+
}
179+
for _, r := range allowedErrs {
180+
if errors.Is(err, r) {
181+
return getAgentInfoFromDatabase(ctx, agentId)
182+
}
175183
}
176184

177185
return nil, fmt.Errorf("error getting agent info: %w", err)

runtime/actors/subscriber.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ func SubscribeForAgentEvents(ctx context.Context, agentId string, update func(da
3333
span, ctx := utils.NewSentrySpanForCurrentFunc(ctx)
3434
defer span.Finish()
3535

36-
if a, err := GetAgentInfo(ctx, agentId); err != nil {
36+
// Go directly to the database for the agent status, because we don't want subscribing to events to fail
37+
// if there is any issue with the agent actor.
38+
if a, err := getAgentInfoFromDatabase(ctx, agentId); err != nil {
3739
return err
3840
} else if a.Status == AgentStatusStopping || a.Status == AgentStatusTerminated {
3941
return fmt.Errorf("agent %s is %s, cannot subscribe to events", agentId, a.Status)

0 commit comments

Comments
 (0)