Skip to content

Derive runtime deadlines from Nitro maxDuration #1027

Description

@dcramer

Objective

Make juniorNitro({ maxDuration }) the single source of truth for Junior's
serverless execution budget.

Simple contract

Junior should not require operators to configure the same timeout twice.

When an app sets:

juniorNitro({ maxDuration: 800 });

Junior should use that value both for the generated Vercel function
configuration and for runtime deadline calculations.

  • The agent hard deadline leaves enough time to save state before Vercel stops
    the function.
  • The conversation worker soft-yields earlier than the hard deadline.
  • Queue visibility lasts longer than the function can run.
  • AGENT_TURN_TIMEOUT_MS may make an agent run shorter, but never longer than
    the host budget.
  • Production may raise maxDuration to the limit available to its Vercel
    project without separately changing runtime environment variables.

Scope

  • Inject the build-time maxDuration value into Junior's generated runtime
    configuration.
  • Derive the request deadline, conversation-worker soft yield, and queue
    visibility timeout from that value using explicit safety buffers.
  • Remove FUNCTION_MAX_DURATION_SECONDS and the legacy
    QUEUE_CALLBACK_MAX_DURATION_SECONDS runtime configuration once the generated
    value is authoritative.
  • Preserve a safe default when juniorNitro() does not receive maxDuration.
  • Add configuration tests proving build and runtime values cannot drift.

Completion

  • One maxDuration setting configures both Vercel and Junior runtime budgets.
  • Agent execution stops before the host timeout and persists a continuation.
  • Conversation work soft-yields before the hard deadline.
  • Queue visibility remains longer than the configured function duration.
  • A lower AGENT_TURN_TIMEOUT_MS override remains supported.
  • Production can increase maxDuration without adding a matching environment variable.

Non-goals

  • Automatically discovering Vercel account limits at runtime.
  • Choosing the production duration value in this issue.
  • Changing turn slice limits or retry policy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions