Repository navigation
feat(cron): post top-level channel messages from scheduled jobs (ENG-14117) - #45
Conversation
…ply style override (ENG-14117) Implements the last-mile wiring for MS Teams replyStyleOverride mechanism, exposing it to agents via a topLevel parameter on the message tool. Changes: - Add replyStyleOverride parameter through send context chain: - sendMessageMSTeams accepts replyStyleOverride - resolveMSTeamsSendContext passes it through - resolveMSTeamsProactiveReplyStyle honors override with early return - Add topLevel boolean parameter to message tool schema for send and upload-file actions - Mirrors Slack's topLevel API for cross-platform consistency - Supports bidirectional override (force top-level OR force threading) - Accepts threadId: null as equivalent to topLevel: true - Handle topLevel in action handlers: - upload-file: read topLevel param, convert to replyStyleOverride, pass to sendMessageMSTeams - send (non-presentation): explicit handler to support topLevel before outbound fallthrough - send (presentation): no change, presentation cards don't support override - Add tests for replyStyleOverride mechanism: - Test top-level override on thread-default channel - Test thread override on top-level config - Test undefined override (no behavior change) This allows scheduled cron jobs to post top-level channel messages while interactive conversations stay threaded, without changing global config. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…resentation limitation - Fix return type of createMSTeamsTopLevelActionSchema to Record<string, TSchema> - Add explicit type for schema array: ChannelMessageToolSchemaContribution[] - Add satisfies ChannelMessageActionName[] to actions arrays for type safety - Import TSchema and ChannelMessageToolSchemaContribution from channel-contract - Document that topLevel parameter only works for non-presentation sends Fixes TypeScript compilation errors in check-prod-types and check-test-types. Addresses review comment about presentation card limitation by documenting it. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…14117)
Scheduled cron announce output threaded under the session's last message on
channels that thread agent replies (MS Teams), so channel timelines missed
scheduled reports. Add a per-job delivery.replyStyle override so a scheduled
job can post a fresh top-level channel message while conversational replies
keep the channel/global threading default.
- Add CronDelivery.replyStyle ("thread" | "top-level") + --reply-style /
--clear-reply-style CLI flags on cron add/edit, config normalize/merge,
delivery plan/preview, and the gateway RPC schema.
- Add a portable threadSuppressed intent to core ChannelOutboundContext /
DeliverOutboundPayloadsParams; the MS Teams adapter maps it to a per-send
replyStyle:"top-level" override. Presentation cards intentionally ignore it.
- Map replyStyle:"top-level" -> threadSuppressed at both cron send sites:
isolated jobs (delivery-dispatch) and main/current jobs (delivery.ts via
CronAnnounceTarget set in server-cron).
Scheduled-delivery counterpart of the message tool's per-send topLevel param.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 26 files
Tip: instead of fixing issues one by one fix them all with cubic
Re-trigger cubic
- Persist tri-state reply-style intent end to end. threadSuppressed is now true (top-level) / false (force thread) / undefined (channel default); the MS Teams adapter maps false to replyStyleOverride:"thread" so --reply-style thread forces threading even when the channel default is top-level. - mergeCronDelivery: keep replyStyle cleared when the resulting mode is webhook, even if the same patch sets both mode and replyStyle. - cron add: reject --reply-style on main/system-event jobs that build no delivery object (mirrors --account/--thread-id). - delivery preview: only show the top-level suffix for announce plans. - cron agent tool schema + help: expose delivery.replyStyle so scheduling agents can discover it. - types: trim CronReplyStyle JSDoc to the module comment limit. - tests: dispatchCronDelivery regression (top-level/thread/unset -> durable threadSuppressed), bidirectional MS Teams adapter mapping, and CLI guards. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…very (ENG-14117) The main/current-session cron announce path enqueues durably (no skipQueue), so a crash between enqueue and send would replay the top-level cron delivery as a normal threaded send. Persist threadSuppressed in the queued delivery entry and pass it from buildRecoveryDeliverParams so recovery preserves the original top-level intent. Covered by the recovery replay test. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 16 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic | Re-trigger cubic
…ENG-14117) - cron-tool.schema.test: add replyStyle to the exact job.delivery key list that now fails after exposing the field on the agent tool schema. - Regenerate Codex prompt snapshots to include the new delivery.replyStyle schema field (char/token counts + JSON only; no unrelated drift). - delivery-preview: add regression cases — announce+top-level keeps the "top-level" suffix; none+top-level omits it. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
/cr |
|
I'll analyze this and get back to you. |
There was a problem hiding this comment.
Reviewed the full diff (43 files, +953/-55), CI, signatures, and base.
Approving. This is clean, well-scoped work and the plumbing is right.
What I checked:
- Design is sound. Per-send
threadSuppressedtri-state (true/false/undefined) kept portable in coreChannelOutboundContext; only the MS Teams adapter interprets it. Core stays channel-agnostic — exactly the right seam. Bidirectional (--reply-style threadforces threading even when the channel default is top-level) is a nice touch. - Both cron send sites are wired — isolated (
delivery-dispatch) and main/current (server-cron→deliverCronAnnouncePayload). Theserver-crongap you caught in$autoreviewwas the real trap; glad it's covered. - Crash-safety is handled.
threadSuppressedpersists through the durable queue (delivery-queue-storage) andbuildRecoveryDeliverParams, with a recovery-replay test asserting it survives. This was the highest-risk corner and it's proven, not hand-waved. - Edge cases guarded: webhook mode clears
replyStyle(both inmergeCronDeliverywhen mode+replyStyle patched together, and in the CLI conflict check); main/system-event jobs reject--reply-style;mode:noneomits the preview suffix; presentation cards documented as ignoring it. - TDD throughout — adapter mapping (bidirectional + undefined), CLI parse/normalize round-trip, protocol validator (rejects unknown styles + accepts null-clear), delivery preview, dispatch regression. Codex prompt snapshots regenerated to match the new schema field.
- CI green (full matrix + CodeQL + cubic), commits verified-signed, cubic's reported issues all addressed, base is
boon.
One non-blocking nit: the branch still shows the three merged #38 commits (bb1fc6e, 7442440, 0c6cf3d) as ahead of boon — #38 merged at 08:28 today under a squashed SHA, so this branch wasn't rebased after. The net diff is correct and the PR description's "stacked on #38, retarget after merge" note is now stale. A rebase on boon would give a clean delta and dodge any stale-merge risk, but it's cosmetic — not gating.
Ship it.

