Repository navigation
Description
Problem
The docs and examples still use the deprecated code_interpreter() and local_code_interpreter() helpers instead of python_tool(). PR #1271 updated docs/examples/tools/README.md and python_tool_example.py, but three files still reference the deprecated functions:
docs/examples/tools/interpreter_example.py— usescode_interpreter/local_code_interpreterthroughout (the runnable companion to the README that fix: address default execution tier security posture #1271 changed, so the two now diverge)docs/docs/how-to/tools-and-agents.md— lines ~114–162 and ~264–274docs/examples/tools/README.md— "Tool with LLM" / "Forcing Tool Use" / "Validating" examples and the "Available Tools" list still name both deprecated functions
Both code_interpreter() and local_code_interpreter() emit DeprecationWarning and point at python_tool() (mellea/stdlib/tools/interpreter.py:1199-1244). The docs should demonstrate the supported API.
Why this is more than a rename
python_tool() is not a drop-in substitution for the deprecated callables — the migration touches four things:
| Aspect | Deprecated | python_tool |
|---|---|---|
| Import | code_interpreter, local_code_interpreter |
python_tool |
| Wrapping | MelleaTool.from_callable(local_code_interpreter) |
python_tool(tier="local_unsafe") — already a MelleaTool |
| Direct call | code_interpreter("print(1+1)") |
tool.run(code="print(1+1)") → ExecutionResult |
Tool-call key & uses_tool arg |
"local_code_interpreter" / the callable |
"python" (default name=) or your name=; the name string, not the object |
Two caveats that block a naive find-replace:
uses_tool(tool)/tool_arg_validator(tool_name=tool)cannot take theMelleaToolobject._name2str(mellea/stdlib/requirements/tool_reqs.py:16) accepts only astror a callable with__name__; aMelleaToolinstance hits thecase _→TypeError. Pass the tool's name string instead.python_tool()emits the newUserWarningfrom fix: address default execution tier security posture #1271 unlesstier=is passed explicitly. Passingtier="local_unsafe"is exactly the conscious trust decision fix: address default execution tier security posture #1271 introduced, so the migrated examples should pass it explicitly — turning the examples into a demonstration of the new contract.
Suggested shape
from mellea.stdlib.tools import python_tool
# create once, reuse the name in requirements and lookups
tool = python_tool(tier="local_unsafe", name="python")
# direct, no LLM:
result = tool.run(code="print(1 + 1)")
# force + validate:
m.instruct(
description="Use the code interpreter tool to make a plot of y=x^2.",
requirements=[uses_tool("python")], # name string, not the object
model_options={ModelOption.TOOLS: [tool]},
tool_calls=True,
)
code = response.tool_calls["python"].args["code"]Note: the README examples just changed in #1271 will need a second pass so their tool_calls[...] keys and uses_tool(...) args use "python" rather than "local_code_interpreter".
Acceptance criteria
-
docs/examples/tools/interpreter_example.pymigrated topython_tool(passes its# pytest: ollama, e2erun) -
docs/docs/how-to/tools-and-agents.mdmigrated;markdownlint-cli2clean -
docs/examples/tools/README.mdmigrated (tool-call keys +uses_toolargs use the name string; "Available Tools" list updated) - No remaining references to
code_interpreter/local_code_interpreterindocs/except where intentionally documenting the deprecation - Tier passed explicitly so examples don't emit the fix: address default execution tier security posture #1271
UserWarning
Context
Follow-up to #1271, which deliberately kept its scope to the security-posture warnings. Surfaced during review of that PR.
Activity