Skip to content

feat!: migrate personas to the relay SDK AgentEvent (Unit C, agents codemod)#56

Merged
khaliqgant merged 2 commits into
mainfrom
feat/relay-runtime-v4
Jun 10, 2026
Merged

feat!: migrate personas to the relay SDK AgentEvent (Unit C, agents codemod)#56
khaliqgant merged 2 commits into
mainfrom
feat/relay-runtime-v4

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Jun 9, 2026

Copy link
Copy Markdown
Member

Paired with @agentworkforce/runtime v4 (AgentWorkforce/workforce#220), which delivers the relay SDK AgentEvent to handlers instead of the old { source, type, payload } shape.

Per-persona migration

  • cron-only (hn-monitor, spotify-releases, vendor-monitor): event.source==='cron'isCronTickEvent(event)
  • granola: event.payload(await event.expand('full')).data
  • repo-hygiene / review: source guard dropped (narrowed by triggers); event.type checks now provider-qualified (github.pull_request.opened, …); payload expanded once and passed to the existing unknown-typed helpers
  • linear-slack: source guard → event.type.startsWith('slack.'); payload via expand
  • linear: handleLinearEvent expands once and threads payload through helpers; all linear.* type strings provider-qualified
  • cloud-team-{implementer,reviewer}: source/type logging off the SDK event
  • tests: linear / linear-slack fixtures rebuilt via envelopeToAgentEvent

Bumps @agentworkforce/{runtime,persona-kit} to ^4.0.0.

Verification

  • tsc --noEmit: 0 errors — the new define-agent narrowing turned the formerly-silent event.type suffix mismatches into compile errors (caught every site).
  • All 60 persona tests pass against the v4 runtime.

Note: v4 isn't published yet, so local verification overlaid the v4 runtime/persona-kit builds into node_modules. CI here should go green once workforce#220 publishes v4. Merge after workforce#220.

🤖 Generated with Claude Code


Summary by cubic

Migrates all personas to the relay SDK AgentEvent in @agentworkforce/runtime v4. Handlers now use provider-qualified event.type, read payload via await event.expand('full'), and use isCronTickEvent(event) for schedules.

  • Migration

    • Dropped source guards; switched to provider-qualified types (e.g., github.pull_request.opened, slack.message.created, linear.issue.create).
    • Read payload once via (await event.expand('full')).data and thread through helpers (granola, linear, repo-hygiene, review).
    • Linear: single expand; own-event checks and type strings updated (e.g., linear.comment.create, linear.AppUserNotification.issueCommentMention).
    • Slack: event.type.startsWith('slack.') gate; payload via expand.
    • Cron-only personas use isCronTickEvent(event) (hn-monitor, spotify-releases, vendor-monitor).
    • Cloud-team personas log source via event.resource.provider (cron fallback).
    • Tests rebuilt to use envelopeToAgentEvent.
  • Dependencies

    • Bumped @agentworkforce/runtime and @agentworkforce/persona-kit to v4 (resolves to 4.0.1; pulls in @agent-relay/events).
    • Verified on published v4: tsc clean (0 errors) and all 60 persona tests pass.

Written for commit b86f6da. Summary will update on new commits.

Review in cubic

…odemod)

Paired with @agentworkforce/runtime v4, which delivers the relay SDK AgentEvent
to handlers instead of the old { source, type, payload } shape.

Per-persona migration:
- cron-only (hn-monitor, spotify-releases, vendor-monitor): event.source==='cron'
  → isCronTickEvent(event)
- granola: event.payload → (await event.expand('full')).data
- repo-hygiene / review: event.source guard dropped (narrowed by triggers);
  event.type checks now provider-qualified (github.pull_request.opened, …);
  payload read once via expand and passed to the existing unknown-typed helpers
- linear-slack: source guard → event.type.startsWith('slack.'); payload via expand
- linear: handleLinearEvent expands once and threads the payload through its
  helpers; all linear.* type strings provider-qualified
- cloud-team-{implementer,reviewer}: source/type logging off the SDK event
- tests: linear/linear-slack event fixtures rebuilt via envelopeToAgentEvent

Bumps @agentworkforce/{runtime,persona-kit} to ^4.0.0. Verified: tsc --noEmit
clean (0 errors — the new define-agent narrowing turned the formerly-silent
event.type suffix mismatches into compile errors) and all 60 persona tests pass
against the v4 runtime.

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

codeant-ai Bot commented Jun 9, 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 9, 2026

Copy link
Copy Markdown

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 33 minutes and 10 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: bc8ac053-7e6e-4b31-a8a2-b79d1699da2a

📥 Commits

Reviewing files that changed from the base of the PR and between c9f05d9 and b86f6da.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (13)
  • cloud-team-implementer/agent.ts
  • cloud-team-reviewer/agent.ts
  • granola/agent.ts
  • hn-monitor/agent.ts
  • linear-slack/agent.ts
  • linear/agent.ts
  • package.json
  • repo-hygiene/agent.ts
  • review/agent.ts
  • spotify-releases/agent.ts
  • tests/linear-agent.test.mjs
  • tests/linear-slack-agent.test.mjs
  • vendor-monitor/agent.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/relay-runtime-v4

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 #56 in AgentWorkforce/agents.
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: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed.

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

