fix: background tasks now fetch real page content; add task-status tools
Rebuild & Deploy / rebuild (push) Successful in 58s

Background research tasks were producing garbage or failing because the
self-hosted Firecrawl /v1/scrape defaults to a ~30s timeout that's too short
for heavy news/research sites, and the small LLM won't reliably chain a
second scrape call after a search that only returns snippets.

task_worker.py:
- web_search now auto-fetches the top results directly from the container
  (which has working outbound internet) and returns their real text, so the
  model gets actual page content in one call instead of snippet echoes.
- web_scrape requests timeout: 90000 (Firecrawl renders heavy sites but needs
  >30s), and falls back to a direct container fetch with tag-stripping if
  Firecrawl times out or returns nothing.

task_registry.py / dispatch_mcp.py:
- Add task_status(id) and list_tasks() tools so Hope can check the live state
  of any dispatched task (pending / running / completed / failed / STALLED).
- Track last_activity per task and surface a stall heuristic.
- Move the status summary into task_registry (no mcp dependency) so it's
  unit-testable.

agent.py: prompt tells Hope about task_status / list_tasks.
tests: add task-status summary and last-activity regression tests.
This commit is contained in:
snowspeeder committed 2026-08-30 06:54:57 -04:00
1 parent df8aa64504
commit d4ea4fc984
5 files changed
+217 -30

No files matched your search

+5 -1
View File
@@ -202,7 +202,11 @@ SYSTEM_PROMPT = textwrap.dedent("""\
After calling dispatch_task, tell the user "I'll get on that for you"
without asking for more permission or details. The result comes back automatically — when
you receive it, share the findings naturally in your conversational style.
You can have multiple tasks running at once.
You can have multiple tasks running at once. If the user asks about a
task's progress or you want to check one yourself, call task_status with
its id (it reports pending/running/completed/failed and whether it looks
stalled); task_status can also be called to check up on a task. Use
list_tasks to see every task you have dispatched.
# Music (media player in the web UI)
You can play music on the user's web player. For any music request, call