chat: mission mode (/mission, --mission) — autonomous goal runs in background with retries, corrections, state-aware retry hints; input() moved to thread so missions run while the REPL waits; configurable nudge_limit

This commit is contained in:
opencode
2026-08-08 13:54:44 +03:00
parent f4cb04a47f
commit 6a509aacc6
5 changed files with 1499 additions and 14 deletions
+8 -5
View File
@@ -363,6 +363,7 @@ async def run_llm_agent_loop(
*,
log: LogFn,
recorder: Any | None = None,
nudge_limit: int = 1,
) -> dict[str, Any]:
"""Drive the controller until the mission is done or steps run out."""
summary: dict[str, Any] = {
@@ -450,11 +451,13 @@ async def run_llm_agent_loop(
if not turn.calls:
# Nudge a model that drifted into plain text back to acting.
silent = (not turn.text) or len(turn.text) < 8
already_nudged = (
bool(controller.messages)
and controller.messages[-1].get("content") == NUDGE
)
if silent or already_nudged:
consecutive_nudges = 0
for msg in reversed(controller.messages):
if msg.get("content") == NUDGE:
consecutive_nudges += 1
else:
break
if silent or consecutive_nudges >= nudge_limit:
summary["result"] = "model produced no tool call"
return summary
controller.messages.append({"role": "user", "content": NUDGE})