@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 upgrades the workspace agents to version 4.0.0 of the @agentworkforce/runtime and @agentworkforce/persona-kit packages. Key changes include migrating from synchronous event.payload to asynchronous event.expand('full') for retrieving provider payloads, replacing WorkforceProviderEvent with WorkforceEvent, and updating event source and type checks to use provider-qualified prefixes or the isCronTickEvent helper. Feedback on these changes suggests adding optional chaining when accessing event.resource.provider in unexpected event handlers to prevent potential runtime crashes, and optimizing the Linear event handler by verifying the event type before invoking the asynchronous expand call.

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.

eventId: event.id,
source: event.source,
type: 'type' in event ? event.type : undefined
source: isCronTickEvent(event) ? 'cron' : event.resource.provider,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Since handleUnexpectedEvent is specifically designed to handle unexpected or malformed events, we should not assume that event.resource is defined or has a provider property. Accessing event.resource.provider directly could throw a TypeError and crash the logging/handling flow. Use optional chaining to safely access the provider.

Suggested change
source: isCronTickEvent(event) ? 'cron' : event.resource.provider,
source: isCronTickEvent(event) ? 'cron' : event.resource?.provider,

eventId: event.id,
source: event.source,
type: 'type' in event ? event.type : undefined
source: isCronTickEvent(event) ? 'cron' : event.resource.provider,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Since handleUnexpectedEvent is specifically designed to handle unexpected or malformed events, we should not assume that event.resource is defined or has a provider property. Accessing event.resource.provider directly could throw a TypeError and crash the logging/handling flow. Use optional chaining to safely access the provider.

Suggested change
source: isCronTickEvent(event) ? 'cron' : event.resource.provider,
source: isCronTickEvent(event) ? 'cron' : event.resource?.provider,

Comment thread linear/agent.ts
Comment on lines +79 to 93
// v4: the provider payload is reached via expand (no sync `event.payload`).
const payload = (await event.expand('full')).data;
ctx.log?.('info', 'linear event', {
eventId: event.id,
type: event.type,
payloadKeys: payloadKeys(event.payload),
recordKeys: payloadKeys(linearRecordPayload(event.payload)),
hasIssueId: Boolean(readIssueId(event.payload, event.type)),
hasSessionId: Boolean(readSessionId(event.payload)),
payloadKeys: payloadKeys(payload),
recordKeys: payloadKeys(linearRecordPayload(payload)),
hasIssueId: Boolean(readIssueId(payload, event.type)),
hasSessionId: Boolean(readSessionId(payload)),
});

if (event.source !== 'linear') {
if (!event.type.startsWith('linear.')) {
logSkip(ctx, event, 'non-linear event source');
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The event is expanded via await event.expand('full') before checking if the event is actually a Linear event. For non-Linear events (such as cron or other providers), this performs an unnecessary and potentially expensive network/database call to expand the event, and then logs attributes that might not exist or make sense. Moving the type check to the top of the function avoids this overhead.

Suggested change
// v4: the provider payload is reached via expand (no sync `event.payload`).
const payload = (await event.expand('full')).data;
ctx.log?.('info', 'linear event', {
eventId: event.id,
type: event.type,
payloadKeys: payloadKeys(event.payload),
recordKeys: payloadKeys(linearRecordPayload(event.payload)),
hasIssueId: Boolean(readIssueId(event.payload, event.type)),
hasSessionId: Boolean(readSessionId(event.payload)),
payloadKeys: payloadKeys(payload),
recordKeys: payloadKeys(linearRecordPayload(payload)),
hasIssueId: Boolean(readIssueId(payload, event.type)),
hasSessionId: Boolean(readSessionId(payload)),
});
if (event.source !== 'linear') {
if (!event.type.startsWith('linear.')) {
logSkip(ctx, event, 'non-linear event source');
return;
}
if (!event.type.startsWith('linear.')) {
logSkip(ctx, event, 'non-linear event source');
return;
}
// v4: the provider payload is reached via expand (no sync event.payload).
const payload = (await event.expand('full')).data;
ctx.log?.('info', 'linear event', {
eventId: event.id,
type: event.type,
payloadKeys: payloadKeys(payload),
recordKeys: payloadKeys(linearRecordPayload(payload)),
hasIssueId: Boolean(readIssueId(payload, event.type)),
hasSessionId: Boolean(readSessionId(payload)),
});

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #56 in AgentWorkforce/agents.
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: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed.

pr-reviewer could not complete review for #56 in AgentWorkforce/agents.
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 #56 in AgentWorkforce/agents.
The review harness exited with code 1.
No review was posted; this needs operator attention.

1 similar comment
@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #56 in AgentWorkforce/agents.
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: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed.

pr-reviewer could not complete review for #56 in AgentWorkforce/agents.
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 #56 in AgentWorkforce/agents.
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: review only — no file changes were applied to the PR (nothing to commit after review). The notes below are advisory and were not pushed.

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

Regenerated against the published v4 line (4.0.1, which includes the no-trigger
narrowing fix). Pulls in @agent-relay/events as a transitive runtime dep.

Verified against the real published packages: tsc --noEmit clean (0 errors),
all 60 persona tests pass.

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.

@agent-relay-code

Copy link
Copy Markdown
Contributor

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

1 similar comment
@agent-relay-code

Copy link
Copy Markdown
Contributor

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

@khaliqgant khaliqgant merged commit 946c200 into main Jun 10, 2026
2 checks passed
@khaliqgant khaliqgant deleted the feat/relay-runtime-v4 branch June 10, 2026 07:26
@agent-relay-code

Copy link
Copy Markdown
Contributor

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

3 similar comments
@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #56 in AgentWorkforce/agents.
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 #56 in AgentWorkforce/agents.
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 #56 in AgentWorkforce/agents.
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