Ik heb net ontdekt hoe ik mijn agentworkflow nog verder kan automatiseren met wat tmux-tovenaarswerk. Nu ik mijn mcp-agentmailproject gebruik om een aantal agents met elkaar te laten praten over het implementeren van een plan (en ook coördineren met behulp van het beads-project voor taakbeheer), moet ik de agents nog steeds "voeden" door een aantal berichten in codex in de wachtrij te zetten om ze bezig te houden. Dit houdt in dat ik één voor één door de verschillende tmux-panes ga (één voor elke codex-instantie) en wat standaardberichten plak of een paar keer op de pijl omhoog druk om eerdere berichten opnieuw te gebruiken, zoals: "Kies de volgende bead die je nu daadwerkelijk nuttig kunt gebruiken en begin er onmiddellijk aan te coderen; communiceer wat je doet naar de andere agents via agentmail." Het voelt een beetje dom en inefficiënt om dit te doen, ook al duurt het niet zo lang om elke agent genoeg instructies te geven om ze meer dan een uur bezig te houden. Maar nu realiseerde ik me dat ik automatisch een aantal berichten in elke relevante tmux-pane tegelijk kan in de wachtrij zetten, gewoon door dit in de console buiten de tmux-sessie te kopiëren en plakken (dit is getest en werkt in zsh): --- PANES=(${(f)"$(tmux list-panes -a -F '#S:#I.#P' | tail -n +3 | head -n -2)"}) for pane in $PANES; do tmux send-keys -t $pane -l 'pick the next bead you can actually do usefully now and start coding on it immediately; communicate what you'"'"'re doing to the other agents via agent mail.' sleep 0.1 tmux send-keys -t $pane Enter for i in {1..4}; do tmux send-keys -t $pane -l 'keep going, doing useful work! and communicate!' sleep 0.1 tmux send-keys -t $pane Enter done tmux send-keys -t $pane -l 'great, now I want you to carefully read over all of the new code you just wrote and other existing code you just modified with "fresh eyes" looking super carefully for any obvious bugs, errors, problems, issues, confusion, etc.' sleep 0.1 tmux send-keys -t $pane Enter tmux send-keys -t $pane -l 'Be sure to check your agent mail and to promptly respond if needed to any messages; thereafter proceed meticulously with the plan, doing all of your remaining unfinished tasks systematically and continuing to notate your progress in-line in the plan document, via beads, and via agent mail messages. Don'"'"'t get stuck in "communication purgatory" where nothing is getting done; be proactive about starting tasks that need to be done, but inform your fellow agents via messages when you do so and notate that in-line in the plan document. When you'"'"'re really not sure what to do, pick the next bead that you can usefully work on and get started.' sleep 0.1 tmux send-keys -t $pane Enter tmux send-keys -t $pane -l 'ok can you now turn your attention to reviewing the code written by your fellow agents and checking for any issues, bugs, errors, problems, inefficiencies, security problems, reliability issues, etc. and carefully diagnose their underlying root causes using first-principle analysis and thereafter fix or revise them if necessary? Dont restrict yourself to the latest commits, cast a wider net and go super deep!' sleep 0.1 tmux send-keys -t $pane Enter done --- Dit script: Krijgt panes: Vindt alle tmux-panes, met uitzondering van de eerste 2 en de laatste 2. Verzendt 8 berichten naar elke geselecteerde pane: "pick the next bead..." - vertelt agents om aan de volgende taak te beginnen. "keep going..." × 4 - herhaalde aanmoediging om door te gaan met werken. "carefully read over..." - instructies voor een frisse codebeoordeling. "check agent mail..." - lang bericht over coördinatie, het vermijden van communicatieparalysie, productief blijven. "review code written by fellow agents..." - peer code review voor bugs/problemen. Elk bericht wordt letterlijk verzonden (-l-vlag) met een vertraging van 0,1 seconde voordat Enter wordt ingedrukt om ervoor te zorgen dat de Codex CLI ze correct verwerkt.
Actually, this is a better way to do it, by filtering on the name of the pane (in my case, it's "node" for the codex panes), and it has the initial 0.1 second sleep, without which it skips the first matching pane without sending the messages correctly: PANES=(${(f)"$(tmux list-panes -a -F '#S:#I.#P #{pane_current_command}' | rg ' node$' | cut -d' ' -f1)"}) for pane in $PANES; do sleep 0.1 # Initial sleep to ensure pane is ready tmux send-keys -t $pane -l 'pick the next bead you can actually do usefully now and start coding on it immediately; communicate what you'"'"'re doing to the other agents via agent mail.' sleep 0.1 tmux send-keys -t $pane Enter for i in {1..4}; do tmux send-keys -t $pane -l 'keep going, doing useful work! and communicate!' sleep 0.1 tmux send-keys -t $pane Enter done tmux send-keys -t $pane -l 'great, now I want you to carefully read over all of the new code you just wrote and other existing code you just modified with "fresh eyes" looking super carefully for any obvious bugs, errors, problems, issues, confusion, etc.' sleep 0.1 tmux send-keys -t $pane Enter tmux send-keys -t $pane -l 'Be sure to check your agent mail and to promptly respond if needed to any messages; thereafter proceed meticulously with the plan, doing all of your remaining unfinished tasks systematically and continuing to notate your progress in-line in the plan document, via beads, and via agent mail messages. Don'"'"'t get stuck in "communication purgatory" where nothing is getting done; be proactive about starting tasks that need to be done, but inform your fellow agents via messages when you do so and notate that in-line in the plan document. When you'"'"'re really not sure what to do, pick the next bead that you can usefully work on and get started.' sleep 0.1 tmux send-keys -t $pane Enter tmux send-keys -t $pane -l 'ok can you now turn your attention to reviewing the code written by your fellow agents and checking for any issues, bugs, errors, problems, inefficiencies, security problems, reliability issues, etc. and carefully diagnose their underlying root causes using first-principle analysis and thereafter fix or revise them if necessary? Dont restrict yourself to the latest commits, cast a wider net and go super deep!' sleep 0.1 tmux send-keys -t $pane Enter done
Je moet misschien de slaaptijd verlengen als je machine traag is. Ik haat hoe kieskeurig het allemaal is; ik ga een betrouwbaardere manier vinden om dit te doen.
25,92K