agent-orchestrator icon indicating copy to clipboard operation
agent-orchestrator copied to clipboard

feat: global/project default for terminate-on-merge policy (restore old behavior) [follow-up #2834/#2980]

Open axisrow opened this issue 4 months ago • 8 comments

Follow-up to #2834 / #2980

Follow-up to #2834 (merged-PR sessions leak runtime RAM), shipped via #2980. #2980 introduced a per-session terminate_on_pr_merge policy (column terminate_on_pr_merge, default FALSE, toggle "Terminate on merge" in the session inspector).

Problem

The fix replaced the old default behavior — terminate the worker after its PR merges — with opt-in, per-session termination. There is no global/project default to restore the previous behavior. TerminateOnPRMerge exists only on the session (domain/session.go); neither AgentConfig (user scope) nor ProjectConfig (project scope) carries it.

So a user who relied on the old "merge → worker is done and torn down" flow now has to remember to flip the toggle on every single worker session, every time. There is no way to say "for me / for this project, merged workers should always terminate."

This is concrete for me, not hypothetical: I routinely run dozens of worker sessions. Before #2980 they cleaned themselves up on merge; now each merged worker stays alive until I manually flip the toggle or kill it. I very much want the old automatic cleanup back — flipping a per-session switch across dozens of workers every day is exactly the kind of friction the toggle was meant to avoid, and in practice means merged workers just pile up.

Why this is a UI/UX problem

Good interface design does not make the user repeat the same preference on every instance of an object when that preference has a clear, consistent desired value for that user. A lifecycle policy like "what happens to a worker when its PR merges" is exactly that kind of decision: most users want one answer for it ("always tear down" or "always keep alive"), not a per-session coin flip they must babysit. Forcing a per-session toggle, with the opposite of the prior behavior as the default, is friction that scales linearly with the number of workers spawned.

This is the classic "preference should be settable at the level the user thinks at" rule: the user's mental model is project-wide ("when my workers' PRs merge, clean them up"), not per-session.

Ask

Add a global (and/or project-level) default for the terminate-on-merge policy, so the per-session toggle becomes the exception, not the only way to opt into the old behavior.

Concretely, any one of these would resolve it:

  • A user-scope / project-scope default (AgentConfig / ProjectConfig) that new sessions inherit as their initial terminate_on_pr_merge. The per-session toggle then overrides it.
  • An env var (e.g. AO_TERMINATE_ON_PR_MERGE=1) or TOML key that sets the default for sessions that don't override it.
  • A CLI flag on ao spawn / project add to set the default.

This does not require a new UI surface. A non-UI default (env var, TOML key, or config field) is fully sufficient — the goal is just that the old behavior be restorable without flipping a toggle on every session. A UI control for it is welcome but not required by this request.

Suggested default semantics

Whichever scope carries the default, the resolution should be: per-session value (if explicitly set) > project default > user/global default > hardcoded FALSE. This mirrors the existing override precedence already used for the prompt overrides shipped in the same area, and lets a user pick "always terminate" globally while still exempting a specific session when needed.

/cc @i-trytoohard (reporter of the original #2834) — raising this as the natural follow-up to that work.

axisrow avatar Jul 27 '26 03:07 axisrow

Thanks for contributing to Agent Orchestrator.

This issue is being picked up by the current external contributor on-call pair:

  • @illegalcall
  • @pulkit7070

If someone is already working on this, please continue as usual. The on-call pair is added for visibility, tracking, and support, not to take over the work. If you need help with review, direction, reproduction, or next steps, please tag @illegalcall and @pulkit7070 here.

For faster context or live questions, you can also join the AO Discord.

Join the session here: https://discord.gg/H6ZDcUXmq

Come by if you want to see what is being built, ask questions, or just hang around with the community.

somewherelostt avatar Jul 27 '26 15:07 somewherelostt

@AgentWrapper, a global terminate-on-merge default would be useful, while each session should still be able to override it. Since per-session control already works, this should remain open as P3.

Rishet11 avatar Aug 30 '26 15:08 Rishet11

Assigned to @vansh-choudhary01

Rishet11 avatar Sep 17 '26 09:09 Rishet11

i'll do it.

vansh-choudhary01 avatar Sep 17 '26 12:09 vansh-choudhary01

@codebanditssss I believe @vansh-choudhary01 has not opened any trailing pr for this issue but you have self-assigned it. can you please let me know the status for the issue?

Vaibhaav-Tiwari avatar Oct 27 '26 17:10 Vaibhaav-Tiwari

@Vaibhaav-Tiwari I'd like to work on this if it's available .

bhushan4work avatar Nov 17 '26 11:11 bhushan4work

@Vaibhaav-Tiwari I'd like to work on this if it's available .

Yes you can

vansh-choudhary01 avatar Nov 17 '26 11:11 vansh-choudhary01

thanks for the heads up

bhushan4work avatar Nov 17 '26 11:11 bhushan4work