Skip to content

feat(tools): add Python tool registry removal - #5444

Merged
liramon2 merged 2 commits into
strands-agents:mainfrom
ikenyal:agent-tasks/5323
Oct 26, 2026
Merged

liramon2 merged 2 commits into
strands-agents:mainfrom
ikenyal:agent-tasks/5323

Conversation

@ikenyal

@ikenyal ikenyal commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Human Overview

I wanted callers to remove tools without having to keep the registry’s internal dictionaries in sync themselves. This change adds the same removal API available in TypeScript and uses it for Swarm and structured-output cleanup, while keeping missing-tool removal a no-op.

Description

Removing a Python tool currently requires callers to keep two dictionaries in sync. A public removal method prevents tools from remaining available through a stale dynamic registration and brings Python into parity with TypeScript.

Public API Changes

The existing strands.tools.registry.ToolRegistry gains remove(tool_name: str) -> None. It removes the exact registered name from both regular and dynamic tools; missing names are a no-op.

# Before
agent.tool_registry.registry.pop(tool_name, None)
agent.tool_registry.dynamic_tools.pop(tool_name, None)

# After
agent.tool_registry.remove(tool_name)

Related Issues

Resolves #5323.

Documentation PR

The new method's docstring documents its contract. A before/after usage example is included in Public API Changes above. The generated Python API reference was verified locally; no separate guide change is needed.

Type of Change

New feature

Testing

Before review cleanup, pre-push checks passed: lint, mypy, Python 3.12 coverage (7,836 passed, 38 skipped), 100 related tests on Python 3.10, build, complexity, API generation, and a built-wheel smoke test. After the documentation/test-only cleanup, all 99 remaining related tests, scoped Ruff formatting/lint, and API generation passed. AST comparison confirms production logic is unchanged. The full suite was not rerun for this revision. No real-provider integration tests were run.

  • I ran hatch run prepare

The local checks above were run instead; prepare also runs the full Python-version matrix, which is left to CI.

Additional Details

Scope and validation notes

As agreed in #5323, this updates Swarm and structured-output cleanup on main. Graph remains in the separate, unmerged #5131; its call site can adopt this method according to merge order. There is no dependency on that PR and no change to connection/provider lifecycle management.

The affected tests emit the same warnings as unmodified main. API generation also reports the same two existing unresolved references in strands.tools.decorator on main. The full suite retains its existing deprecation and mock-coroutine warnings.

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • 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, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@github-actions github-actions Bot added area-tool Tool behavior/api area-devx Developer experience improvements enhancement New feature or request python Pull requests that update python code labels Oct 22, 2026
@ikenyal
ikenyal marked this pull request as ready for review October 22, 2026 20:03
@ikenyal
ikenyal requested a review from a team as a code owner October 22, 2026 20:03
@ikenyal
ikenyal requested a review from mkmeral October 22, 2026 20:03
@liramon2

Copy link
Copy Markdown
Contributor

@ikenyal Hi, thanks for the contribution. I left a couple comments on this PR.

@github-actions github-actions Bot added complexity/low Touched functions have low cognitive complexity (<=10) size/xs labels Oct 26, 2026
@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@liramon2
liramon2 merged commit f3ee040 into strands-agents:main Oct 26, 2026
36 of 38 checks passed
gautamsirdeshmukh pushed a commit to gautamsirdeshmukh/harness-sdk that referenced this pull request Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-devx Developer experience improvements area-tool Tool behavior/api complexity/low Touched functions have low cognitive complexity (<=10) enhancement New feature or request python Pull requests that update python code size/xs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add ToolRegistry.remove() in Python

2 participants