Skip to content

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

Merged
tejaskash merged 3 commits intomainfrom
lifecycle-config
Mar 26, 2026
Merged

feat: add runtime lifecycle configuration (idle timeout and max lifetime)#653
tejaskash merged 3 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

@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.81% 6484 / 14154
🔵 Statements 45.37% 6887 / 15177
🔵 Functions 44.38% 1159 / 2611
🔵 Branches 45.91% 4273 / 9306
Generated in workflow #1389 for commit bcc83c4 by the Vitest Coverage Report Action

@github-actions github-actions bot added size/xl PR size: XL and removed size/xl PR size: XL labels Mar 25, 2026
Copy link
Contributor

@Hweinstock Hweinstock left a comment

Choose a reason for hiding this comment

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

Few small comments

@github-actions github-actions bot added size/xl PR size: XL and removed size/xl PR size: XL labels Mar 26, 2026
Hweinstock
Hweinstock previously approved these changes Mar 26, 2026
Copy link
Contributor

@Hweinstock Hweinstock left a comment

Choose a reason for hiding this comment

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

looks like there are some merge conflicts, but otherwise looks good.

Hweinstock
Hweinstock previously approved these changes Mar 26, 2026
…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.
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.
- Extract LIFECYCLE_TIMEOUT_MIN/MAX constants from schema, use everywhere
  instead of hardcoded 60/28800 values (review comment 2)
- Rename validateLifecycleOptions → parseAndValidateLifecycleOptions to
  clarify intent; return parsed values instead of mutating input (comment 3)
- Unify create/add option types to number | string for consistency (comment 4)
@github-actions github-actions bot added size/xl PR size: XL and removed size/xl PR size: XL labels Mar 26, 2026
@tejaskash tejaskash merged commit 1ca0750 into main Mar 26, 2026
19 of 20 checks passed
@tejaskash tejaskash deleted the lifecycle-config branch March 26, 2026 21:38
aidandaly24 added a commit to aidandaly24/agentcore-cli that referenced this pull request Mar 27, 2026
Fix help text for options added in upstream PRs aws#652, aws#653, aws#657, aws#620:

- dev: add [non-interactive] to --tool, --input, -H/--header
- invoke: add [non-interactive] to -H/--header
- fetch access: add [non-interactive] to --name, --type, --target, --json
- copy.ts: add missing 'import' command description

Confidence: high
Scope-risk: narrow
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.

3 participants