This repository was archived by the owner on Sep 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
feat: persistence and lifecycle improvements for Modus Agents #843
Merged
mattjohnsonpint
merged 3 commits into
main
from
mjp/hyp-3347-persist-agent-state-between-actor-runtime-restarts
May 16, 2025
Merged
feat: persistence and lifecycle improvements for Modus Agents #843
mattjohnsonpint
merged 3 commits into
main
from
mjp/hyp-3347-persist-agent-state-between-actor-runtime-restarts
May 16, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Running Code Quality on PRs by uploading data to Trunk will soon be removed. You can still run checks on your PRs using trunk-action - see the migration guide for more information. |
f2c8680 to
966d532
Compare
29ce58b to
e5e2384
Compare
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds durable persistence and refined lifecycle hooks for Modus Agents, enabling full shutdown and restart without losing state.
- Introduces new
onSuspend,onRestore, andonTerminatehooks and updates AssemblyScript agent APIs - Persists agent state to ModusGraph in dev and Postgres in production, with migrations
- Updates Go actor system to reload and respawn agents based on stored state
Reviewed Changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/assemblyscript/src/assembly/enums.ts | Updated agent status enum values |
| sdk/assemblyscript/src/assembly/agent.ts | Added terminateAgent, updated shutdownAgent, hooks, constructor default |
| sdk/assemblyscript/src/assembly/agents.ts | Exported terminate from agent module |
| sdk/assemblyscript/examples/agents/assembly/index.ts | Example terminateAgent function added |
| sdk/assemblyscript/examples/agents/assembly/counterAgent.ts | Implemented new lifecycle hooks in example agent |
| runtime/hostfunctions/agents.go | Registered terminateAgent host function |
| runtime/db/modusdb.go | Switched to modusgraph import and config logic |
| runtime/db/db.go | Added useModusDB toggle function |
| runtime/db/agentstate.go | New persistence logic for agent state |
| runtime/db/migrations/000007_add_agent_state.up.sql | Migration to create agents table |
| runtime/db/migrations/000007_add_agent_state.down.sql | Migration to drop agents table |
| runtime/actors/agents.go | Added TerminateAgent, status tracking, respawn logic |
| runtime/actors/actorsystem.go | Reload and respawn agents at startup |
| go.mod & go.work | Dependency bumped to modusgraph and other modules |
| CHANGELOG.md | Added entry for persistence and lifecycle improvements |
| .trunk/configs/cspell.json | Added "modusgraph" to dictionary |
kevinmingtarja
approved these changes
May 16, 2025
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR layers on to #840 to add persistence of Modus Agents. It also improves the agent lifecycle events and APIs, so they match the agent's state changes.
Agent state is persisted to ModusGraph (previously ModusDB) in local development. In production, it's persisted to the backend's PostgresDB instance that has already been configured.
With these changes, you can completely shut down and restart the runtime without losing any agent state.