What Problem This Solves
ENG-14117 (P0): on channels that thread agent replies — the customer surface is Microsoft Teams,
channels.msteams.replyStyle:"thread"— a scheduled/cron job's completion output threads under the session's last message. Channel timelines never get a clean top-level post, so members miss scheduled reports (arguijo's Daily Bid Tab Scan, Civil Timecard Audit, etc.).PR #38 added a per-send
topLevelparam to themessagetool, which covers agent-initiated on-request sends (AC #1). It does not cover the cron/scheduled delivery path (AC #2), which routes throughsendDurableMessageBatchand only ever resolves reply style from config. This PR closes that gap.Why This Change Was Made
A global
replyStyle:"top-level"flip would break the "conversations stay threaded" half of the contract, so the fix has to be per-send. This threads a portable top-level intent from the cron job config all the way to the Teams adapter:CronDelivery.replyStyle("thread" | "top-level") plus--reply-style/--clear-reply-styleoncron add/edit, config normalize/merge, delivery plan/preview, and the gateway RPC schema.threadSuppressedfield to coreChannelOutboundContext/DeliverOutboundPayloadsParams; only the MS Teams adapter interprets it (core stays channel-agnostic). Presentation cards intentionally ignore it (documented limitation, same as PR feat(msteams): add topLevel parameter for per-send reply style override (ENG-14117) #38).replyStyle:"top-level" -> threadSuppressedat both cron send sites: isolated jobs (delivery-dispatch) and main/current-session jobs (delivery.tsviaCronAnnounceTarget, set inserver-cron).It is the scheduled-delivery counterpart of PR #38's per-send
topLevelparam, built on the same override plumbing.User Impact
Operators set
--reply-style top-levelon a scheduled job (ordelivery.replyStylein config) and its runs post a fresh top-level channel message the whole channel sees, while conversational replies still thread. Omitting it preserves current behavior, so existing jobs are unaffected. Additive optional config — no migration.Evidence
$autoreview(high) caught and fixed 2 real issues before commit: the gateway RPC schema usedadditionalProperties:falseand would have rejectedreplyStyleat the boundary; and the main/current-session announce path (server-cron->deliverCronAnnouncePayload) was initially unwired so top-level only worked for isolated jobs.pnpm build(noINEFFECTIVE_DYNAMIC_IMPORT), and behavior tests across msteams / cron / CLI / gateway-protocol (134 passing across the touched suites).Out of scope (follow-ups, not in this PR)
sync-config/agent-setup fleet default for the trial (different repo; mirrors ENG-13324's TeamsreplyStyledefault work).boon-agent10-pilot: run a cron with--reply-style top-level, confirm a new root Teams message (noreplyToId), and confirm a follow-up still threads.🤖 Generated with Claude Code
Summary by cubic
Adds a per‑job reply style for cron announces so scheduled jobs can post top‑level messages on Microsoft Teams or force threading. Defaults stay unchanged; opt in with
--reply-styleor clear it. Addresses ENG-14117.New Features
delivery.replyStyle("thread"|"top-level") for cron announces; set via--reply-style/--clear-reply-styleoncron add/cron edit(protocol + cron-tool schemas accept; normalization supports set/clear).threadSuppressed; MS Teams maps true →"top-level"and false →"thread"; presentation cards ignore it; applied on both cron paths (isolated and main/current‑session)."top-level"for announce plans when set, and omits it formode:"none".Bug Fixes
threadSuppressedin the durable delivery queue and recovery so top‑level intent survives crash replay on the main/current‑session path.--reply-stylewhen combined with--webhook, and on main/system‑event jobs that build no delivery object.replyStylecleared whenmode:webhookso it never threads in that mode.Written for commit bc22792. Summary will update on new commits.