Skip to content

feat(agents-api) pass cron timezone to agent in scheduled trigger execution#2487

Merged
miles-kt-inkeep merged 5 commits intomainfrom
feat/timezone-aware-scheduled-trigger
Mar 3, 2026
Merged

feat(agents-api) pass cron timezone to agent in scheduled trigger execution#2487
miles-kt-inkeep merged 5 commits intomainfrom
feat/timezone-aware-scheduled-trigger

Conversation

@miles-kt-inkeep
Copy link
Copy Markdown
Contributor

No description provided.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 3, 2026

🦋 Changeset detected

Latest commit: 12d4669

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@inkeep/agents-api Patch
@inkeep/agents-manage-ui Patch
@inkeep/agents-cli Patch
@inkeep/agents-core Patch
@inkeep/agents-email Patch
@inkeep/agents-mcp Patch
@inkeep/agents-sdk Patch
@inkeep/agents-work-apps Patch
@inkeep/ai-sdk-provider Patch
@inkeep/create-agents Patch

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

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
agents-api Ignored Ignored Preview Mar 3, 2026 4:07am
agents-docs Ignored Ignored Preview Mar 3, 2026 4:07am
agents-manage-ui Ignored Ignored Preview Mar 3, 2026 4:07am

Request Review

@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog Bot commented Mar 3, 2026

Threads the cron trigger's configured timezone through the scheduled execution pipeline so the agent receives it as x-inkeep-client-timezone (and a companion x-inkeep-client-timestamp) via forwarded headers.

  • agents-api/src/domains/run/workflow/steps/scheduledTriggerSteps.ts — accepts cronTimezone, builds a forwardedHeaders map (defaulting to UTC), and passes it into executeAgentAsync
  • agents-api/src/domains/run/workflow/functions/scheduledTriggerRunner.ts — forwards cronTimezone from the trigger config into executeScheduledTriggerStep
  • agents-api/src/domains/run/services/TriggerService.ts — adds forwardedHeaders to executeAgentAsync's param type and pipes it through to the agent execution call
  • .changeset/friendly-crimson-orca.md — patch changeset for @inkeep/agents-api

Pullfrog  | View workflow run | Using Claude Code | Triggered by Pullfrogpullfrog.com𝕏

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

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

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.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow runpullfrog.com𝕏

Comment on lines +558 to +561
const forwardedHeaders: Record<string, string> = {};
const effectiveTimezone = cronTimezone || 'UTC';
forwardedHeaders['x-inkeep-client-timezone'] = effectiveTimezone;
forwardedHeaders['x-inkeep-client-timestamp'] = new Date().toISOString();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

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-561 Unit 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 executeScheduledTriggerStepexecuteAgentAsyncExecutionHandler.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

Comment on lines +558 to +561
const forwardedHeaders: Record<string, string> = {};
const effectiveTimezone = cronTimezone || 'UTC';
forwardedHeaders['x-inkeep-client-timezone'] = effectiveTimezone;
forwardedHeaders['x-inkeep-client-timestamp'] = new Date().toISOString();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💭 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:

  1. x-inkeep-client-timezone equals cronTimezone when provided
  2. x-inkeep-client-timezone defaults to 'UTC' when cronTimezone is null
  3. x-inkeep-client-timestamp is 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.

Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

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

@github-actions github-actions Bot deleted a comment from claude Bot Mar 3, 2026
Copy link
Copy Markdown
Contributor

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

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.

@github-actions github-actions Bot deleted a comment from claude Bot Mar 3, 2026
@miles-kt-inkeep miles-kt-inkeep merged commit add0b4b into main Mar 3, 2026
11 checks passed
@miles-kt-inkeep miles-kt-inkeep deleted the feat/timezone-aware-scheduled-trigger branch March 3, 2026 04:17
@claude claude Bot mentioned this pull request Mar 3, 2026
@inkeep
Copy link
Copy Markdown
Contributor

inkeep Bot commented Mar 3, 2026

No documentation updates required for this PR.

The existing Headers documentation already documents the x-inkeep-client-timezone and x-inkeep-client-timestamp headers that agents receive. This PR extends the same headers to scheduled trigger executions, which is an internal implementation detail that doesn't require user-facing documentation changes.

The cronTimezone configuration option is already documented in the Scheduled Triggers docs.

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.

2 participants