Skip to content

Move web search into a sub-agent tool#136

Merged
davidharting merged 3 commits into
mainfrom
media-web-search-subagent
May 13, 2026
Merged

Move web search into a sub-agent tool#136
davidharting merged 3 commits into
mainfrom
media-web-search-subagent

Conversation

@davidharting
Copy link
Copy Markdown
Owner

Summary

  • Extracts WebSearch out of MediaTrackingAgent and into a new MediaWebSearchAgentTool sub-agent, working around a PrismPHP bug where the Anthropic provider returns 400 errors when an agent mixes custom and provider tools across multi-turn conversations.
  • Reframes the orchestrator's web-search guidance around purpose ("identify media you don't already know") instead of mandating it on every prompt, so logging events on already-tracked media can skip the web search.

Test plan

  • php artisan test — 294 passed
  • task format
  • Manual end-to-end via Telegram:
    • Adding new media (previously 400-ed) works and identifies via the sub-agent
    • Ambiguous title (e.g. "add Dune") surfaces multiple candidates and disambiguates
    • Logging a finished/started event on something already in the library doesn't trigger a web search

🤖 Generated with Claude Code

davidharting and others added 3 commits May 11, 2026 11:56
PrismPHP's Anthropic provider returns 400 errors when an agent mixes
custom tools with provider tools (like WebSearch) across multi-turn
conversations. Extract WebSearch into MediaWebSearchAgentTool — a custom
tool whose handle() spawns a sub-agent with WebSearch as its only tool —
so the orchestrator only owns custom tools. Mirrors the existing
MediaWritingAgentTool pattern.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Previously the orchestrator was told to "always" call MediaWebSearchAgentTool
before responding, which caused needless web searches when David referred
to media already in his library (e.g. logging a finished event on something
currently being read). Reframe the guidance around the tool's purpose —
identifying unknown media — so the orchestrator can skip it when SearchMedia
alone is sufficient.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Documents the PrismPHP/Anthropic 400-error bug that motivates wrapping
WebSearch inside MediaWebSearchAgentTool instead of exposing it directly.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@davidharting davidharting marked this pull request as ready for review May 13, 2026 01:22
@davidharting davidharting merged commit f195cd6 into main May 13, 2026
1 check passed
@davidharting davidharting deleted the media-web-search-subagent branch May 13, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant