fix(#561): Redesign conversation state management to address agent persistence after interruptions#565
Merged
Conversation
…oring Orchestrator to use conversation state
… conversation lock
…dispatching in Orchestrator
…ests in ForgeExecutorService
…nd filtering inactive agents
…chestrator methods
…ersation service for clarity
…n conversation service
Move the responsibility of clearing conversation state queue from the executor to the orchestration layer for better separation of concerns. Co-authored-by: Forge <forge@antinomy.ai>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Overview
This PR refactors the conversation state management system to fix an issue where agent states incorrectly remain marked as active after Ctrl+C interruptions, leading to potential state corruption in subsequent interactions.
Purpose
When users interrupt a conversation with Ctrl+C, the
is_activeflags on agents remained set totrue, causing incorrect behavior if the conversation was resumed later. This refactoring removes the problematic flag entirely and fundamentally redesigns how agent activity is tracked and synchronized.Implementation
The implementation takes a three-pronged approach:
Architecture Change: The
Orchestratornow maintains the conversation in memory with proper synchronization usingRwLock, rather than repeatedly fetching it from storage.State Management: Removed the
is_activeflag fromAgentStateand instead determine agent activity dynamically by checking if its event queue is empty.API Improvements: Renamed methods in
ConversationServiceto be more intuitive:get→find(more explicit about possible absence)upsertmethod for clear responsibilityOrchestratorSynchronization: Added explicit conversation state synchronization to ensure persistence after state changes.
Testing
To test these changes:
This fix ensures that conversation state is properly maintained across interruptions without corruption.
Related Issues
Fixes #561: "bug: Agent states remain active after Ctrl+C interruption"
Fixes #543
Fixes #541
Changelog
Changed in
conversation.rsis_activeflag fromAgentStatedispatch_eventto track activity based on queue emptinessChanged in
lib.rsConversationServicetrait interfaceget→findand addedupsertOrchestratorChanged in
orch.rsOrchestratorto store conversation withRwLockChanged in
api.rsandexecutor.rsSuggested Reviewers