Skip to content

Event automation dispatches never count toward the automated-turn limit #2002

Closed

Description

@dcramer

packages/junior/src/chat/README.md says:

A conversation also has a consecutive automated-turn limit. Resource-event watches count on the Conversation. Event-task dispatches count on the Destination. After the limit, further automated wakes stay quiet until a user message clears the pause.

The Watch part works. The event-task part does not exist in the code.

What the code does

  • Only the Watch path checks the limit. admitAutomatedTurn is called in one place, events/notification.ts, for the watched Conversation.
  • After a turn, recordFinishedTurnForAutomatedLimit counts automated turns per Conversation (task-execution/conversation-turn.ts and providers/slack/turn.ts).
  • Each dispatch runs in its own Conversation, agent-dispatch:<dispatchId> (getDispatchConversationId in agent-dispatch/store.ts). So each dispatch starts at a count of zero, and the count never builds up for a Destination.
  • No code in event-automations/ or agent-dispatch/ checks or counts the limit for a Destination.

Impact

An event automation whose own work causes new matching Events can keep running. For example, a push from the automation can cause another pull request Event that starts the automation again. The limit that stops this for Watches does not apply.

Expected

Count event-automation dispatches for their Destination, and keep further dispatches quiet after the limit, as the README says. If dispatches should not have this limit, change the README instead.

Tests

No test covers this through the runtime. The existing tests call the limit functions directly (tests/unit/services/automated-turn-limit.test.ts, tests/component/events/events.test.ts).

Found in the test audit for #2001.

Activity

  1. added
    bug
    on Oct 1, 2026
  2. added a commit that references this issue on Oct 9, 2026
    f3e4cda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions