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

Conversation

@mattjohnsonpint
Copy link
Contributor

@mattjohnsonpint mattjohnsonpint commented Jun 10, 2025

  • Fixes several agent lifecycle issues, such as stopping an agent while its suspended.
  • Agent activation within wasm module is now split from initialization.
  • Updated agent functions for shutdown and event status.
  • Added DB functions for updating status without resetting state data.
  • Lots of refactoring and misc fixes.

Note, I tested with passivation enabled for suspend/restore state changes. However, I disabled it at the end because there's still an open issue with long-running tasks.

@mattjohnsonpint mattjohnsonpint requested review from a team and Copilot June 10, 2025 05:17
@linear
Copy link

linear bot commented Jun 10, 2025

This comment was marked as outdated.

@mattjohnsonpint mattjohnsonpint marked this pull request as draft June 10, 2025 14:58
@mattjohnsonpint

This comment was marked as outdated.

@mattjohnsonpint mattjohnsonpint force-pushed the mjp/hyp-3472-error-stopping-modus-agent-while-its-suspended branch from d2c4cc7 to 0286b1a Compare June 11, 2025 07:04
@mattjohnsonpint mattjohnsonpint changed the title fix: actor shutdown after suspend fix: address agent lifecycle issues Jun 11, 2025
@mattjohnsonpint mattjohnsonpint requested a review from Copilot June 11, 2025 07:07
@mattjohnsonpint mattjohnsonpint marked this pull request as ready for review June 11, 2025 07:07

This comment was marked as outdated.

@mattjohnsonpint mattjohnsonpint requested a review from Copilot June 11, 2025 07:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR overhauls the agent lifecycle by centralizing lifecycle actions into a single event handler, refactors the Wasm agent actor to use discrete start/resume/suspend/stop methods with database-backed status updates, and adds a new UpdateAgentStatus helper in the DB layer.

  • Introduce handleEvent/handleMessage exports and remove separate activate/shutdown in Go and AssemblyScript SDKs
  • Refactor wasmAgentActor to split lifecycle into startAgent, resumeAgent, suspendAgent, stopAgent, and push status updates to the database
  • Add UpdateAgentStatus in agentstate.go and tweak the wasm host config (WithSysNanosleep, disable passivation)

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
sdk/go/pkg/agents/agents.go Replaced shutdownAgent, added handleEvent, improved Stop error handling
sdk/assemblyscript/src/assembly/exports.ts Updated exports to use _modus_agent_handle_event
sdk/assemblyscript/src/assembly/agent.ts Removed shutdownAgent, added handleEvent and lifecycle comments
runtime/wasmhost/wasmhost.go Broke chain calls for clarity, added WithSysNanosleep
runtime/db/agentstate.go Added UpdateAgentStatus, refactored DB update functions
runtime/actors/wasmagent.go Refactored actor lifecycle into discrete methods and status updates
runtime/actors/agents.go Updated actor spawning, StopAgent/getAgentInfo to use ensureAgentReady
runtime/actors/actorsystem.go Disabled passivation to avoid premature actor shutdown
CHANGELOG.md Added entry for agent lifecycle fixes
.trunk/configs/cspell.json Added “Nanosleep” to spelling dictionary
Comments suppressed due to low confidence (2)

runtime/db/agentstate.go:68

  • The nil‐engine guard was removed, so if GlobalModusDbEngine is nil this Upsert will panic or error. Consider re‐adding a check to skip or warn when the engine is unavailable.
gid, _, _, err := modusgraph.Upsert(ctx, GlobalModusDbEngine, state)

.trunk/configs/cspell.json:129

  • [nitpick] The entry 'Nanosleep' may not match the lowercase nanosleep naming in code; consider aligning casing with the actual API name.
"Nanosleep",

@mattjohnsonpint mattjohnsonpint merged commit d5c7629 into main Jun 11, 2025
83 checks passed
@mattjohnsonpint mattjohnsonpint deleted the mjp/hyp-3472-error-stopping-modus-agent-while-its-suspended branch June 11, 2025 07:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants