Skip to content

fix(runtime): no-trigger personas narrow to AgentEvent (v4.0.0 regression) - #221

Merged
khaliqgant merged 1 commit into
mainfrom
fix/relay-no-trigger-narrowing
Jun 10, 2026
Merged

khaliqgant merged 1 commit into
mainfrom
fix/relay-no-trigger-narrowing

Conversation

@khaliqgant

Copy link
Copy Markdown
Member

The bug

v4.0.0 broke any persona that declares no concrete triggers/schedules (e.g. cloud-team member personas launched by a dispatcher). defineAgent's narrowing collapsed their handler event to BaseAgentEvent<${string}.${string}> — narrower than AgentEvent — so an (event: WorkforceEvent) handler no longer typechecks:

Type '(ctx, event: WorkforceEvent) => Promise<void>' is not assignable to
'(ctx, event: ProviderEventFor<string, string>) => void | Promise<void>'

Surfaced when verifying the agents codemod (AgentWorkforce/agents#56) against the published v4.0.0 (my pre-merge verification used an earlier runtime build that predated the BaseAgentEvent change).

The fix

ProviderEventFor falls back to the full AgentEvent when the trigger on union is the wide string (nothing concrete declared), while still mapping declared literals to BaseAgentEvent<${P}.${O}> (incl. 2-segment types like slack.app_mention). Restores pre-v4 behavior for trigger-less personas.

Verification

  • 86 runtime tests pass.
  • The agents repo's cloud-team member personas typecheck clean against the rebuilt runtime (0 errors).

Release

Needs a 4.0.1 patch publish. The agents repo already pins ^4.0.0, so it picks up 4.0.1 on install.

🤖 Generated with Claude Code

…Event

v4.0.0 regression: defineAgent's event narrowing collapsed personas that declare
no concrete trigger literals (e.g. team members launched by a dispatcher) to
`BaseAgentEvent<`${string}.${string}`>`, which is narrower than `AgentEvent` and
rejects an `(event: AgentEvent)`/`WorkforceEvent` handler:

  Type '(ctx, event: WorkforceEvent) => ...' is not assignable to
  '(ctx, event: ProviderEventFor<string, string>) => ...'

ProviderEventFor now falls back to the full `AgentEvent` when the trigger `on`
union is the wide `string` (nothing concrete declared), while still mapping
declared literals to `BaseAgentEvent<`${P}.${O}`>` (incl. 2-segment types like
slack.app_mention). Restores the pre-v4 behavior for trigger-less personas.

86 runtime tests pass; the agents repo's cloud-team member personas typecheck
clean against the rebuilt runtime.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codeant-ai

codeant-ai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Your free trial PR review limit of 300 PRs has been reached. Please upgrade your plan to continue using CodeAnt AI.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@khaliqgant, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 39 minutes and 31 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cfc5cd7d-b198-4a46-b1cd-3ea6723eb971

📥 Commits

Reviewing files that changed from the base of the PR and between 5e19933 and ae0b6c6.

📒 Files selected for processing (1)
  • packages/runtime/src/define-agent.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/relay-no-trigger-narrowing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #221 in AgentWorkforce/workforce.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@khaliqgant
khaliqgant merged commit dcc2aca into main Jun 10, 2026
3 checks passed
@khaliqgant
khaliqgant deleted the fix/relay-no-trigger-narrowing branch June 10, 2026 07:14

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the ProviderEventFor type helper in packages/runtime/src/define-agent.ts to fall back to AgentEvent when the event type O is a wide string. This ensures that handlers typed with AgentEvent remain assignable when a persona declares no concrete trigger literals. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #221 in AgentWorkforce/workforce.
The review harness exited with code 1.
No review was posted; this needs operator attention.

4 similar comments
@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #221 in AgentWorkforce/workforce.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #221 in AgentWorkforce/workforce.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #221 in AgentWorkforce/workforce.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #221 in AgentWorkforce/workforce.
The review harness exited with code 1.
No review was posted; this needs operator attention.

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