Payload
{
"action": "labeled",
"issue": {
"url": "https://api.github.com/repos/darkmatter/nixmac/issues/398",
"repository_url": "https://api.github.com/repos/darkmatter/nixmac",
"labels_url": "https://api.github.com/repos/darkmatter/nixmac/issues/398/labels{/name}",
"comments_url": "https://api.github.com/repos/darkmatter/nixmac/issues/398/comments",
"events_url": "https://api.github.com/repos/darkmatter/nixmac/issues/398/events",
"html_url": "https://github.com/darkmatter/nixmac/issues/398",
"id": 4642233804,
"node_id": "I_kwDOSB6EzM8AAAABFLLdzA",
"number": 398,
"title": "Evolution agent: add stop heuristics and ask-before-continuing gate on repeated bad edits",
"user": {
"login": "czxtm",
"id": 1325802,
"node_id": "MDQ6VXNlcjEzMjU4MDI=",
"avatar_url": "https://avatars.githubusercontent.com/u/1325802?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/czxtm",
"html_url": "https://github.com/czxtm",
"followers_url": "https://api.github.com/users/czxtm/followers",
"following_url": "https://api.github.com/users/czxtm/following{/other_user}",
"gists_url": "https://api.github.com/users/czxtm/gists{/gist_id}",
"starred_url": "https://api.github.com/users/czxtm/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/czxtm/subscriptions",
"organizations_url": "https://api.github.com/users/czxtm/orgs",
"repos_url": "https://api.github.com/users/czxtm/repos",
"events_url": "https://api.github.com/users/czxtm/events{/privacy}",
"received_events_url": "https://api.github.com/users/czxtm/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
},
"labels": [
{
"id": 10865918433,
"node_id": "LA_kwDOSB6EzM8AAAACh6jB4Q",
"url": "https://api.github.com/repos/darkmatter/nixmac/labels/Improvement",
"name": "Improvement",
"color": "ededed",
"default": false,
"description": null
}
],
"state": "open",
"locked": false,
"assignees": [],
"milestone": null,
"comments": 1,
"created_at": "2026-06-11T16:10:34Z",
"updated_at": "2026-06-11T16:10:36Z",
"closed_at": null,
"assignee": null,
"author_association": "MEMBER",
"issue_field_values": [],
"type": null,
"active_lock_reason": null,
"sub_issues_summary": {
"total": 0,
"completed": 0,
"percent_completed": 0
},
"issue_dependencies_summary": {
"blocked_by": 0,
"total_blocked_by": 0,
"blocking": 0,
"total_blocking": 0
},
"body": "## Context\n\nRaised in #nixmac by Scott McMaster (June 9, 2026) and confirmed by Farhan as a ticket worth filing:\n\n> \"now that we have token limits instead of iteration limits, I've seen several instances of the agent rabbit-holing on bad edit commands which it now has no easy escape from and so we spin and spin and burn the user's tokens. We should probably think about some additional heuristics for when we want to stop an evolution, or at least ask the user if it wants us to continue trying (like we do with build checks).\"\n\nFarhan's response: \"+1 on stop heuristics regardless — especially an ask-before-continuing gate like build checks when we see repeated bad edits / token burn. I'll write that ticket up.\"\n\nThis is separate from darkmatter/nixmac#262 (which handled the hard-error-after-max-retries case). This issue covers the *heuristic detection* of when an agent is stuck and should pause to ask before continuing.\n\n## Scope\n\n* Detect when the agent is repeating the same failed edit tool calls (e.g., same `edit_nix_file` call failing N times in a row)\n* When heuristic fires: pause evolution and surface a \"The agent seems to be having difficulty. Keep going?\" prompt, similar to the build-check gate\n* Consider: repeated identical error patterns, high token consumption with low forward progress, N consecutive failed tool calls\n* Do NOT hard-error; preserve context so the user can continue or abandon\n\n---\n\n## Acceptance Criteria / Gherkin Specs\n\n```gherkin\nScenario: Agent pauses and prompts user after repeated identical edit failures\n Given an evolution is running\n And the agent has failed the same edit_nix_file call 3 or more consecutive times\n When the next iteration would continue\n Then evolution pauses\n And a prompt appears: \"The agent seems stuck. Continue trying or abandon?\"\n And the user can choose to continue or stop without losing the current context\n\nScenario: Agent pauses when token burn is high with no forward progress\n Given an evolution is running\n And token consumption has crossed a configurable threshold\n And no successful edit has been made in the last N iterations\n When the next iteration would continue\n Then evolution pauses and asks the user whether to keep going\n\nScenario: Normal evolution is not interrupted\n Given an evolution is making forward progress (successful edits each round)\n When token usage is within normal bounds\n Then evolution continues without interruption\n```",
"reactions": {
"url": "https://api.github.com/repos/darkmatter/nixmac/issues/398/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
},
"timeline_url": "https://api.github.com/repos/darkmatter/nixmac/issues/398/timeline",
"performed_via_github_app": {
"id": 1658531,
"client_id": "Iv23lia2it3rsjIhboVE",
"slug": "linear-code",
"node_id": "A_kwHOAshhgs4AGU6j",
"owner": {
"login": "linear",
"id": 46686594,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjQ2Njg2NTk0",
"avatar_url": "https://avatars.githubusercontent.com/u/46686594?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/linear",
"html_url": "https://github.com/linear",
"followers_url": "https://api.github.com/users/linear/followers",
"following_url": "https://api.github.com/users/linear/following{/other_user}",
"gists_url": "https://api.github.com/users/linear/gists{/gist_id}",
"starred_url": "https://api.github.com/users/linear/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/linear/subscriptions",
"organizations_url": "https://api.github.com/users/linear/orgs",
"repos_url": "https://api.github.com/users/linear/repos",
"events_url": "https://api.github.com/users/linear/events{/privacy}",
"received_events_url": "https://api.github.com/users/linear/received_events",
"type": "Organization",
"user_view_type": "public",
"site_admin": false
},
"name": "Linear Code",
"description": "",
"external_url": "https://linear.app",
"html_url": "https://github.com/apps/linear-code",
"created_at": "2025-07-24T11:29:06Z",
"updated_at": "2026-04-14T21:31:51Z",
"permissions": {
"actions": "write",
"checks": "read",
"contents": "write",
"deployments": "read",
"issues": "write",
"members": "read",
"merge_queues": "read",
"metadata": "read",
"pull_requests": "write",
"statuses": "read",
"workflows": "write"
},
"events": [
"check_run",
"check_suite",
"commit_comment",
"issues",
"issue_comment",
"member",
"membership",
"organization",
"pull_request",
"pull_request_review",
"pull_request_review_comment",
"pull_request_review_thread",
"repository",
"status",
"sub_issues",
"team",
"team_add"
]
},
"state_reason": null,
"pinned_comment": null
},
"label": {
"id": 10865918433,
"node_id": "LA_kwDOSB6EzM8AAAACh6jB4Q",
"url": "https://api.github.com/repos/darkmatter/nixmac/labels/Improvement",
"name": "Improvement",
"color": "ededed",
"default": false,
"description": null
},
"repository": {
"id": 1209959628,
"node_id": "R_kgDOSB6EzA",
"name": "nixmac",
"full_name": "darkmatter/nixmac",
"private": false,
"owner": {
"login": "darkmatter",
"id": 17834193,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE3ODM0MTkz",
"avatar_url": "https://avatars.githubusercontent.com/u/17834193?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/darkmatter",
"html_url": "https://github.com/darkmatter",
"followers_url": "https://api.github.com/users/darkmatter/followers",
"following_url": "https://api.github.com/users/darkmatter/following{/other_user}",
"gists_url": "https://api.github.com/users/darkmatter/gists{/gist_id}",
"starred_url": "https://api.github.com/users/darkmatter/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/darkmatter/subscriptions",
"organizations_url": "https://api.github.com/users/darkmatter/orgs",
"repos_url": "https://api.github.com/users/darkmatter/repos",
"events_url": "https://api.github.com/users/darkmatter/events{/privacy}",
"received_events_url": "https://api.github.com/users/darkmatter/received_events",
"type": "Organization",
"user_view_type": "public",
"site_admin": false
},
"html_url": "https://github.com/darkmatter/nixmac",
"description": "Home manager and nix-darwin that understands plain English",
"fork": false,
"url": "https://api.github.com/repos/darkmatter/nixmac",
"forks_url": "https://api.github.com/repos/darkmatter/nixmac/forks",
"keys_url": "https://api.github.com/repos/darkmatter/nixmac/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/darkmatter/nixmac/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/darkmatter/nixmac/teams",
"hooks_url": "https://api.github.com/repos/darkmatter/nixmac/hooks",
"issue_events_url": "https://api.github.com/repos/darkmatter/nixmac/issues/events{/number}",
"events_url": "https://api.github.com/repos/darkmatter/nixmac/events",
"assignees_url": "https://api.github.com/repos/darkmatter/nixmac/assignees{/user}",
"branches_url": "https://api.github.com/repos/darkmatter/nixmac/branches{/branch}",
"tags_url": "https://api.github.com/repos/darkmatter/nixmac/tags",
"blobs_url": "https://api.github.com/repos/darkmatter/nixmac/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/darkmatter/nixmac/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/darkmatter/nixmac/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/darkmatter/nixmac/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/darkmatter/nixmac/statuses/{sha}",
"languages_url": "https://api.github.com/repos/darkmatter/nixmac/languages",
"stargazers_url": "https://api.github.com/repos/darkmatter/nixmac/stargazers",
"contributors_url": "https://api.github.com/repos/darkmatter/nixmac/contributors",
"subscribers_url": "https://api.github.com/repos/darkmatter/nixmac/subscribers",
"subscription_url": "https://api.github.com/repos/darkmatter/nixmac/subscription",
"commits_url": "https://api.github.com/repos/darkmatter/nixmac/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/darkmatter/nixmac/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/darkmatter/nixmac/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/darkmatter/nixmac/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/darkmatter/nixmac/contents/{+path}",
"compare_url": "https://api.github.com/repos/darkmatter/nixmac/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/darkmatter/nixmac/merges",
"archive_url": "https://api.github.com/repos/darkmatter/nixmac/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/darkmatter/nixmac/downloads",
"issues_url": "https://api.github.com/repos/darkmatter/nixmac/issues{/number}",
"pulls_url": "https://api.github.com/repos/darkmatter/nixmac/pulls{/number}",
"milestones_url": "https://api.github.com/repos/darkmatter/nixmac/milestones{/number}",
"notifications_url": "https://api.github.com/repos/darkmatter/nixmac/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/darkmatter/nixmac/labels{/name}",
"releases_url": "https://api.github.com/repos/darkmatter/nixmac/releases{/id}",
"deployments_url": "https://api.github.com/repos/darkmatter/nixmac/deployments",
"created_at": "2026-04-14T00:37:13Z",
"updated_at": "2026-06-10T15:32:59Z",
"pushed_at": "2026-06-11T15:18:40Z",
"git_url": "git://github.com/darkmatter/nixmac.git",
"ssh_url": "git@github.com:darkmatter/nixmac.git",
"clone_url": "https://github.com/darkmatter/nixmac.git",
"svn_url": "https://github.com/darkmatter/nixmac",
"homepage": "https://nixmac.com",
"size": 681542,
"stargazers_count": 5,
"watchers_count": 5,
"language": "Rust",
"has_issues": true,
"has_projects": false,
"has_downloads": true,
"has_wiki": false,
"has_pages": true,
"has_discussions": false,
"forks_count": 1,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 90,
"license": {
"key": "mit",
"name": "MIT License",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit",
"node_id": "MDc6TGljZW5zZTEz"
},
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"has_pull_requests": true,
"pull_request_creation_policy": "all",
"topics": [
"home-manager",
"nix",
"nix-darwin",
"nix-flake",
"opencode"
],
"visibility": "public",
"forks": 1,
"open_issues": 90,
"watchers": 5,
"default_branch": "develop",
"custom_properties": {}
},
"organization": {
"login": "darkmatter",
"id": 17834193,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjE3ODM0MTkz",
"url": "https://api.github.com/orgs/darkmatter",
"repos_url": "https://api.github.com/orgs/darkmatter/repos",
"events_url": "https://api.github.com/orgs/darkmatter/events",
"hooks_url": "https://api.github.com/orgs/darkmatter/hooks",
"issues_url": "https://api.github.com/orgs/darkmatter/issues",
"members_url": "https://api.github.com/orgs/darkmatter/members{/member}",
"public_members_url": "https://api.github.com/orgs/darkmatter/public_members{/member}",
"avatar_url": "https://avatars.githubusercontent.com/u/17834193?v=4",
"description": ""
},
"enterprise": {
"id": 469843,
"slug": "darkmatter",
"name": "darkmatter",
"node_id": "E_kgDOAAcrUw",
"avatar_url": "https://avatars.githubusercontent.com/b/469843?v=4",
"description": "",
"website_url": "darkmatter.io",
"html_url": "https://github.com/enterprises/darkmatter",
"created_at": "2025-09-07T16:01:00Z",
"updated_at": "2026-06-07T16:53:26Z"
},
"sender": {
"login": "czxtm",
"id": 1325802,
"node_id": "MDQ6VXNlcjEzMjU4MDI=",
"avatar_url": "https://avatars.githubusercontent.com/u/1325802?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/czxtm",
"html_url": "https://github.com/czxtm",
"followers_url": "https://api.github.com/users/czxtm/followers",
"following_url": "https://api.github.com/users/czxtm/following{/other_user}",
"gists_url": "https://api.github.com/users/czxtm/gists{/gist_id}",
"starred_url": "https://api.github.com/users/czxtm/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/czxtm/subscriptions",
"organizations_url": "https://api.github.com/users/czxtm/orgs",
"repos_url": "https://api.github.com/users/czxtm/repos",
"events_url": "https://api.github.com/users/czxtm/events{/privacy}",
"received_events_url": "https://api.github.com/users/czxtm/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
},
"installation": {
"id": 131074261,
"node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uMTMxMDc0MjYx"
}
}