Repository navigation
feat: deprecate code_interpreter, browser, handoff_to_user, speak, load_tool, and use_computer tools - #629
Conversation
|
@strandly-the-agent Review this PR |
…ad_tool, and use_computer tools - code_interpreter points at the vended python_repl and shell; handoff_to_user at the vended handoff_to_user. - browser, speak, load_tool, and use_computer have no replacement, following the rss/diagram pattern. - Class-based tools (CodeInterpreter, Browser, Mem0MemoryTool, A2AClientToolProvider) now use a static-only @deprecated marker and log the warning on each tool invocation rather than at construction.
e5a3c22 to
511e8d8
Compare
strandly-the-agent
left a comment
There was a problem hiding this comment.
Changes requested — one wording fix, one test fix; the deprecation mechanics themselves are solid.
🔴 code_interpreter → python_repl / shell hides a security-boundary change. Agent() with no sandbox= runs on NotASandboxLocalEnvironment (host, no isolation), so a user following the message/README moves model-written code from an isolated AgentCore session onto the agent's host with no warning. calculator's message already discloses exactly this kind of change; this one should too (inline suggestion, verified against test_migration_import_resolves).
🟡 The three Sub.__deprecated__ == Base.__deprecated__ "drift guard" tests can't fail — __deprecated__ resolves through the MRO, and mypy doesn't flag Sub() when the subclass marker is missing, so these are the only guard on the classes users actually instantiate (inline suggestion).
Everything else checks out: full suite green, ruff clean, mypy --enable-error-code deprecated reports all new markers, all migration targets exist in strands-agents 1.62.0, and the move to warn-on-invoke matches the function-tool convention.
✅ Verified, Questions, Reading order, Appendix
Verified (head 511e8d8; the delta from e5a3c22 is only the BYPASS_TOOL_CONSENT test fix)
pytest -n auto testsone5a3c22, py3.12, all extras: 1615 passed, 37 skipped; the 9 touched test modules re-run on511e8d8: 490 passed, 13 skipped.ruff check/ruff format --checkclean.mypy --enable-error-code deprecatedreports all 8 new/changed markers, including the fourcategory=Noneclasses and the two wrapped by@tool(load_tool,use_computer).- Construction no longer warns under
simplefilter("error", DeprecationWarning)forMockBrowser(),MockCodeInterpreter(),A2AClientToolProvider(),Mem0MemoryTool(). - Migration targets resolve in strands-agents 1.62.0:
vended_tools.python_repl/shell/handoff_to_user/file_editor,Agent(load_tools_from_directory: bool = False),strands.bidi.BidiAgent;bedrock-agentcore1.23.1 shipsBrowserClientonly. Vendedpython_repldocstring confirms fresh-interpreter-per-call; vendedhandoff_to_userraises an interrupt with nobreakout_of_loop— README bullets match. - Default sandbox repro:
strands/agent/agent.py:391self._sandbox = sandbox or NotASandboxLocalEnvironment(); vendedpython_repl.py:81has no error path for a missing sandbox — code ran as a child of the reviewer process, same cwd. - Tried and held: double-logging from subclasses (none override the tool method); dotted
module_namepath on Windows;@toolover@deprecatedkeeping SDKagentinjection (agent.tool.load_tool(...)→ success); every@toolmethod onA2AClientToolProvider.toolswarns.
Questions (non-blocking)
- Moving the warning out of
__init__means aMem0MemoryTool/A2AClientToolProviderthat's constructed and registered but never invoked now emits no deprecation signal at all, where v0.8.10 warned at construction. Deliberate trade, or worth keeping one construction-time log too? README.md:129still sellscode_interpreteras "isolated sandbox environments" — worth a clause there as well once the migration bullet carries the caveat?
Reading order for human reviewers
src/strands_tools/code_interpreter/code_interpreter.py(message + class marker pattern) →README.md:340-360(behavior differences)src/strands_tools/a2a_client.py,mem0_memory.py— the retroactive change to #621 behaviourtests/test_deprecations.py— dotted paths +use_computerskip
Appendix — non-blocking (5)
- ⚪
speak.py:19-21— message offers only Polly;README.md:351-354also points atstrands.bidi.BidiAgent. Consider appending "for a live voice agent, see strands.bidi.BidiAgent". - ⚪
handoff_to_user.py:51-52,code_interpreter.py:31-33— markdown backticks around imports; 24 of the 25 existing messages use the parenthetical(from strands.vended_tools import x)form. Note the terminator is load-bearing:test_migration_import_resolvesgreedily matchesfrom X import [\w., ]+, so dropping the backticks without adding parentheses breaks that test. - ⚪
use_computer.py:58-60— "drive pyautogui directly" under-scopes vs. the README's "pyautogui, pytesseract, and OS-specific app control". - ⚪
tests/test_deprecations.py:76-84— the headless gate names the wrong import: without a display the first failure isimport cv2(libGL.so.1), thenpyautogui(KeyError: 'DISPLAY'). CI unaffected (DISPLAYunset on ubuntu legs);DISPLAYset + no libGL would hard-fail instead of skip. - ⚪
README.md:195-196— "Python suppresses the resultingDeprecationWarningat runtime" is now true only for function tools; withcategory=Nonethe class markers never raise one, and the removed "(or, for class-based tools, when constructed)" was the only text that distinguished them.
- code_interpreter message and README disclose that the vended tools run on the host unless Agent(sandbox=...) is set. - Subclass marker tests read __dict__ so they fail when the subclass's own @deprecated is missing. - Use the parenthetical import form for handoff_to_user and code_interpreter, widen the use_computer message to pytesseract, and clarify the runtime DeprecationWarning note in the README.
Description
Deprecated
code_interpreter,browser,handoff_to_user,speak,load_tool, anduse_computer. These tools now log a warning at runtime and carry a@deprecatedmarker for static analysis, each naming where to go instead. Warnings ship in v0.8.11 and become error logs in v0.9.0.code_interpreter(AgentCoreCodeInterpreter)python_replfor Python, vendedshellfor other languageshandoff_to_userhandoff_to_userbrowser(LocalChromiumBrowser,AgentCoreBrowser)bedrock-agentcore'sBrowserClientfor AgentCore sessionsspeaksynthesize_speechdirectlyload_toolAgent, orAgent(load_tools_from_directory=True)use_computerpyautoguidirectlyThe replacements are deliberately not one-for-one. The vended
python_replandshellrun in the agent's configured sandbox, not an AgentCore session, and keep no in-memory state between calls. The vendedhandoff_to_userraises an interrupt instead of prompting on the console, and has nobreakout_of_loop.bedrock-agentcore(through 1.24.2) ships only the browser session layer, not a Strands tool. The README's behavior differences section calls out each gap; the no-replacement tools follow the existingrss/diagramstructure.Class-based tools now warn on invocation, not construction.
CodeInterpreter,Browser,Mem0MemoryTool, andA2AClientToolProvideruse@deprecated(..., category=None)and log from their tool methods. A runtimeDeprecationWarningon the abstract base classes would fire as soon as their subclasses were defined at import, so the marker is static-only for all four, and the README now says every tool warns when invoked. This changes theMem0MemoryToolandA2AClientToolProviderbehavior shipped in #621.test_deprecations.pynow resolves dotted module paths for the subpackage tools, and skipsuse_computer's import-based checks on headless Linux, wherepyautoguicannot import.Related Issues
Follows #621.
Type of Change
Other (please describe): Deprecation
Testing
pytest -n auto tests, Python 3.10), plusruff checkandruff format --checkmypy --enable-error-code deprecatedreports the documented imports (AgentCoreCodeInterpreter,LocalChromiumBrowser,AgentCoreBrowser)Checklist
On the last two: this intentionally adds deprecation warnings, which is its purpose. No dependent changes are required — the vended
python_repl,shell, andhandoff_to_usership instrands-agents1.61.0.