Skip to content

Harden agent loop, device control, and integrations#105

Draft
neooriginal wants to merge 1 commit into
betafrom
agent/reliability-hardening
Draft

Harden agent loop, device control, and integrations#105
neooriginal wants to merge 1 commit into
betafrom
agent/reliability-hardening

Conversation

@neooriginal

Copy link
Copy Markdown
Contributor

Summary

  • Make agent runs durable and controllable across startup, model calls, tool calls, pause/resume, stop, shutdown, and restart recovery.
  • Prevent false completion and silent exits by requiring completion evidence, rejecting non-terminal promises such as "I'm working on it", and producing a truthful fallback when a safety ceiling is reached.
  • Keep long-running work flexible: the iteration ceiling is a configurable runaway guard, genuine new evidence resets the no-progress counter, and only unchanged/repeated work is cut off.
  • Harden browser, Chrome-extension, Android, and desktop control with end-to-end cancellation, bounded output, protocol cleanup, crash/disconnect recovery, safer screenshots, URL/network validation, and clearer errors.
  • Improve provider and official-integration reliability with bounded model calls, transient retry/fallback behavior, dynamic tool access metadata, correct read-only parallelism, OAuth race protection, and retry-safe HTTP handling.
  • Make messaging, memory ingestion, runtime, voice, social, and wearable paths cancellation-aware and resilient to partial failures.
  • Update vulnerable/outdated dependencies and raise the supported Node runtime to 20.19+.

Why

Several reliability failures shared the same underlying patterns:

  • cancellation was not consistently propagated to the real subprocess, socket, request, browser page, or device command;
  • terminal state could race with pause/stop/shutdown, and startup failures could disappear before being recorded;
  • successful MCP and official-integration reads were invisible to the loop's progress guard;
  • a wrapper argument mismatch effectively disabled parallel batching for safe read-only tools;
  • provider/network responses and retries were not uniformly bounded;
  • the memory embedding-index migration recreated an index on every startup and could race in multi-process startup;
  • messaging and recovery paths could lose work or leave orphaned execution.

This patch centralizes those lifecycle guarantees and adds regression coverage around the failure boundaries.

Agent-loop behavior audited

  • Default execution allows up to 250 iterations (bounded at 400) as a last-resort runaway guard, not a normal stopping condition.
  • Loop budgets are persistently configurable within safe bounds and preserve context-specific defaults when unset.
  • New tool evidence counts as progress; repeated unchanged calls are rejected without blocking legitimate research.
  • Completion remains model-assisted, but a deterministic evidence/goal contract prevents status promises from being accepted as completed work.
  • Pause/resume preserves the same run, stop/abort interrupts active work, shutdown drains owned background work, and terminal transitions are first-writer-wins.
  • Model timeouts, transient retries, fallback selection, blank responses, compaction, tool failures, and restart recovery all have explicit terminal or recovery behavior.

User impact

  • Fewer unexplained stalls, false "done" messages, and abandoned runs.
  • Prompt stop/pause behavior even during external calls or device operations.
  • More reliable long-horizon research and integration workflows without hard-coded premature termination.
  • Better browser/device error feedback and recovery after disconnects or crashes.
  • Durable inbound messaging and safer retries that do not replay writes.

Validation

  • npm run test:backend — 536 passed: 496 unit, 19 integration, 11 security, 4 contract, 2 E2E, and 4 WebSocket tests.
  • npm run flutter:test — 13 passed.
  • flutter analyze — no issues.
  • All changed JavaScript/MJS files passed syntax checks.
  • git diff --check passed.
  • npm audit --audit-level=low and npm run audit:ci — 0 vulnerabilities.
  • npm ls --all passed.
  • npm run docs:build passed.
  • Playwright Chromium launch/navigation smoke test passed with the installed browser.

Platform-validation notes

  • A Flutter web build was intentionally not run, per repository instructions.
  • Windows companion C++ was reviewed and covered through protocol/unit tests but was not compiled on macOS.
  • Physical Android and Windows hardware validation remains appropriate during beta rollout.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant