Skip to content

codegen: show and save the generated code - #74

Draft
GeigerJ2 wants to merge 3 commits into
mainfrom
feature/codegen-show-and-save
Draft

codegen: show and save the generated code#74
GeigerJ2 wants to merge 3 commits into
mainfrom
feature/codegen-show-and-save

Conversation

@GeigerJ2

@GeigerJ2 GeigerJ2 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@GeigerJ2
GeigerJ2 requested a review from Jaweria-B August 6, 2026 08:43
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f6c1a391-c47a-459d-93f0-0a1608b6075e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.
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