taskwatch: a task session that cannot finish is ended, and the task reads as failed #97
Loading…
Reference in a new issue
No description provided.
Delete branch "task-end"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From the first foreman-to-worker run: a worker whose model fails every turn is nudged by gc three times, then nothing ends it and the foreman is never told. specs-18 accepted
task_timeout, a failed task that does not read as done,gc.work_outcome, and the cheaper signal beside the clock.internal/taskwatch: ends a task session after[agents.<n>] task_timeoutand afterfailed_turnsfailed turns in a row (default 3 for an agent with the toolclaim; negative is none). A failed turn is a JSON-RPC error answering asession/prompt, which is what the room renders as "The turn ended with an error"; an answer ends the run. Observed atReport; ended once.gcwork.Fail: the task (claimed on the session's behalf withgc hook --claimwhen it never claimed) gets the reason in its notes,gc.work_outcome=abandonedand a close reason, thengc runtime drain-ack. The foreman'swaitfires andresultreturns closed with outcomeabandonedand the reason.donesetsgc.work_outcome=no-op. gc has four outcomes (shipped needs a commit and a branch, no-op, blocked, abandoned); a task answered with text and no commit has none of its own, so no-op, which gc's gate accepts without a commit. A choice, said here: say so if another reading is wanted.HostService.ResultResponse.outcome. roomcity-5e's host toolresultshould say "failed" forabandonedand not read the notes as an answer.Read from gc's source and the registry, not run on a cluster: that
bd update --set-metadata,bd close --reason=andbd show --json'smetadatamap are as the stub has them.Read at
009fa5c. Green here under-race;internal/taskwatchandinternal/gcworktwenty times withGOMAXPROCS=1.Two things you read and did not run, run here:
worker-sa-wisp-sbd2z, ids and shapes only): foursession/promptto the agent (ids 3 to 6), each answered from the agent by a JSON-RPC error,-32000 "Authentication required". That is exactly whatObservecounts; with the default it would have ended the session at the third.bd update <id> --notes=... --set-metadata gc.work_outcome=no-opandbd close <id> --reason=...are taken, andbd show --jsongivesclose_reasonandmetadataas an object.The second found the first change:
1.
Resultcannot read a bead whose metadata holds anything but strings. bd types what--set-metadatais given:Metadata map[string]stringfails on that object, andResultthen answers "bd show answered nothing that can be read" for a task that is closed and has its notes. The one work bead the city has (sa-6s6) holds onlygc.routed_to, a string, so it does not bite today; it does the first time gc or a person puts a count or a flag on a task. Decode the values loosely (map[string]anyor raw) and takegc.work_outcomewhen it is a string; a test with a number beside it.2.
Failcan abandon a task that is not the session's. With no claimed task in the session's mark,Failclaims one on its behalf. That is right for a session that never claimed. It is wrong for one that has finished: afterdonethe mark is empty and the session is still Running until gc stops it, so a timeout that falls in that gap makesFailrungc hook --claim, and whatever task waits in the pool for the next worker is taken and closed as abandoned, "timed out". The same pair, the other way round: the worker'sdoneand the watch'sFailat one moment both runfinishon one task, and the lastbd updatewins, which may be the reason over the worker's result.Both go with one thing:
Done,ClaimandFailof a session one at a time, and a record that the session's task is over (set wherefinishclears the claimed mark), on whichFailonly asks gc to end the session. Tests for each: aFailafterdoneclaims nothing; aFailbeside adoneleaves the result.3. The README.
task_timeoutandfailed_turnsare in no page. They belong in "The room's tools for an agent" (on main since #94), besidetools: the two keys, the default of three for an agent withclaim, what a failed turn is, and what the foreman then sees (waitfires,resultis closed with outcomeabandonedand the reason as its notes).As you see fit:
turnsandendedkeep an entry for every session name the server ever saw. Drop a session's when it is ended.EndAswith ahowof its own; say in the pull request if it is left.no-opfordone: no objection from the code's side; it is specs-18's to accept, and I pass it on.Rebase over main (
12763daisRelease 0.10.0's parent; the changelog'sAddedyou add to is now under 0.10.0, and your line belongs under Unreleased).009fa5c6c219a675de12Read at
19a675d. Green here under-race,internal/taskwatchandinternal/gcworktwenty times withGOMAXPROCS=1. The three changes are in and hold: metadata decoded loosely, one lock for a session over Claim, Done and Fail, the over mark (a start clears a session's marks, so it does not outlive the start it speaks of), the README.One more, found by running what
finishnow does:donewith a long first line that is not ASCII cannot close its task.firstLinecuts at byte 200, and a cut inside a character makes the close reason invalid UTF-8, which bd's store refuses. On bd 1.3.4, a reason of 199aand thenя, cut at 200:By then
bd updatehas stored the notes, the close fails,Donereturns the error to the worker, and every repetition fails the same way: the task stays open and claimed. The owner writes Russian, so a worker's result will be Cyrillic sooner than later, and half of all cuts in Cyrillic land inside a character. Cut by runes (and the reason ofFail, which carries the model's error text, goes through the same close: keep it valid too). A test with a first line of 300 Cyrillic letters, asserting the reason is valid UTF-8.As you see fit: in
finish, set the over mark before clearing the claimed one. Between the two writes as they stand, a failure leaves a session with neither, which is the stateFailtakes for "never claimed".Rebase over main
547f41b: #95 added### Addedunder Unreleased and a key to[agents.<name>].19a675de1218bcb700a1mikluko referenced this pull request2026-11-16 11:11:44 +00:00