feat(tasks): long-horizon agent tasks (persistent, resumable, bounded) #268

Closed
nsaspy wants to merge 0 commits from feature/long-horizon-tasks into master
Owner

RAGE rebase recovery — current state

This PR was explicitly rebased/recovered onto Zara master after the original branch fell 138 commits behind.

  • pre-rebase head preserved at backup/feature-long-horizon-tasks-pre-rebase-20260902 (e406f105dcfdacf1f33b38bcc57b48f44e32e602)
  • recovery lineage starts from master 9f3b779b876df360001b12d0100698f334beb8b8
  • task engine, persistence, tools, tests, docs, database locking fix, and additive task runtime events are transplanted
  • zara/agent/__init__.py is ported onto the current #260 AgentLoopAdviceRegistry path: task-owned history/context stays external and does not overwrite normal conversation history
  • zara/runtime/backend.py is ported onto the current daemon router/memory/stream path: task-owned turns bypass ordinary top-level intent routing and normal durable chat-memory persistence while retaining the canonical agent/tool/advice loop
  • zara/config.py is ported as a narrow three-way delta: [tasks] remains default-off with strict bounded validation and get_tasks_config()
  • zara/runtime/host.py owns the single task runner on the canonical runtime thread; task steps use coordinator-issued turn ids and the existing backend/tool approval path; restart/shutdown stop the task runner before the backend; the backend publisher is restored when task observation stops
  • current hook, voice, latency, API-service, and plugin runtime ownership from master was preserved

Exact-head recovery evidence

CI #812 on fdff7ef91a13a57199c1f6637b77006a8fc73907 produced a deterministic RED: four t/test_task_host_wiring.py failures all showed RuntimeHost.start() leaving task_runner=None. The cause was not the task config or runner: RuntimeHost correctly requested the canonical backend's principal identity for principal-scoped task persistence, but the modern RuntimeBackend contract exposed no principal identity.

Commit b7cc0a85a6d84352c668d8e892e01b2b5f5e0e79 fixes that narrowly by adding a typed RuntimeBackend.principal_id contract, exposing the bound AgentManager.principal.principal_id from LangGraphRuntimeBackend, and delegating it through AgentRuntimeBackend. No hard-coded local principal and no RuntimeHost reach-through into private manager state.

Fresh exact-head CI #816 is the only merge authority for this new head. Shared-mic Arch/Ubuntu and Android skeleton gates are already green; the main scripts/test-all.sh / nix flake check / package gate must finish green before merge.

Do not merge while any exact-head gate is pending, failing, skipped, cancelled, or inconclusive.

Feature intent

Implements persistent, resumable, bounded long-horizon agent tasks without a second agent loop. Task steps remain ordinary conversation turns through the canonical runtime; approvals use the shared approval lifecycle; cancellation uses the existing coordinator/backend chain; [tasks].enabled remains default-off.

Core task behavior includes principal-scoped persistent task records, bounded step logs, startup recovery to interrupted, explicit resume, step/wall-clock budgets, bounded concurrency, additive task events, and task tools routed through the existing tool registry.

## RAGE rebase recovery — current state This PR was explicitly rebased/recovered onto Zara `master` after the original branch fell 138 commits behind. - pre-rebase head preserved at `backup/feature-long-horizon-tasks-pre-rebase-20260902` (`e406f105dcfdacf1f33b38bcc57b48f44e32e602`) - recovery lineage starts from master `9f3b779b876df360001b12d0100698f334beb8b8` - task engine, persistence, tools, tests, docs, database locking fix, and additive task runtime events are transplanted - `zara/agent/__init__.py` is ported onto the current #260 `AgentLoopAdviceRegistry` path: task-owned history/context stays external and does not overwrite normal conversation history - `zara/runtime/backend.py` is ported onto the current daemon router/memory/stream path: task-owned turns bypass ordinary top-level intent routing and normal durable chat-memory persistence while retaining the canonical agent/tool/advice loop - `zara/config.py` is ported as a narrow three-way delta: `[tasks]` remains default-off with strict bounded validation and `get_tasks_config()` - `zara/runtime/host.py` owns the single task runner on the canonical runtime thread; task steps use coordinator-issued turn ids and the existing backend/tool approval path; restart/shutdown stop the task runner before the backend; the backend publisher is restored when task observation stops - current hook, voice, latency, API-service, and plugin runtime ownership from master was preserved ### Exact-head recovery evidence CI #812 on `fdff7ef91a13a57199c1f6637b77006a8fc73907` produced a deterministic RED: four `t/test_task_host_wiring.py` failures all showed `RuntimeHost.start()` leaving `task_runner=None`. The cause was not the task config or runner: `RuntimeHost` correctly requested the canonical backend's principal identity for principal-scoped task persistence, but the modern `RuntimeBackend` contract exposed no principal identity. Commit `b7cc0a85a6d84352c668d8e892e01b2b5f5e0e79` fixes that narrowly by adding a typed `RuntimeBackend.principal_id` contract, exposing the bound `AgentManager.principal.principal_id` from `LangGraphRuntimeBackend`, and delegating it through `AgentRuntimeBackend`. No hard-coded local principal and no RuntimeHost reach-through into private manager state. Fresh exact-head CI #816 is the only merge authority for this new head. Shared-mic Arch/Ubuntu and Android skeleton gates are already green; the main `scripts/test-all.sh` / `nix flake check` / package gate must finish green before merge. **Do not merge while any exact-head gate is pending, failing, skipped, cancelled, or inconclusive.** ## Feature intent Implements persistent, resumable, bounded long-horizon agent tasks without a second agent loop. Task steps remain ordinary conversation turns through the canonical runtime; approvals use the shared approval lifecycle; cancellation uses the existing coordinator/backend chain; `[tasks].enabled` remains default-off. Core task behavior includes principal-scoped persistent task records, bounded step logs, startup recovery to `interrupted`, explicit resume, step/wall-clock budgets, bounded concurrency, additive task events, and task tools routed through the existing tool registry.
nsaspy closed this pull request 2026-09-04 23:09:33 +00:00
Some checks failed
CI / test (pull_request) Failing after 4s
CI / android skeleton gate (pull_request) Failing after 5s
CI / shared mic / Ubuntu 24.04 (pull_request) Failing after 9m20s
CI / shared mic / Arch Linux (pull_request) Failing after 10m21s

Pull request closed

Sign in to join this conversation.
No description provided.