feat(agents-api) pass cron timezone to agent in scheduled trigger execution#2487
Conversation
🦋 Changeset detectedLatest commit: 12d4669 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
|
Threads the cron trigger's configured timezone through the scheduled execution pipeline so the agent receives it as
|
There was a problem hiding this comment.
Small, well-scoped change that correctly threads cronTimezone through to forwardedHeaders for the workflow-based scheduled trigger path. One inconsistency worth addressing: the manual execution paths don't forward timezone.
| const forwardedHeaders: Record<string, string> = {}; | ||
| const effectiveTimezone = cronTimezone || 'UTC'; | ||
| forwardedHeaders['x-inkeep-client-timezone'] = effectiveTimezone; | ||
| forwardedHeaders['x-inkeep-client-timestamp'] = new Date().toISOString(); |
There was a problem hiding this comment.
The two manual-execution call sites in scheduledTriggers.ts (~lines 1207 and 1519) also invoke executeAgentAsync for the same scheduled triggers and have trigger.cronTimezone available, but don't build forwardedHeaders. This means "Rerun" and "Test Now" from the manage UI won't forward the timezone, creating an inconsistency with the workflow-based execution path. Consider extracting a small helper (e.g., buildScheduledTriggerHeaders(cronTimezone)) and using it in all three call sites.
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low
This PR correctly threads the cronTimezone field from scheduled trigger configuration through to agent execution via forwardedHeaders. The implementation follows established patterns and enables agents to access timezone context during scheduled trigger execution.
💭 Consider (1) 💭
💭 1) scheduledTriggerSteps.ts:558-561 Unit test coverage for timezone header construction
Issue: The new header construction logic doesn't have dedicated unit tests.
Why: While the code correctly follows existing patterns (workflow steps aren't individually unit tested), a test would catch regressions like typos in header keys or accidental removal of the UTC fallback.
Fix: Consider adding a test verifying: (1) x-inkeep-client-timezone equals cronTimezone when provided, (2) defaults to 'UTC' when null, (3) x-inkeep-client-timestamp is valid ISO format.
Refs: scheduledTriggers.test.ts — existing CRUD tests for scheduled triggers
Inline Comments:
- 💭 Consider:
scheduledTriggerSteps.ts:558-561Unit test coverage for timezone header construction
Implementation Notes (Positive):
✅ Correct header naming: Uses x-inkeep-client-timezone and x-inkeep-client-timestamp consistent with chat.ts and Agent.ts
✅ Correct parameter naming: cronTimezone matches the database schema field cron_timezone in manage-schema.ts
✅ Appropriate trust boundary: The validation pattern in chat.ts is for untrusted client HTTP headers. Here, cronTimezone comes from a trusted database source with schema constraints, so omitting regex validation is reasonable.
✅ Complete threading: The forwardedHeaders flows correctly through executeScheduledTriggerStep → executeAgentAsync → ExecutionHandler.execute() following the established architecture.
💡 APPROVE WITH SUGGESTIONS
Summary: Clean implementation that enables timezone-aware scheduled trigger execution. The code follows established patterns and the changeset is appropriately scoped. The single "Consider" item about test coverage is non-blocking. This PR looks good to merge.
Reviewers (3)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
pr-review-standards |
0 | 0 | 0 | 0 | 0 | 0 | 0 |
pr-review-consistency |
4 | 0 | 0 | 0 | 0 | 0 | 4 |
pr-review-tests |
3 | 0 | 1 | 0 | 1 | 0 | 0 |
| Total | 7 | 0 | 1 | 0 | 1 | 0 | 4 |
Note: Consistency reviewer returned 1 MAJOR and 3 INFO findings. The MAJOR (validation pattern difference) was downgraded to discarded because cronTimezone comes from a trusted database source, not untrusted client input. The 3 INFO findings were positive confirmations of correct patterns.
Discarded (4)
| Location | Issue | Reason Discarded |
|---|---|---|
scheduledTriggerSteps.ts:558-561 |
Missing timezone validation (regex check like chat.ts) | Different trust boundary — cronTimezone comes from database with schema constraints, not untrusted HTTP headers. Validation pattern in chat.ts is for external client input. |
scheduledTriggerSteps.ts:461 |
Parameter naming consistency check | INFO finding — confirmed as correct, no issue found |
scheduledTriggerSteps.ts:560-561 |
Header key naming consistency check | INFO finding — confirmed as correct, no issue found |
TriggerService.ts:614 |
forwardedHeaders threading pattern check | INFO finding — confirmed as correct, no issue found |
| const forwardedHeaders: Record<string, string> = {}; | ||
| const effectiveTimezone = cronTimezone || 'UTC'; | ||
| forwardedHeaders['x-inkeep-client-timezone'] = effectiveTimezone; | ||
| forwardedHeaders['x-inkeep-client-timestamp'] = new Date().toISOString(); |
There was a problem hiding this comment.
💭 Consider: Unit test coverage for timezone header construction
Issue: This new header construction logic doesn't have dedicated unit tests verifying the fallback to 'UTC' when cronTimezone is null/undefined, or that the correct header keys are used.
Why: While the code correctly follows existing patterns, a unit test would catch regressions like typos in header names or accidental removal of the UTC fallback.
Fix: Consider adding a test case to verify:
x-inkeep-client-timezoneequalscronTimezonewhen providedx-inkeep-client-timezonedefaults to'UTC'whencronTimezoneis nullx-inkeep-client-timestampis a valid ISO timestamp
This is non-blocking since this follows the existing pattern where workflow steps aren't individually unit tested, and the existing integration test coverage would catch major regressions.
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low
This delta review covers the 2 commits since the last automated review (3f5a9d55). The changes directly address the consistency issue raised by pullfrog: the manual execution paths ("Rerun" and "Test Now") now forward timezone headers, matching the workflow-based execution path.
Delta Changes Reviewed
✅ New helper function: buildScheduledTriggerHeaders(cronTimezone) centralizes header construction in TriggerService.ts
✅ Consistent application: The helper is now used in all 3 execution paths:
- Workflow step (
scheduledTriggerSteps.ts:569) - Manual rerun (
scheduledTriggers.ts:1218) - Manual test (
scheduledTriggers.ts:1531)
✅ Correct refactoring: The inline header construction in scheduledTriggerSteps.ts was replaced with the shared helper, reducing duplication
Prior Feedback Status
| Source | Issue | Status |
|---|---|---|
| pullfrog | Manual execution paths don't forward timezone | ✅ Addressed in this delta |
✅ APPROVE
Summary: Clean follow-up that addresses the consistency feedback. The helper function is well-placed in TriggerService.ts alongside executeAgentAsync, and all scheduled trigger execution paths now consistently forward timezone headers.
Reviewers (2)
| Reviewer | Returned | Main Findings | Consider | While You're Here | Inline Comments | Pending Recs | Discarded |
|---|---|---|---|---|---|---|---|
pr-review-standards |
0 | 0 | 0 | 0 | 0 | 0 | 0 |
pr-review-consistency |
0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Total | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
There was a problem hiding this comment.
PR Review Summary
(0) Total Issues | Risk: Low
This delta review covers changes since the last automated review (1de0cadee). The delta consists only of:
- A merge commit from
main(12d46692d) - CI workflow fix from PR #2483 (
a7635fa96)
No changes to the PR's feature code — the timezone forwarding implementation remains unchanged from the prior review.
Prior Review Status
| Review | Verdict | Notes |
|---|---|---|
| pullfrog | COMMENTED | Flagged manual execution path consistency |
| claude (1st) | APPROVE WITH SUGGESTIONS | Unit test coverage suggestion |
| claude (2nd) | ✅ APPROVE | Confirmed pullfrog feedback addressed |
All prior feedback has been addressed. The buildScheduledTriggerHeaders helper is correctly applied across all 3 execution paths.
✅ APPROVE
Summary: No-op delta — only a merge from main bringing in unrelated CI workflow changes. The feature implementation is unchanged and was already approved in the prior review. Ship it! 🚀
Reviewers (0)
No reviewers dispatched — delta contains no feature code changes.
|
No documentation updates required for this PR. The existing Headers documentation already documents the The |
No description provided.