Skip to content

Fix source access in generalized GenPlan prompts - #172

Draft
joshnroy wants to merge 1 commit into
codex/genplan-loggingfrom
codex/genplan-source-access
Draft

Fix source access in generalized GenPlan prompts#172
joshnroy wants to merge 1 commit into
codex/genplan-loggingfrom
codex/genplan-source-access

Conversation

@joshnroy

@joshnroy joshnroy commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #173 (logging). Review/merge #173 first; this PR targets codex/genplan-logging and contains only the source-bundle fix.

Summary

  • Include the dynamically loaded environment class when collecting source for generalized GenPlan prompts, then follow its local imports using the existing source collector.
  • Preserve wrapper source and existing fixed-count source handling. Inspect the loaded class without creating or resetting extra environments.
  • Add regression coverage for DynObstruction2D and DynPushPullHook2D that checks the full backend and shared physics/goal source, not just filenames.

Why

VariableObjectCountEnv loads its backend dynamically. Following only the wrapper's imports omitted the actual environment implementation, so the baseline received wrapper code while feedback told it to inspect goal/termination conditions in missing source.

This supplies source as prompt text; it does not enable file-reading, shell, or MCP tools. The shared source builder also benefits best-of-K. Budget and refinement behavior are unchanged.

Why _gather_env_source also changes

_source_targets decides what to include. It now returns both existing environment instances and the dynamically loaded environment class (_env_cls). Previously, _gather_env_source always called type(obj): correct for an instance, but for a class this returns its metaclass instead of the environment class whose source we need.

The collector therefore uses cls = obj if inspect.isclass(obj) else type(obj) and derives both the source file and package root from cls. This lets it read the underlying implementation without constructing or resetting another environment.

Verification

  • Both new regression cases fail against the pre-fix implementation and pass with this change.
  • 88 tests passed across GenPlan, best-of-K, validation, LLM clients, and prompts; 2 live integration tests excluded.
  • Black, isort, and focused mypy checks passed.
  • Pylint passed for both changed files after suppressing existing obsolete configuration-option diagnostics.
  • No live Claude calls or paid experiments run.

Risks / follow-up

The source prompt becomes larger. The existing dependency collector remains best-effort; this fixes discovery of the dynamically loaded backend, not all possible import forms. Existing runs are unaffected; new runs receive the expanded source.

Logging is supplied by the base PR #173. Campaigns, results, and uv.lock are not included.

@joshnroy joshnroy self-assigned this Aug 28, 2026
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.

1 participant