Global chat: Add web search & fetch capability
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 5
- Forks
- 10
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 17
Description
Add web search & fetch to global_chat planner agent (+ ideally, all agents, but requires additional work)
Goal: Enable agentic doc lookup (find URL → open page → read) for things like DHIS2 API docs, similar to Claude.ai web chat.
Changes:
- Add web_search_20260209 and web_fetch_20250910 tools to PlannerAgent (services/global_chat/planner.py). These run on Anthropic's servers, not locally like our other tools. May require enabling web search in Anthropic Console. Evaluate other approaches too: what are the pros and cons of using Anthropic's web search capability vs a custom tool?
- Set max_uses
- Possibly: Set allowed_domains allowlist (DHIS2, OpenFn, common adaptor target APIs) — required for safety. If these are well defined, it would also speed up the model's tool usage loop if it was given the correct URLs when using the tool.
Code audit needed:
- Tool-use loop must pass server_tool_use blocks through (not dispatch as local tools).
- Handle stop_reason: "pause_turn" by continuing the request.
- Search ID encrypted_content / encrypted_index may need to be preserved and not pruned across conversations
- StreamManager must render or knowingly drop web_search_tool_result and citation blocks
Front-end:
- How do we communicate to users the risks & cost of turning web search on?
- New streaming statuses
- It should be possible for users to turn it off. It would not work with a ZDR contract.
Security:
- Env secrets (API keys, DB URL) are not at risk, as these are never in LLM context.
- Risk is exfiltration of user-pasted data (credentials, state) via injected instructions in fetched pages.
- Evaluate potential ways to minimise security risks for users (e.g. separate agent with no access to job code/logs)
Cost:
- $10 / 1k searches + token costs for fetched content. max_uses caps per-turn spend.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with services/global_chat/planner.py and trace the tool-use loop, stop_reason handling, and StreamManager rendering. Review the Anthropic server-tool requirements, encrypted search fields, domain and usage limits, frontend status and opt-out needs, and security constraints; done means the behavior and risks are resolved across these areas, with the relevant web-search results and citations handled safely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai, backend, frontend, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100