Skip to content

Conversation

@daveey
Copy link
Contributor

@daveey daveey commented Jan 4, 2026

TL;DR

Added commons statistics tracking and rewards based on aligned objects.

What changed?

  • Added statistics tracking for commons objects, including:
    • Count of aligned objects by type
    • Duration (ticks) that objects remain aligned
    • Inventory statistics
  • Implemented a new reward type commons_stats that allows agents to be rewarded based on commons statistics
  • Updated the episode stats to include commons statistics
  • Modified the alignment system to track object types when adding/removing members

How to test?

  • Run the test cases in test_align.py which verify:
    • Commons stats tracking for aligned objects
    • Rewards based on commons stats
    • Stats updates when alignment changes
    • Multiple commons tracking their stats independently
  • Try the updated cogsguard recipe which now rewards agents for keeping chargers aligned

Why make this change?

This change enables more sophisticated reward mechanisms based on commons alignment patterns. It allows agents to be rewarded not just for the resources in commons, but for maintaining alignment with specific object types over time. This is particularly useful for scenarios where we want to incentivize agents to protect or maintain certain objects within their commons.

Copy link
Contributor Author

daveey commented Jan 4, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@datadog-official

This comment has been minimized.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2dfe6d3bbd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 29 to +32
explicit Commons(const CommonsConfig& cfg,
const std::vector<std::string>* resource_names = nullptr,
const std::unordered_map<std::string, ObservationType>* feature_ids = nullptr)
: HasInventory(cfg.inventory_config, resource_names, feature_ids), name(cfg.name) {
: HasInventory(cfg.inventory_config, resource_names, feature_ids), name(cfg.name), stats(resource_names) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Require or guard null resource_names in Commons stats init

The new StatsTracker stats member is constructed with resource_names, but the constructor still defaults that parameter to nullptr. StatsTracker throws when resource_names is null, so any existing caller that relied on the default (e.g., the C++ Commons tests that do Commons commons(config) in packages/mettagrid/tests/test_commons.cpp) will now crash at construction. Either make the parameter required or provide a safe fallback when resource_names is null to avoid breaking existing usages.

Useful? React with 👍 / 👎.

@openhands-ai
Copy link

openhands-ai bot commented Jan 4, 2026

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • Test and Benchmark

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #4598 at branch `daveey-land`

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

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