Repository navigation
Description
From the open-library audit of 2026-10-22 (ranked R04, about 1900 lines of source and tests; risk L (after R01 and R02)). ai-core-6. Spot-checked: the only live importer outside dead code is roadmap/refine.py (tavily_search); other importers are harness/agents.py and the dead WebSearch/WebFetch capabilities, both removed by R01. Depends on R01.
What the code is (ai-core-6): common_tools.py holds a hand-written DuckDuckGo HTML scraper (regex over html.duckduckgo.com), a custom web_fetch with its own MarkdownConverter subclass, about 180 lines of try/except fallback shims for Exa, XSearch and ImageGeneration, mirrored TypedDicts and tavily_search_tool. The only live consumer in src is roadmap/refine.py calling tavily_search (a 30-line POST). web_fetch_tool/duckduckgo_search_tool are called only by harness Coder/Researcher and the dead WebSearch/WebFetch capabilities; PromptInjectionDefender (guardrails.py) is called only from render_untrusted_page.
Files: src/devops_cli/ai/common_tools.py (690), src/devops_cli/ai/agents/guardrails.py (246)
Existing tool considered: pydantic_ai.common_tools (web_fetch with SSRF-safe safe_download, duckduckgo, tavily, exa) when a feature needs them. Keep tavily_search as is. Behaviour gap: Project web_fetch wraps output in <untrusted_web_page>, runs sanitize_prompt_boundary_tags and a prompt-injection scan, and goes through the egress broker; the native tool does not do the wrapping or the scan. Irrelevant now because nothing calls it; re-add those two calls around the native tool if it is wired.
Evidence: grep of web_fetch_tool|duckduckgo_search_tool|render_untrusted_page|tavily_search outside common_tools.py: only roadmap/refine.py:51,438 (tavily_search) plus dead callers.
Tests affected: tests/test_common_tools.py (628); tests/test_native_common_tools.py (135); tests/test_ai_agent_guardrails.py (236); tests/test_http_egress.py; tests/test_runtime_security_and_ssrf_hardening.py
Risk (L): Order-dependent: do after candidates 1 and 3 remove the dead callers.
Land after #1836 and the facade deletion (the issue titled 'delete the dead pydantic_ai re-export facades ...'); the only live importer outside dead code is roadmap/refine.py (tavily_search).
Acceptance criteria:
- The listed modules, symbols and their tests are deleted; none is skipped or xfailed; a grep of src, tests, AGENTS.md and docs (outside docs/agent history and CHANGELOG) for the deleted paths and names returns nothing.
- Every shared list is updated (CONST_ lists, invariants, ceilings fixture, conftest, generated docs) and
devops docs checkis clean. devops cipasses with coverage at or above 90%.
Proposed design
Problem statement
The ai/common_tools.py module contains redundant and overly complex code for web fetching and search tools, including a hand-written DuckDuckGo scraper, custom Markdown conversion logic, and fallback implementations for various AI tools. The only live consumer is tavily_search, while other tools are unused or deprecated. Additionally, the guardrails.py module provides prompt injection defense that is no longer used.
Acceptance criteria
- Criterion 1: The ai/common_tools.py file is deleted without any remaining references in source code, tests, documentation, or configuration files.
Verification: A grep of src, tests, AGENTS.md and docs for 'common_tools' returns nothing. - Criterion 2: The ai/agents/guardrails.py file is deleted without any remaining references in source code, tests, documentation, or configuration files.
Verification: A grep of src, tests, AGENTS.md and docs for 'guardrails' returns nothing. - Criterion 3: The tavily_search function remains functional and is not affected by the refactor.
Verification: The roadmap/refine.py module can still call tavily_search and get expected results. - Criterion 4: All related tests are updated to reflect the deletion of the modules.
Verification: devops ci passes with coverage at or above 90%. - Criterion 5: Shared lists and configuration files are updated to remove references to deleted code.
Verification: devops docs check is clean after the refactor.
Key questions
- What is the only live consumer of ai/common_tools.py outside of dead code?: The only live consumer in src is roadmap/refine.py calling tavily_search. [sources: src/devops_cli/ai/common_tools.py:480]
- What are the specific tools and functions that will be deleted from ai/common_tools.py?: The module contains a hand-written DuckDuckGo HTML scraper, a custom web_fetch with its own MarkdownConverter subclass, about 180 lines of try/except fallback shims for Exa, XSearch and ImageGeneration, mirrored TypedDicts and tavily_search_tool. The only live consumer is roadmap/refine.py calling tavily_search. [sources: src/devops_cli/ai/common_tools.py:13]
- What is the behavior gap mentioned in the issue for web_fetch?: Project web_fetch wraps output in , runs sanitize_prompt_boundary_tags and a prompt-injection scan, and goes through the egress broker; the native tool does not do the wrapping or the scan. [sources: src/devops_cli/ai/common_tools.py:249]
- Should the behavior gap be addressed by re-adding the wrapping and scanning calls around the native tool?: Yes, if it is wired back in, those two calls should be added around the native tool. (proposed) [sources: src/devops_cli/ai/common_tools.py:249]
- What tests are affected by this deletion?: Tests affected include tests/test_common_tools.py (628), tests/test_native_common_tools.py (135), tests/test_ai_agent_guardrails.py (236), tests/test_http_egress.py, and tests/test_runtime_security_and_ssrf_hardening.py [sources: src/devops_cli/ai/common_tools.py:480]
- What is the dependency order for this change?: The change must be done after candidates 1 and 3 remove the dead callers. [sources: src/devops_cli/ai/common_tools.py:480]
- What is the final condition for this issue to be considered complete?: The listed modules, symbols and their tests are deleted; none is skipped or xfailed; a grep of src, tests, AGENTS.md and docs (outside docs/agent history and CHANGELOG) for the deleted paths and names returns nothing. [sources: src/devops_cli/ai/common_tools.py:480]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 22, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
The candidate proposes a refactor to reduce code and delete unused files.It is part of a larger audit and depends on other items, suggesting it's important but not critical.The change improves code quality by removing dead code and simplifying the architecture.It involves deleting significant code and updating multiple tests and documentation.dan-petty commentedon Oct 22, 2026
Status set to Ready at ae8c2d9 (see proposed design in issue body).
refactor(ai): delete the web fetch tool, the search wrappers and the …
dan-petty commentedon Oct 22, 2026
What changed
#1893, merged into
release/v0.2.39as 5bb1097.19 file(s) changed.
How it was verified
Check runs at 18f61e3:
Acceptance Criteria of
docs/agent/tasks/task-1854-common-tools-tavily-only.md:ai/common_tools.pydefinestavily_searchand nothing else, andagents/guardrails.pyis gone. A search ofsrc,tests,AGENTS.md,README.md,ARCHITECTURE.mdanddocs(outsidedocs/agentandCHANGELOG.md) for the deleted module paths and names finds nothing. No test is skipped or xfailed.tests/test_common_tools.pycovers every line oftavily_search(src/devops_cli/ai/common_tools.py20 of 20 statements).tests/test_roadmap_refine.pyandtests/test_http_egress.pystill pass withtavily_searchas their only search caller.commands/,server/andmainreaches no deleted module and leaves no module newly unreached.uv run deptry srcfinds no unused or missing dependency.uv run devops docs checkreports every file up to date.ruff checkandruff format --checkpass oversrcandtests, andmypypasses oversrc. These tests pass:tests/test_architectural_invariants.py,tests/test_swallowed_failures_ratchet.py,tests/test_agent_task_files.py,tests/test_agents_md_claims.py,tests/test_public_export_surface.py,tests/test_all_commands_help_dryrun.pyandtests/test_mcp.py.uv run devops cipasses on the delivering tree. This change ran the targeted tests, not the gate.feat(release): v0.2.39 (#1947)