Repository navigation
Fix #300: Count worktree file activity toward the idle timeout and keep a killed agent's work - #303
Merged
Merged
Conversation
…and keep a killed agent's partial work Closes #300
…s, and cover the fallback
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #300. On vicgupta/tinyagent the opencode idle timeout killed an agent that was still editing files, and its work was thrown away with the worktree.
.git/, for files that were created, changed (mtime or size) or removed. Any change resets the idle timer, just like output does. The scan runs every quarter of the limit, between 10ms and 30s, so every 30s at the default. It stops when the agent exits and only runs when the idle timeout is on.AMF_AGENT_IDLE_TIMEOUT. The overall agent timeout stays 1h.amf init's template,.env.exampleand help are updated..amf/, and goes to a local-only branchamf/wip/issue-N-<UTC time>(with-2,-3… on a clash). amf prints the branch andgit log -p <default>..<branch>in the log, emits anissue.wipevent, and names it in the failure comment. Nothing is pushed from it and no PR is opened or updated. An agent that changed nothing leaves no WIP branch. If saving fails, amf logs a warning and still reports the timeout.saveWIPBranchnow moves the worktree'samf/issue-Nback to where it was (withreset --soft), so only the WIP branch holds the partial commit.Testing
TestAgentIdleTimeoutCountsFileActivity: an agent that is silent but keeps writing outlives a 600ms limit, and a PR is opened.TestKilledAgentSavesWIP, with idle-timeout and agent-timeout subtests: edits land on the local WIP branch, which isn't on origin. No PR is opened, and the comment and log name the branch.TestKilledPrimaryKeepsWIPThroughFallback: the killed primary's edits survive the fallback's fresh worktree and stay out of the pushed branch and the PR.TestSaveWIPBranchLeavesIssueBranchandTestFileActivityInterval.TestAgentIdleTimeout, where an agent that neither prints nor writes is still stopped and leaves no WIP branch, and the default test now expects 30m.gofmt -lclean;go build ./...,go vet ./...,go vet -tags live ./...,go test -count=1 ./...andgo test -race -count=1 ./cmd/amfall pass.TestHelpFitsEightyColumnspasses.Docs
docs/SPECS.md(the agent Timeout step, failure handling, dry-run note, files table,issue.wipevent),docs/CONFIGURATION.md,docs/TROUBLESHOOTING.md,docs/COMMANDS.md,README.md,.env.example, and theamf runhelp plus theAMF_AGENT_IDLE_TIMEOUTentry.Decisions
git statushashing would cost more to see.worktree removeand the fallback'sworktree add -B, can be inspected with plain git, and can't reach a PR or CI. A Ctrl-C interrupt isn't a kill by amf, so it saves no WIP. The worktree is kept as before.Closes #300