Skip to content

slack: drop the working pill when a codex turn ends (task_complete)#86

Merged
rogeriochaves merged 1 commit into
mainfrom
fix/codex-turn-end-pill
Jun 6, 2026
Merged

slack: drop the working pill when a codex turn ends (task_complete)#86
rogeriochaves merged 1 commit into
mainfrom
fix/codex-turn-end-pill

Conversation

@rogeriochaves

Copy link
Copy Markdown
Contributor

Summary

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. The bridge only watched for the out-of-credits flavour of task_complete (where last_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:

  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 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.

Test plan

  • All 242 existing CLI tests pass.
  • Deploy to the dev box, restart agents-slack-bridge.service.
  • Trigger a normal pr-reviewer turn end to end via Slack. The "is working…" pill clears within pollMs of the agent's last text post.
  • No clear pill on codex task_complete errors in journalctl -u agents-slack-bridge.service.

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.
@rogeriochaves rogeriochaves merged commit e9f55d1 into main Jun 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant