Skip to content

Bug: web search fallback has no error handling — hangs silently in sandboxed environments #4

Description

@Augustas11

Problem

The Wikipedia API fallback embedded in the prompt is a single-line call with no exception handling:

import urllib.request,json; data=json.loads(urllib.request.urlopen(f"https://en.wikipedia.org/api/rest_v1/page/summary/{query}",timeout=10).read().decode()); print(data.get("extract",""))

In Docker/sandboxed environments with no outbound internet, this hangs for the full 10-second timeout. The agent may then give up or write a wrong answer. The failure is silent — nothing in the logs indicates a network issue caused the error.

Fix

Wrap in try/except in the prompt instruction:

try:
    import urllib.request, json
    data = json.loads(urllib.request.urlopen(url, timeout=5).read().decode())
    print(data.get("extract", "Not found"))
except Exception as e:
    print(f"Web lookup failed: {e}. Proceed without external data.")

Impact

Medium — only affects questions requiring external definitions, but causes silent hangs in the standard Docker benchmark setup.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions