Skip to content

fix(agent): prompt guidance no longer mandates web tools the session doesn't have (#39797, salvage #39905) - #89924

Open
teknium1 wants to merge 1 commit into
mainfrom
deepagents-port/tool-availability-guidance
Open

fix(agent): prompt guidance no longer mandates web tools the session doesn't have (#39797, salvage #39905)#89924
teknium1 wants to merge 1 commit into
mainfrom
deepagents-port/tool-availability-guidance

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

The system prompt and browser tool schemas no longer hard-mandate web_search/web_extract — guidance now names retrieval tools only when they are actually in the active toolset, so user-configured alternatives (e.g. a Kagi search skill with SOUL.md overrides) are honored. Fixes #39797, salvages #39905 by @yinkev.

Root cause: OPENAI_MODEL_EXECUTION_GUIDANCE said "Current facts → use web_search" and the static browser_navigate/browser_cdp schemas said "prefer web_search or web_extract" unconditionally — the model followed the prompt over the user's SOUL.md instruction, and hallucinated the tools when the web toolset was disabled.

Changes

  • agent/prompt_builder.py: execution guidance says "appropriate permitted retrieval/search tool" instead of mandating web_search
  • model_tools.py: new _apply_browser_retrieval_hints() — replaces the old one-way strip hack; static schemas stay toolset-neutral and concrete tool names are appended only after check_fn filtering establishes availability (idempotent, so repeated schema builds stay byte-stable)
  • tools/browser_tool.py, tools/browser_cdp_tool.py: static schema descriptions made toolset-neutral
  • Tests: hint-application matrix (none / one / both web tools), schema-neutrality assertions, guidance regression test

Validation

Check Result
tests/agent/test_prompt_builder.py + tests/test_model_tools.py + tests/tools/test_browser_hardening.py + tests/tools/test_browser_cdp_tool.py 128 passed
E2E vs real BROWSER_TOOL_SCHEMAS/BROWSER_CDP_SCHEMA (no-web / web_search-only / both) correct names in every case
Idempotency (repeated application never grows descriptions) stable
Sibling sweep (use web_search/prefer web_extract across agent/, tools/) only remaining site is a permissive consent line in onboarding.py — not the mandating class

Salvaged from #39905 (cherry-picked with original authorship); conflicts against current main resolved in the two test files only.

Ported insight cross-checked against langchain-ai/deepagents#5602, which shipped the same fix class this week (web-search prompt guidance gated on Tavily availability) — external validation that model-facing guidance must be filtered to the live toolset.

Infographic

Infographic generation unavailable this run (FAL balance exhausted — hard fail per policy). Will attach on regeneration.

@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on 141fbd9 — fix(agent): respect permitted web retrieval guidance

❌ Job failures

Python tests / Run tests slice 12/12 · View job

Job Python tests / Run tests slice 12/12 failed.


⚠️ Warnings

OSV vulnerability scan · View job

7 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 5m3s vs 4m4s (+24.2%). 9 job(s) slower, 14 faster, 1 unchanged.

  • Python tests / Run tests slice 3/12: +42.0s
  • Python tests / Run tests slice 2/12: +33.0s
  • Python tests / Run tests slice 11/12: -26.0s
  • Python tests / Run tests slice 12/12: -20.0s
  • OSV scan / Scan lockfiles / osv-scan: -18.0s

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/tools Tool registry, model_tools, toolsets tool/browser Browser automation (CDP, Playwright) P2 Medium — degraded but workaround exists labels Aug 19, 2026
@teknium1

Copy link
Copy Markdown
Contributor Author

Slice 12/12 red is main-side: test_upscale_defaults_are_all_off fails on pristine origin/main (introduced by ceabb03). Fix: #89933. After it merges this branch needs a rebase onto main (rerun pins the original merge commit).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists tool/browser Browser automation (CDP, Playwright) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Hermes ignores SOUL.md's instruction to not use web_search and web_extract

3 participants