✨ codegen: show and save the generated code - #74
Draft
GeigerJ2 wants to merge 3 commits into
Draft
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
After each turn the CLI now surfaces the Python the codegen agent ran: each `run_aiida_code` snippet is shown syntax-highlighted, and written to its own `.py` file under `SandboxSettings.codegen_save_dir` (a per-user data dir by default), so a user can read, keep, edit, and re-run it. Previously the code was only visible in the DEBUG tool-call trace. `show_generated_code` and `save_generated_code` are separate (one displays, one persists); both are no-ops for the analysis and execution agents, which never call `run_aiida_code`. Wired into the `chat` REPL and the one-shot `ask`.
Saving only the final snippet was wrong twice over: a weak model's last attempt is not always the correct one, and earlier attempts that ran cleanly are exactly what a user wants to keep. Pair each run_aiida_code call with its return and save every snippet that ran (deduped), skipping refusals, timeouts and tracebacks. The inline view still shows one snippet, now the last that ran cleanly rather than the last attempt. A terminal cannot fold output already scrolled past, so the full set is revealed on demand instead: Ctrl+O (or /code) prints every snippet of the last turn, each marked ran or failed. Runner gains summary_is_failure so a caller holding only the summary string, read back from message history, can classify a run without re-executing it.
Two copies of the snippet landed in every codegen answer: our inline display, and the model pasting it back because the prompt told it to. Code in the middle of an answer reads badly. Drop the inline display. Announce where each snippet was saved instead (one dim line), and keep the on-demand reveal (Ctrl+O or /code). Tell the codegen agent to answer from the result and not reproduce the snippet, since the interface saves and reveals it. Removes the now-unused show_generated_code.
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.
No description provided.