BUG: code_execution_tool raises KeyError: 'code' when the code argument is missing #187
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nsaspy/a0-symbolics#187
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Finding
plugins/_code_execution/tools/code_execution_tool.pyreads thecodeargument by direct subscript for the three main runtimes:Every other argument in the same function is defensive:
Any call with
runtimeset topython/nodejs/terminalbut nocodekey raisesKeyError: 'code'instead of returning a tool result.Observed traceback from a live run:
Impact
The exception is never converted into a corrective tool result.
Agent._execute_tool_requesthas noexceptaroundawait tool.execute(**tool_args)andAgent.handle_exception()re-raises (if exception: raise exception), so the message-loop task dies. A single malformed tool call (missing arg) kills the whole agent run instead of letting the model retry. A badruntimevalue is already handled gracefully viafw.code.runtime_wrong.md; a missingcodeshould behave the same way.Direction
Minimal fix, consistent with the surrounding style:
Optional hardening: return a warning fragment (e.g.
fw.code.missing_code.md, "'code' argument is required for runtime '{{runtime}}'") whencodeis absent for the three runtimes, mirroringfw.code.runtime_wrong.md. If implemented, use"code" not in self.argsrather than a falsy check — theInputtool forwardscode=keyboardwherekeyboardcan legitimately be""afterrstrip(), and a falsy guard would turn that harmless no-op into a warning.Scope note: the same unguarded subscript exists in upstream agent-zero (inherited unchanged via the plugin-extraction refactor,
git blameconfirms); the lines are byte-identical in the live runtime copy at/a0/plugins/_code_execution/tools/code_execution_tool.py. A grep acrosstools/andplugins/*/tools/shows no other tool subscripts a required arg without a guard — this is the only instance. Adjacent, out of scope:int(self.args.get("session", 0))raisesValueErroron a non-numericsession.Acceptance
code_execution_toolwith{"runtime": "python"},{"runtime": "nodejs"},{"runtime": "terminal"}and nocodekey returns a tool response instead of raisingKeyError: 'code'Inputtool path with emptykeyboardstill behaves as a no-op (no false missing-code warning)tests/test_code_execution_pager.pycovering the three runtimes withoutcodeMirrored from
lost-rob0t/a0-symbolics#63via tracker sync.