fix: restore controls after task completion
Rebuild & Deploy / rebuild (push) Successful in 1m6s

This commit is contained in:
snowspeeder committed 2026-08-29 07:57:23 -04:00
1 parent 120ab192f1
commit 63e15b6023
5 files changed
+83 -10

No files matched your search

+26 -6
View File
@@ -102,11 +102,11 @@ class TaskWorker:
if not text:
reg.fail(self.task_id, "LLM returned empty response")
return
if self._is_deferred_answer(text):
if self._is_deferred_answer(text) or self._is_underfilled_news_answer(text):
reg.add_step(
self.task_id,
"thinking",
"Draft deferred the work; continuing automatically.",
"Draft was incomplete; continuing automatically.",
)
if iteration == max_iterations - 1:
reg.fail(self.task_id, "Could not produce a complete answer")
@@ -117,8 +117,9 @@ class TaskWorker:
{
"role": "user",
"content": (
"Do not ask me a follow-up or offer to continue later. "
"Continue the task now, run any more targeted tool calls "
"The previous draft did not fully answer the original request. "
"Do not ask a follow-up or offer to continue later. Continue "
"the task now, run any more targeted tool calls "
"you need, make reasonable assumptions, and only finish "
"when you have directly answered the original request."
),
@@ -153,6 +154,23 @@ class TaskWorker:
)
return "?" in text or any(phrase in lowered for phrase in deferral_phrases)
def _is_underfilled_news_answer(self, text: str) -> bool:
"""Reject generic news summaries that do not name actual events."""
description = self.description.lower()
if "news" not in description and "headline" not in description:
return False
lowered = text.lower()
generic_phrases = (
"reports also cover global developments",
"other sources indicate",
"various international perspectives",
"ongoing coverage of world events",
"recommend checking major",
"unable to retrieve",
"could not retrieve",
)
return any(phrase in lowered for phrase in generic_phrases)
def _system_prompt(self) -> str:
today = datetime.now(timezone.utc).strftime("%B %d, %Y")
return (
@@ -162,8 +180,10 @@ class TaskWorker:
"to finish later; make reasonable assumptions and continue autonomously. If a web "
"search is broad or inconclusive, immediately run a more targeted query and scrape "
"the most promising result pages, including today's date and specific reputable "
"sources when freshness matters. For headline "
"requests, return concrete named events rather than links to news homepages, and "
"sources when freshness matters. For plural news or headline requests, provide three "
"distinct concrete events unless the user requests a different count. For three "
"headlines, write exactly three sentences with one event per sentence and no extras. Never pad the "
"answer with generic phrases about broad coverage or international perspectives, and "
"respect any requested item count exactly. Only "
"produce a final answer once it fulfills the original request. The final answer must "
"be 1-3 concise sentences suitable for speaking aloud, with plain text only and no "