| name | amcos-agent-termination |
| description | Use when terminating agents or performing clean shutdown. Trigger with agent termination or stop requests. Loaded by ai-maestro-chief-of-staff-main-agent |
| user-invocable | false |
| license | Apache-2.0 |
| compatibility | Requires AI Maestro installed. |
| metadata | {"author":"Emasoft","version":"1.0.0"} |
| context | fork |
| agent | ai-maestro-chief-of-staff-main-agent |
Agent Termination
Overview
Handles clean shutdown of agent instances including work verification, state preservation, termination execution, and registry cleanup. Use when an agent's work is complete, when reclaiming resources, or during cleanup.
Prerequisites
- AI Maestro running,
ai-maestro-agents-management and agent-messaging skills available
- Target agent in RUNNING or HIBERNATED state
- Team registry accessible via REST API
Instructions
Termination Procedure (PROCEDURE 2)
- Request GovernanceRequest approval - Submit termination request to sourceManager via
amcos-permission-management skill. BLOCK until approved. Do NOT proceed without approval.
- Verify work complete - Confirm no pending tasks or uncommitted work
- Save final state - Request agent to save context/progress to handoff file
- Send termination warning via
agent-messaging with hibernation-warning type
- Execute termination via
ai-maestro-agents-management skill (requires confirmation)
- Update registry -
uv run python scripts/amcos_team_registry.py remove-agent
- Cleanup resources - Verify tmux session gone, temp directories cleaned
- Log termination - Record timestamp, reason, outcome in lifecycle log
Graceful vs Forced
| Type | When | Procedure |
|---|
| Graceful | Agent responsive, work done | Full 8-step procedure |
| Forced | Unresponsive 5+ min | Skip steps 2-4, force-terminate tmux |
Always attempt graceful first.
Quality Standards
- Terminated agents MUST be cleaned from registry
- ALWAYS hibernate instead of terminate when agent may be needed again
- ALWAYS save state before termination
- Log every termination per record-keeping
Output
| Step | Expected Output |
|---|
| Termination | tmux session destroyed, process stopped |
| Registry | Agent removed, status "terminated" |
| Cleanup | Resources freed, log entry written |
Error Handling
| Issue | Resolution |
|---|
| Uncommitted work | Request commit/push first. Do NOT proceed until confirmed |
| tmux persists | tmux kill-session -t <name> |
| Registry update fails | Retry 3x, then remove via ai-maestro-agents-management skill |
Examples
Graceful Termination
uv run python scripts/amcos_team_registry.py remove-agent --name ampa-svgbbox-impl
tmux has-session -t ampa-svgbbox-impl 2>/dev/null && echo "RUNNING" || echo "TERMINATED"
Forced Termination
tmux kill-session -t ampa-stuck-agent
uv run python scripts/amcos_team_registry.py remove-agent --name ampa-stuck-agent
Checklist
Copy this checklist and track your progress:
Resources
- record-keeping — Lifecycle logs, registries, session state formats, log queries