Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

feat: deprecate code_interpreter, browser, handoff_to_user, speak, load_tool, and use_computer tools - #629

Merged
liramon2 merged 2 commits into
strands-agents:mainfrom
liramon2:deprecation-3
Oct 23, 2026
Merged

liramon2 merged 2 commits into
strands-agents:mainfrom
liramon2:deprecation-3

Conversation

@liramon2

@liramon2 liramon2 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Deprecated code_interpreter, browser, handoff_to_user, speak, load_tool, and use_computer. These tools now log a warning at runtime and carry a @deprecated marker for static analysis, each naming where to go instead. Warnings ship in v0.8.11 and become error logs in v0.9.0.

Tool module Points at Kind
code_interpreter (AgentCoreCodeInterpreter) vended python_repl for Python, vended shell for other languages SDK Tool
handoff_to_user vended handoff_to_user SDK Tool
browser (LocalChromiumBrowser, AgentCoreBrowser) no replacement — drive Playwright directly, with bedrock-agentcore's BrowserClient for AgentCore sessions None
speak no replacement — call Amazon Polly's synthesize_speech directly None
load_tool no replacement — pass tools to the Agent, or Agent(load_tools_from_directory=True) None
use_computer no replacement — drive pyautogui directly None

The replacements are deliberately not one-for-one. The vended python_repl and shell run in the agent's configured sandbox, not an AgentCore session, and keep no in-memory state between calls. The vended handoff_to_user raises an interrupt instead of prompting on the console, and has no breakout_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 existing rss/diagram structure.

Class-based tools now warn on invocation, not construction. CodeInterpreter, Browser, Mem0MemoryTool, and A2AClientToolProvider use @deprecated(..., category=None) and log from their tool methods. A runtime DeprecationWarning on 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 the Mem0MemoryTool and A2AClientToolProvider behavior shipped in #621.

test_deprecations.py now resolves dotted module paths for the subpackage tools, and skips use_computer's import-based checks on headless Linux, where pyautogui cannot import.

Related Issues

Follows #621.

Type of Change

Other (please describe): Deprecation

Testing

  • Full unit suite passes locally (pytest -n auto tests, Python 3.10), plus ruff check and ruff format --check
  • mypy --enable-error-code deprecated reports the documented imports (AgentCoreCodeInterpreter, LocalChromiumBrowser, AgentCoreBrowser)

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

On the last two: this intentionally adds deprecation warnings, which is its purpose. No dependent changes are required — the vended python_repl, shell, and handoff_to_user ship in strands-agents 1.61.0.

@liramon2
liramon2 requested a review from a team as a code owner October 23, 2026 18:21
@liramon2
liramon2 requested a review from mkmeral October 23, 2026 18:21
@liramon2

Copy link
Copy Markdown
Contributor Author

@strandly-the-agent Review this PR

@liramon2
liramon2 marked this pull request as draft October 23, 2026 18:24
…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.
@liramon2
liramon2 marked this pull request as ready for review October 23, 2026 18:43

@strandly-the-agent strandly-the-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 tests on e5a3c22, py3.12, all extras: 1615 passed, 37 skipped; the 9 touched test modules re-run on 511e8d8: 490 passed, 13 skipped. ruff check / ruff format --check clean.
  • mypy --enable-error-code deprecated reports all 8 new/changed markers, including the four category=None classes and the two wrapped by @tool (load_tool, use_computer).
  • Construction no longer warns under simplefilter("error", DeprecationWarning) for MockBrowser(), 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-agentcore 1.23.1 ships BrowserClient only. Vended python_repl docstring confirms fresh-interpreter-per-call; vended handoff_to_user raises an interrupt with no breakout_of_loop — README bullets match.
  • Default sandbox repro: strands/agent/agent.py:391 self._sandbox = sandbox or NotASandboxLocalEnvironment(); vended python_repl.py:81 has 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_name path on Windows; @tool over @deprecated keeping SDK agent injection (agent.tool.load_tool(...) → success); every @tool method on A2AClientToolProvider.tools warns.

Questions (non-blocking)

  1. Moving the warning out of __init__ means a Mem0MemoryTool / A2AClientToolProvider that'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?
  2. README.md:129 still sells code_interpreter as "isolated sandbox environments" — worth a clause there as well once the migration bullet carries the caveat?

Reading order for human reviewers

  1. src/strands_tools/code_interpreter/code_interpreter.py (message + class marker pattern) → README.md:340-360 (behavior differences)
  2. src/strands_tools/a2a_client.py, mem0_memory.py — the retroactive change to #621 behaviour
  3. tests/test_deprecations.py — dotted paths + use_computer skip

Appendix — non-blocking (5)

  • ⚪ speak.py:19-21 — message offers only Polly; README.md:351-354 also points at strands.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_resolves greedily matches from 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 is import cv2 (libGL.so.1), then pyautogui (KeyError: 'DISPLAY'). CI unaffected (DISPLAY unset on ubuntu legs); DISPLAY set + no libGL would hard-fail instead of skip.
  • ⚪ README.md:195-196 — "Python suppresses the resulting DeprecationWarning at runtime" is now true only for function tools; with category=None the class markers never raise one, and the removed "(or, for class-based tools, when constructed)" was the only text that distinguished them.

Comment thread README.md Resolved
- 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.
Comment thread src/strands_tools/browser/browser.py Resolved

This branch was successfully deployed

1 active deployment
auto-approve — f4619ff9 Deployed Oct 23, 2026 by liramon2 via check-access-and-checkout #634
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants