feat: decision recording and state machine visualization (#513) - #553
Open
cybr-wisp wants to merge 1 commit into
Open
feat: decision recording and state machine visualization (#513)#553cybr-wisp wants to merge 1 commit into
cybr-wisp wants to merge 1 commit into
Conversation
cybr-wisp
force-pushed
the
feature/state-machine-viz
branch
from
August 6, 2026 00:00
4f8acb5 to
43534c2
Compare
Contributor
Author
|
Fixed the one failing test: test_chat_based_policy_with_agent expected 4 internal events but the new decision recording adds 2 DecisionEvents (one per action selection step), so updated the assertion to 6. CI should be green now. |
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.
Description
Right now there's no way to see what decisions an agent considered at each step -> you only see what it did, not what it could have done. This PR adds that visibility.
The core idea: after the policy picks an action, we now record a
DecisionEventthat captures the chosen action, the alternatives that were available but not taken, and the current state machine state. This goes into both the agent's belief and SharedMemory so other agents (like a future critic from #512) can subscribe to it.On top of that, there's a
StateMachineViewerthat reads these decision events and generates a standalone HTML page showing the state machine graph with taken transitions (solid green), skipped alternatives (dashed gray), and a step-by-step decision history table.What changed:
DecisionEventinevents.pywithchosen,alternatives, andstatefieldsBaseAgent.async_runnow emits a decision event after each action selectionsherpa_ai/visualization/package with theStateMachineViewerUsage:
All 11 new tests pass, existing state machine and shared memory tests unaffected.
Type of change
Related issues
Closes #513
Checklists
Development
make format && make lint)make test)Code review