slack: drop the working pill when a codex turn ends (task_complete)#86
Merged
Conversation
Codex writes a `task_complete` event_msg to its rollout the moment a turn finishes; the assistant's final text is the `agent_message` immediately before it. Until now the bridge only watched for the out-of-credits flavour of task_complete (last_agent_message == null), so a normal completed turn left the working pill lit on the assistant's last post forever. The refresh loop kept re-setting it every minute, so the channel showed "is working…" on a turn that ended hours ago. Two paths cover the in-batch and cross-batch cases: 1. format.ts: when a non-out-of-credits task_complete lands in the same poll batch as the final agent_message, mark that text post terminal. The bridge's existing terminal-text path then skips the new pill and the previous anchor's pill is cleared in the normal flow. This is the common case — agent_message and task_complete are written back-to-back in the rollout, so a single poll tick sees both. 2. bridge.ts: cross-batch safety net. If a poll tick sees a task_complete but emits no terminal text (because the agent_message was already posted in a prior tick), clear the active pill directly. The refresh loop would otherwise re-light it on the assistant's post indefinitely.
3 tasks
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
Codex writes a
task_completeevent_msg to its rollout the moment a turn finishes; the assistant's final text is theagent_messageimmediately before it. The bridge only watched for the out-of-credits flavour oftask_complete(wherelast_agent_message == null), so any normal completed turn left the working pill lit on the assistant's last post forever — the refresh loop kept re-setting it every minute and the channel showed "is working…" on a turn that ended hours ago.Two paths cover the in-batch and cross-batch cases:
format.ts: when a non-out-of-creditstask_completelands in the same poll batch as the finalagent_message, mark that text post terminal. The bridge's existing terminal-text path skips the new pill and the previous anchor's pill is cleared in the normal flow. This is the common case —agent_messageandtask_completeare written back-to-back in the rollout, so a single poll tick sees both.bridge.ts: cross-batch safety net. If a poll tick sees atask_completebut emits no terminal text (because theagent_messagewas already posted in a prior tick), clear the active pill directly.Test plan
agents-slack-bridge.service.pollMsof the agent's last text post.clear pill on codex task_completeerrors injournalctl -u agents-slack-bridge.service.