feat(kernel): persist agent runtime state across restarts
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
- Schema: migrations now execute ALTER TABLE ADD COLUMN for state/message_count - MemoryStore: add update_agent_runtime() and list_agents_with_runtime() - Registry: add register_with_runtime() to accept persisted state/message_count - Kernel boot: restore agents with their persisted state (not always Running) - Kernel shutdown: persist all agent states/message_counts before terminating Agents that were suspended stay suspended after restart. Message counts survive restarts instead of resetting to 0.
This commit is contained in:
@@ -30,6 +30,22 @@ impl AgentRegistry {
|
||||
self.created_at.insert(id, Utc::now());
|
||||
}
|
||||
|
||||
/// Register an agent with persisted runtime state
|
||||
pub fn register_with_runtime(
|
||||
&self,
|
||||
config: AgentConfig,
|
||||
state: AgentState,
|
||||
message_count: u64,
|
||||
) {
|
||||
let id = config.id;
|
||||
self.agents.insert(id, config);
|
||||
self.states.insert(id, state);
|
||||
self.created_at.insert(id, Utc::now());
|
||||
if message_count > 0 {
|
||||
self.message_counts.insert(id, message_count);
|
||||
}
|
||||
}
|
||||
|
||||
/// Unregister an agent
|
||||
pub fn unregister(&self, id: &AgentId) {
|
||||
self.agents.remove(id);
|
||||
|
||||
Reference in New Issue
Block a user