Skip to content

feat: add runtime lifecycle configuration (idle timeout and max lifetime)#653

Open
tejaskash wants to merge 2 commits intomainfrom
lifecycle-config
Open

feat: add runtime lifecycle configuration (idle timeout and max lifetime)#653
tejaskash wants to merge 2 commits intomainfrom
lifecycle-config

Conversation

@tejaskash
Copy link
Contributor

@tejaskash tejaskash commented Mar 25, 2026

Summary

Adds runtime lifecycle configuration support, allowing users to control idle session timeout and max instance lifetime for agent runtimes. Both values are optional and accept a range of 60-28800 seconds.

  • New --idle-timeout and --max-lifetime CLI flags on create and add agent commands
  • Full TUI support in both the Create (GenerateWizard) and Add Agent (BYO) flows under Advanced settings
  • Schema validation with cross-field constraint (idle timeout must be <= max lifetime)
  • Shared lifecycle-utils.ts validation module used by both CLI and TUI paths
  • Values written to lifecycleConfiguration in agentcore.json and passed through to CDK

TUI: Advanced flow with lifecycle steps

When a user selects "Yes, customize" in the Advanced settings step, the breadcrumb expands to include Idle Timeout and Max Lifetime:

  ✓ Name →  ✓ Type →  ✓ Code →  ✓ Build →  ✓ Model →  ✓ Advanced →  ● Network
  ○ Headers →  ○ Idle Timeout →  ○ Max Lifetime →  ○ Confirm

TUI: Idle Timeout input

  ✓ Headers →  ● Idle Timeout →  ○ Max Lifetime →  ○ Confirm

  ╭──────────────────────────────────────────────────────────╮
  │ Idle session timeout in seconds (60-28800, or press      │
  │ Enter to skip)                                           │
  │ > 600  ✓                                                 │
  ╰──────────────────────────────────────────────────────────╯

TUI: Max Lifetime input

  ✓ Headers →  ✓ Idle Timeout →  ● Max Lifetime →  ○ Confirm

  ╭──────────────────────────────────────────────────────────╮
  │ Max instance lifetime in seconds (60-28800, or press     │
  │ Enter to skip)                                           │
  │ > 14400  ✓                                               │
  ╰──────────────────────────────────────────────────────────╯

TUI: Review screen showing lifecycle values

  ╭──────────────────────────────────────────────────────────╮
  │ Review Configuration                                     │
  │                                                          │
  │   Name: LifecycleAgent                                   │
  │   Type: Bring my own code                                │
  │   Code Location: app/LifecycleAgent/                     │
  │   Entrypoint: main.py                                    │
  │   Build: Direct Code Deploy                              │
  │   Model Provider: Bedrock                                │
  │   Network Mode: PUBLIC                                   │
  │   Headers: Authorization                                 │
  │   Idle Timeout: 600s                                     │
  │   Max Lifetime: 14400s                                   │
  │                                                          │
  │ Enter confirm · Esc back                                 │
  ╰──────────────────────────────────────────────────────────╯

CLI flags

  --idle-timeout <seconds>     Idle session timeout in seconds (60-28800) [non-interactive]
  --max-lifetime <seconds>     Max instance lifetime in seconds (60-28800) [non-interactive]

CDK Companion PR

https://github.com/aws/agentcore-l3-cdk-constructs/pull/109

Test plan

  • Unit tests for lifecycle-utils.ts validation (15 tests)
  • Schema validation tests for lifecycleConfiguration in AgentEnvSpecSchema (cross-field superRefine)
  • useGenerateWizard unit tests for lifecycle state management
  • create and add command validation tests for --idle-timeout / --max-lifetime
  • schema-mapper tests verifying lifecycle config flows to agent spec
  • Integration tests verifying CLI flags produce correct config in agentcore.json
  • TUI integration tests (Create flow + BYO flow)
  • E2E test support: lifecycle config passed through create, verified via AWS GetAgentRuntime API
  • All existing tests pass after rebase on main

…ime)

Add --idle-timeout and --max-lifetime flags to create/add commands, with
full TUI support in both GenerateWizard (create) and AddAgent (BYO) flows.
Values map to lifecycleConfiguration in the agent schema and flow through
to the CDK construct.

Includes schema validation (60-28800s range, idle <= max), CLI flag
validation, E2E test support with AWS API verification, integration tests,
and TUI integration tests.
@tejaskash tejaskash requested a review from a team March 25, 2026 20:17
@github-actions github-actions bot added the size/xl PR size: XL label Mar 25, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 25, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 45.37% 5982 / 13183
🔵 Statements 44.97% 6355 / 14131
🔵 Functions 44.42% 1111 / 2501
🔵 Branches 45.84% 3953 / 8622
Generated in workflow #1324 for commit ad06702 by the Vitest Coverage Report Action

The strands-bedrock e2e test reuses an existing deployed runtime that
was created without lifecycle config. Adding lifecycle assertions to it
causes failures because the already-deployed runtime has default values
(900s) rather than the overridden ones (120s).

Runtime lifecycle configuration should be validated via a dedicated test,
not by modifying shared framework e2e tests.
@github-actions github-actions bot added size/xl PR size: XL and removed size/xl PR size: XL labels Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xl PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant