Skip to content

Decode run_python code and send_files from tool arguments - #269

Merged
iamwavecut merged 1 commit into
mainfrom
fix/run-python-tool-args
Oct 20, 2026
Merged

iamwavecut merged 1 commit into
mainfrom
fix/run-python-tool-args

Conversation

@iamwavecut

Copy link
Copy Markdown
Owner

Problem

After #268 was deployed, a runtime virtual dialog asked for a bar chart. Gemma called run_python with a full {"code": "..."} argument twice, and both calls failed with run_python_code_empty. The argument decoder (populate_tool_args) copies ToolStep fields one by one and had no entries for code and send_files, so both were dropped for every call form.

The model also omitted send_files, so even a working run would not have delivered the chart.

Change

  • populate_tool_args maps code and send_files; populate_json_map_args passes send_files arrays through like file_ids; normalize_and_validate_step trims send_files and drops empty entries. code is kept byte for byte.
  • run_python gets code as its positional argument.
  • The send_files description now gives an example and says that only the listed files reach the user.
  • New test every_tool_schema_arg_reaches_the_tool_step_from_json_arguments checks every argument of every tool schema against the decoder, so a new argument cannot be dropped silently again. native_run_python_calls_keep_the_script_and_files covers the production call shape.

Verification

  • cargo fmt --all --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test -p openplotva-dialog (106 passed), -p openplotva-llm (218), -p openplotva-app (1432), -p openplotva-prompts (9)

After the deploy, a SAFE runtime virtual dialog will repeat the production chart request and the follow-up edit.

Deployment risk

Only the dialog tool decoder and one tool argument description change. The tool schema text change rebuilds the cached prompt prefix once. Rollback: revert this commit, or unset SANDBOX_URL to remove the tool.

The argument decoder filled ToolStep field by field and had no entries
for code and send_files, so every native run_python call reached the
sandbox with an empty script ("run_python_code_empty" in production).
Map both fields, pass send_files arrays through like file_ids, and add
a test that every tool schema argument survives JSON decoding.

The model also omitted send_files in production, so the argument
description now says that only listed files reach the user.
@github-actions

Copy link
Copy Markdown
Messages
📖 Danger checked 1 changed file(s).

Generated by 🚫 dangerJS against 3c8c20f

@iamwavecut
iamwavecut merged commit 6a04b8c into main Oct 20, 2026
12 checks passed
@iamwavecut
iamwavecut deleted the fix/run-python-tool-args branch October 20, 2026 16:53
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