[codex] Harden reflection lessons with source context - #65
Draft
sayhiben wants to merge 4 commits into
Draft
Conversation
cuneytozseker
added a commit
that referenced
this pull request
Jun 15, 2026
build_reflection_prompt previously claimed to be reviewing code but only received the execution result string, so models periodically refused with "I don't have any code to review" and the refusal got saved into lessons.md as if it were a lesson. Now passes self.current_program.code and program_type alongside the result, mirroring how build_fix_prompt already includes the code. The raw (unsanitized) code is intentional — the LLM only reads it as context, never executes it, and bundling a sanitization step here would entangle this with the still-unresolved archive sanitizer work (#49). Addresses #55. PR #65 is a heavier independent fix that also adds non-lesson guards as defense in depth. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Root Cause
_do_reflect()only sent a success/error result, whilebuild_reflection_prompt()asked the model to review code execution. Some models responded that no code was available, and any non-empty response was persisted tolessons.md.The first fix added source context and a guard, but review found two remaining gaps: the guard did not catch the exact issue wording (
I don't have any code to review and pull lessons from), and the prompt/fallbacks leaned on "TinyCanvas" without explaining that this is a local drawing helper API.Validation
python3.12 -m unittest discover -s testspython3.12 -m py_compile programmer/brain.py llm/generator.py archive/learning.pygit diff --checkFixes #55