Skip to content

Comments

[cornerstone] Phase 4.7f — Port Code Generation & Execution to Python#7971

Merged
dglazkov merged 1 commit intomainfrom
cornerstone-generate-execute-code
Feb 23, 2026
Merged

[cornerstone] Phase 4.7f — Port Code Generation & Execution to Python#7971
dglazkov merged 1 commit intomainfrom
cornerstone-generate-execute-code

Conversation

@dglazkov
Copy link
Collaborator

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

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

## 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`).
@dglazkov dglazkov merged commit f808624 into main Feb 23, 2026
3 checks passed
@dglazkov dglazkov deleted the cornerstone-generate-execute-code branch February 23, 2026 04:54
@github-actions
Copy link

📊 Coverage Report

Metric PR Main Delta
Lines 98.15% 98.15% ⚪ +0.00%
Functions 98.10% 98.10% ⚪ +0.00%
Branches 94.29% 94.29% ⚪ +0.00%

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