[cornerstone] Phase 4.7f — Port Code Generation & Execution to Python#7971
Merged
[cornerstone] Phase 4.7f — Port Code Generation & Execution to Python#7971
Conversation
## What Ports the `generate_and_execute_code` agent function from TypeScript to Python, completing the final function group in Phase 4.7. ## Why Completes all six agent function groups (text, image, video, speech, music, code). Code gen reuses the existing `from_pidgin_string` / `conform_body` / `stream_generate_content` pipeline from `generate_text`, so no new infrastructure was needed. ## Changes ### `opal-backend-shared` - **Modified** `functions/generate.py` — adds `_define_generate_and_execute_code` (Gemini + `codeExecution` tool, optional `googleSearch`, handles `inlineData` file outputs and `codeExecutionResult` error tracking). Updated instruction text with code gen prompt guidelines. Wired into `get_generate_function_group`. - **New** `tests/test_code_gen.py` — 16 tests covering all code paths ### `PROJECT_CORNERSTONE.md` - Marks Phase 4.7f as complete ## Testing ```bash cd packages/opal-backend-shared && source .venv/bin/activate python -m pytest tests/test_code_gen.py tests/test_generate.py -v ``` All 36 tests pass (16 new + 20 existing `generate_text`).
📊 Coverage Report
|
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.
What
Ports the
generate_and_execute_codeagent function from TypeScript to Python,completing the final function group in Phase 4.7.
Why
Completes all six agent function groups (text, image, video, speech, music,
code). Code gen reuses the existing
from_pidgin_string/conform_body/stream_generate_contentpipeline fromgenerate_text, so no newinfrastructure was needed.
Changes
opal-backend-sharedfunctions/generate.py— adds_define_generate_and_execute_code(Gemini +codeExecutiontool, optionalgoogleSearch, handlesinlineDatafile outputs andcodeExecutionResulterror tracking). Updated instruction text with code gen prompt guidelines.
Wired into
get_generate_function_group.tests/test_code_gen.py— 16 tests covering all code pathsPROJECT_CORNERSTONE.mdTesting
All 36 tests pass (16 new + 20 existing
generate_text).