Skip to content

fix: initialize logging channel in game master components - #295

Open
rootkiller6788 wants to merge 2 commits into
google-deepmind:mainfrom
rootkiller6788:fix/game-master-logging-channel-init
Open

fix: initialize logging channel in game master components#295
rootkiller6788 wants to merge 2 commits into
google-deepmind:mainfrom
rootkiller6788:fix/game-master-logging-channel-init

Conversation

@rootkiller6788

Copy link
Copy Markdown
Contributor

Problem

Five game-master components call self._logging_channel(...) in pre_act
without ever calling super().__init__():

  • WorldState, Locations, and GenerativeClock in
    concordia/components/game_master/world_state.py
  • Inventory and Score in
    concordia/components/game_master/inventory.py

_logging_channel is installed only by ComponentWithLogging.__init__(), so it
is never defined on these components. When they are used with a plain
EntityAgent (which never calls set_logging_channel), pre_act raises:

AttributeError: '...' object has no attribute '_logging_channel'

Fix

Add the missing super().__init__() to each of the five __init__ methods so
that ComponentWithLogging installs the default NoOpLoggingChannel. This
matches the existing pattern in terminate.py, make_observation.py, and
constant.py.

Tests

Add unit tests that run without an LLM (using MockModel and 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-location
      filtering, state round-trip.
  • inventory_test.py (12 tests)
    • ItemTypeConfig.check_valid and _many_or_much_fn.
    • Inventory: state round-trip, pre_act (FREE and RESOLVE paths),
      get_player_inventory copy semantics.
    • Score: scoring, pre_act, state round-trip.

pytest concordia/components/game_master/ -n 0
→ 197 passed.

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().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants