Repository navigation
Stop EntityAgent reusing stale pre-act values after a failed step - #383
Closed
codewithfourtix wants to merge 2 commits into
Closed
codewithfourtix wants to merge 2 commits into
codewithfourtix wants to merge 2 commits into
Conversation
When act() or observe() raises, EntityAgent returns to READY without going through UPDATE, so components never get their update() call. Components that cache per-step values keep them: ActionSpecIgnored clears its pre-act value only in update(), so after a failed act() every such component silently serves the value from the failed step on the next successful act(), e.g. a memory summary or plan from an earlier point in the simulation. On failure, run the UPDATE phase before returning to READY, so components can drop per-step state. Errors raised by update() during this recovery are logged, not raised, so the original exception still propagates unchanged (the reason set_phase() is used here, see 326d918). Add the first tests for EntityAgent's failed-step handling: no stale value on the next act(), the original exception is re-raised for act() and observe(), update() runs in the UPDATE phase, an error in update() does not hide the original error, and the agent can act again afterwards.
The agent does not wait for components' in-flight calls when a step fails, so a pre_act call can still be running during the cleanup added in the previous commit. get_pre_act_value() checked the phase before taking the lock, so a call that passed the check and then waited for the lock while update() cleared the cache would compute and cache a value from the failed step once it got the lock, leaving a stale value in a READY agent. Check the phase while holding the lock, so such a call raises instead. Add a regression test that holds the cache lock while a reader is waiting for it and ends the step before releasing it.
Collaborator
|
Closing this for the reason described on the corresponding issue: #382 |
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.
Fixes #382.
A failed
act()/observe()returns toREADYwithout runningUPDATE, soActionSpecIgnoredcomponents keep their cached pre-act value and a retriedact()reuses it.update()before returning toREADY. Errors from it are logged so the original exception still propagates (keeps the intent of 326d918).ActionSpecIgnored's cache lock, so an in-flightpre_actcan't re-cache a stale value after cleanup.entity_agent_test.py. The stale-value, update-phase and lock tests fail onmain.