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 May 15, 2025

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.

@linear
Copy link

linear bot commented May 15, 2025

@trunk-io
Copy link

trunk-io bot commented May 15, 2025

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.

@mattjohnsonpint mattjohnsonpint force-pushed the mjp/hyp-3347-persist-agent-state-between-actor-runtime-restarts branch from f2c8680 to 966d532 Compare May 15, 2025 20:37
@mattjohnsonpint mattjohnsonpint force-pushed the mjp/hyp-3347-persist-agent-state-between-actor-runtime-restarts branch from 29ce58b to e5e2384 Compare May 15, 2025 23:42
@mattjohnsonpint mattjohnsonpint marked this pull request as ready for review May 15, 2025 23:45
@mattjohnsonpint mattjohnsonpint requested review from a team, Copilot and kevinmingtarja May 15, 2025 23:45
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

Adds durable persistence and refined lifecycle hooks for Modus Agents, enabling full shutdown and restart without losing state.

  • Introduces new onSuspend, onRestore, and onTerminate hooks 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

@mattjohnsonpint mattjohnsonpint merged commit aa44589 into main May 16, 2025
86 checks passed
@mattjohnsonpint mattjohnsonpint deleted the mjp/hyp-3347-persist-agent-state-between-actor-runtime-restarts branch May 16, 2025 20:43
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