fix: initialize logging channel in game master components - #295
Open
rootkiller6788 wants to merge 2 commits into
Open
fix: initialize logging channel in game master components#295rootkiller6788 wants to merge 2 commits into
rootkiller6788 wants to merge 2 commits into
Conversation
WorldState, Locations, and GenerativeClock (world_state.py) as well as Inventory and Score (inventory.py) call self._logging_channel() in pre_act but never call super().__init__(), leaving _logging_channel undefined. Using these components with a plain EntityAgent (which never calls set_logging_channel) crashes with AttributeError. Add the missing super().__init__() so ComponentWithLogging installs the default NoOpLoggingChannel, matching terminate.py / make_observation.py / constant.py. Also add unit tests for world_state.py and inventory.py covering state round-trips, pre_act, and the Locations._normalize_location helper.
Access the serialized action spec through get_state() instead of the protected _latest_action_spec attribute, which pyrefly infers as Optional and flags on .to_dict().
jzleibo
approved these changes
Aug 30, 2026
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.
Problem
Five game-master components call
self._logging_channel(...)inpre_actwithout ever calling
super().__init__():WorldState,Locations, andGenerativeClockinconcordia/components/game_master/world_state.pyInventoryandScoreinconcordia/components/game_master/inventory.py_logging_channelis installed only byComponentWithLogging.__init__(), so itis never defined on these components. When they are used with a plain
EntityAgent(which never callsset_logging_channel),pre_actraises:AttributeError: '...' object has no attribute '_logging_channel'
Fix
Add the missing
super().__init__()to each of the five__init__methods sothat
ComponentWithLogginginstalls the defaultNoOpLoggingChannel. Thismatches the existing pattern in
terminate.py,make_observation.py, andconstant.py.Tests
Add unit tests that run without an LLM (using
MockModeland mocks):world_state_test.py(17 tests)WorldState:pre_act, action-spec and state round-trips, formatted output.Locations._normalize_location: exact / case-insensitive / substring /unknown / empty / trailing-period handling.
Locations: initial-location defaults and overrides, empty-locationfiltering, state round-trip.
inventory_test.py(12 tests)ItemTypeConfig.check_validand_many_or_much_fn.Inventory: state round-trip,pre_act(FREE and RESOLVE paths),get_player_inventorycopy semantics.Score: scoring,pre_act, state round-trip.pytest concordia/components/game_master/ -n 0
→ 197 passed.