Skip to content

docs(proactive-agents): rewrite cron/radio guards as positive conditions#953

Merged
khaliqgant merged 3 commits into
mainfrom
docs/proactive-agents-readability-fix
May 24, 2026
Merged

docs(proactive-agents): rewrite cron/radio guards as positive conditions#953
khaliqgant merged 3 commits into
mainfrom
docs/proactive-agents-readability-fix

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

Summary

Follow-up to #952. The rendered code block ligatures `!==` into a glyph where the `!` is nearly invisible — readers see `event.source = 'cron'` and reasonably conclude the guard fires on cron rather than gating for it. Same problem in the Integration-based example.

Before:
```ts
if (event.source !== 'cron' || event.name !== 'daily') return;
const digest = await summarizeOvernightShips(ctx);
await ctx.slack!.post('ops-daily', digest);
```

After:
```ts
if (event.source === 'cron' && event.name === 'daily') {
const digest = await summarizeOvernightShips(ctx);
await ctx.slack!.post('ops-daily', digest);
}
```

Benefits:

  • No `!==` to misrender.
  • The happy path is what reads naturally for a newcomer.
  • Matches the style already used in the Combined example further down the same page.

Added one sentence after the cron example noting the intentional choice — important once a single handler reacts to multiple listener kinds.

Test plan

  • Edits are isolated to two code blocks + one sentence of prose
  • Visual check of the rendered page locally before merge

🤖 Generated with Claude Code

The cron and integration examples both used `if (a !== x || b !== y) return;`
early-return guards. The mono font used in the rendered code block
ligatures `!==` into a glyph where the `!` is nearly invisible — readers
saw `event.source = 'cron'` and reasonably concluded the guard fires
*on* cron rather than gating *for* it.

Flipped both to `if (a === x && b === y) { ... }` so:
- No `!==` to misrender.
- The happy path is what reads naturally.
- The intent is the same; the dispatch handler in the Combined example
  already uses this style.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fec9e5ff-706a-4ba2-9e0f-54907ce02863

📥 Commits

Reviewing files that changed from the base of the PR and between 31bbb1c and c79b96b.

📒 Files selected for processing (1)
  • web/content/docs/proactive-agents.mdx

📝 Walkthrough

Walkthrough

Two TypeScript handler examples in the proactive agents docs were changed to use positive conditional blocks instead of early-return guards: the cron/digest example now runs inline harness execution, posts to Slack, and saves memory on success; the GitHub issue listener now wraps payload extraction and commenting in an explicit conditional.

Changes

Proactive Agent Handler Examples

Layer / File(s) Summary
Cron listener: inline harness, Slack post, save memory
web/content/docs/proactive-agents.mdx
Replaces an early-return guard with if (event.source === 'cron' && event.name === 'daily') and shows inline ctx.harness.run(...) usage with exit-code and empty-output checks, Slack posting of the formatted digest, and ctx.memory.save(...) to store the posted digest.
GitHub listener: positive conditional for issue.created
web/content/docs/proactive-agents.mdx
Replaces an early-return guard with if (event.source === 'github' && event.type === 'issue.created') wrapping payload extraction and the ctx.github!.comment(...) call.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • AgentWorkforce/relay#952: Introduces the proactive agents documentation page and the original agent.ts examples that this PR refactors.

Suggested reviewers

  • willwashburn

Poem

🐰 A tiny patch hops into the light,
Conditions flipped to guard the day and night—
Cron runs the harness, posts the tidy thread,
Memory keeps the gist of what it said.
🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: rewriting cron/radio guards as positive conditions in the proactive-agents documentation.
Description check ✅ Passed The description provides context (reference to #952, rendering issue), before/after code examples, clear benefits, and notes changes made; however, the Test Plan section is incomplete (visual check marked as pending).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/proactive-agents-readability-fix

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

web/content/docs/proactive-agents.mdx

Parsing error: Expression expected.


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.

Previous version handwaved with `summarizeOvernightShips(ctx) // your code`
— readers saw the dispatch shape but not what the inside of a handler
actually looks like, which is where the interesting `ctx` surface lives.

Replaced with a real ~18-line implementation that exercises:
- ctx.persona.inputs for deploy-time config
- ctx.harness.run for AI work over the Relayfile mount
- ctx.slack.post for delivery (typed integration client)
- ctx.log for structured logging visible in `deployments logs`
- ctx.memory.save for cross-firing persistence

Added a short bullet list immediately under the snippet annotating
each `ctx` call so a first-time reader knows what they're looking at.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

@github-actions
Copy link
Copy Markdown
Contributor

Preview deployed!

Environment URL
Web https://d2pl7oroonb1a.cloudfront.net

This preview will be cleaned up when the PR is merged or closed.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/content/docs/proactive-agents.mdx`:
- Around line 99-100: The docs say ctx.harness.run() returns { output, exitCode,
durationMs } but the example only destructures { output, exitCode }; update the
example where ctx.harness.run is used to destructure all three fields (output,
exitCode, durationMs) so it matches the documented return shape, or
alternatively add a short inline note in the example that durationMs is omitted
because it’s unused; locate the usage of ctx.harness.run and adjust the
destructuring there (e.g., const { output, exitCode, durationMs } = await
ctx.harness.run({...}) or add a parenthetical comment about omitted fields).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e71693de-a4d1-4726-a4b5-8a37bdd96783

📥 Commits

Reviewing files that changed from the base of the PR and between 1206e0f and 31bbb1c.

📒 Files selected for processing (1)
  • web/content/docs/proactive-agents.mdx

Comment thread web/content/docs/proactive-agents.mdx Outdated
CodeRabbit on #953: the prose said `Returns { output, exitCode, durationMs }`
but the example only destructured `{ output, exitCode }`. Reader could
think they had to handle durationMs.

Tightened the prose to list all fields including `usage?` (matches the
HarnessRunResult shape in @agentworkforce/runtime) and added an explicit
"destructure the fields you need" so the example's partial pull is clearly
intentional.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@khaliqgant khaliqgant merged commit f3f3744 into main May 24, 2026
29 checks passed
@khaliqgant khaliqgant deleted the docs/proactive-agents-readability-fix branch May 24, 2026 06:51
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