Skip to content

Fix : Remove default maxSessionDuration for AgentRuntime#410

Open
safiya2610 wants to merge 2 commits into
volcano-sh:mainfrom
safiya2610:fix/issue-303
Open

Fix : Remove default maxSessionDuration for AgentRuntime#410
safiya2610 wants to merge 2 commits into
volcano-sh:mainfrom
safiya2610:fix/issue-303

Conversation

@safiya2610

@safiya2610 safiya2610 commented Jun 28, 2026

Copy link
Copy Markdown

What type of PR is this?

This PR resolves Issue #303 by making AgentRuntime.spec.maxSessionDuration optional instead of defaulting to 8 hours.

Changes

Removed the default maxSessionDuration value for AgentRuntime.
Updated the workload builder to set Sandbox.Spec.Lifecycle.ShutdownTime only when maxSessionDuration is explicitly configured.
Preserved the existing default maximum session duration behavior for CodeInterpreter.
Updated the AgentRuntime CRD to reflect the optional field.
Added and updated unit tests to cover the new behavior.
Why
Previously, every AgentRuntime was assigned a default maximum session duration of 8 hours, causing long-running agents to be terminated even when they were still active. With this change, long-running AgentRuntime instances are no longer force-terminated unless a maximum session duration is explicitly specified, while CodeInterpreter continues to retain its existing behavior.

Testing
go test ./pkg/workloadmanager/...
go test ./pkg/apis/runtime/v1alpha1/...
go build ./...

Which issue(s) this PR fixes:
Fixes #303

Signed-off-by: Safiya <147792763+safiya2610@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 28, 2026 12:32
@volcano-sh-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kevin-wangzefeng for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request makes maxSessionDuration optional for AgentRuntime by removing its default value and required validation in both the CRD and Go API definitions. It also updates the workload builder logic to only set a sandbox shutdown time if a TTL is specified, defaulting to DefaultSandboxTTL specifically for code interpreters, and adds a corresponding unit test assertion. Feedback highlights that maxSessionDuration is still listed in the required list at the bottom of the CRD file, which will cause Kubernetes to reject resources that omit it.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Copilot AI left a comment

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.

Pull request overview

This PR aims to resolve Issue #303 by making AgentRuntime.spec.maxSessionDuration optional (removing the implicit 8h hard lifetime), while preserving the existing default max session duration behavior for CodeInterpreter. It updates sandbox construction so a hard ShutdownTime is only set when explicitly configured, updates the AgentRuntime API/CRD, and adjusts unit tests accordingly.

Changes:

  • Remove the default hard max lifetime for AgentRuntime sessions by not setting Sandbox.Spec.Lifecycle.ShutdownTime unless maxSessionDuration is provided.
  • Preserve CodeInterpreter’s default hard max lifetime (8h) by explicitly applying DefaultSandboxTTL when maxSessionDuration is omitted.
  • Update the AgentRuntime API/CRD and unit tests to reflect the new optional semantics.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
pkg/workloadmanager/workload_builder.go Stop defaulting TTL in the generic sandbox builder; set ShutdownTime only when TTL is explicitly configured; preserve CodeInterpreter TTL defaulting.
pkg/workloadmanager/workload_builder_test.go Update AgentRuntime default timeout test to assert ShutdownTime is nil when maxSessionDuration is omitted.
pkg/apis/runtime/v1alpha1/agent_type.go Remove kubebuilder-required/default markers and document MaxSessionDuration as optional for AgentRuntime.
manifests/charts/base/crds/runtime.agentcube.volcano.sh_agentruntimes.yaml Remove the CRD default value for maxSessionDuration.
Comments suppressed due to low confidence (1)

manifests/charts/base/crds/runtime.agentcube.volcano.sh_agentruntimes.yaml:50

  • The Helm CRD still marks spec.maxSessionDuration as required even though the default was removed. In this CRD, spec.required still includes - maxSessionDuration (see same file around line 8505), so clients will still be forced to provide the field, which contradicts making it optional in AgentRuntimeSpec.

Update the CRD schema to remove maxSessionDuration from the spec.required list (ideally by regenerating the CRD from controller-gen after removing the +kubebuilder:validation:Required tag in pkg/apis/runtime/v1alpha1/agent_type.go).

              maxSessionDuration:
                description: |-
                  MaxSessionDuration describes the maximum duration for a session.
                  After this duration, the session will be terminated no matter active or inactive.
                type: string

Comment thread pkg/workloadmanager/workload_builder.go
@codecov-commenter

codecov-commenter commented Jun 28, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.62%. Comparing base (524e55e) to head (e7219c7).
⚠️ Report is 146 commits behind head on main.

Files with missing lines Patch % Lines
pkg/workloadmanager/workload_builder.go 81.81% 1 Missing and 1 partial ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #410       +/-   ##
===========================================
+ Coverage   47.57%   58.62%   +11.05%     
===========================================
  Files          30       37        +7     
  Lines        2819     3500      +681     
===========================================
+ Hits         1341     2052      +711     
+ Misses       1338     1238      -100     
- Partials      140      210       +70     
Flag Coverage Δ
unittests 58.62% <88.88%> (+11.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Safiya <147792763+safiya2610@users.noreply.github.com>

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


shutdownTime := metav1.NewTime(time.Now().Add(params.ttl))
var shutdownTime *metav1.Time
if params.ttl > 0 {
Comment on lines +41 to +43
// NoExpiryDeadline represents a sandbox with no hard expiry deadline (used for AgentRuntime without maxSessionDuration).
// Setting ExpiresAt to this value ensures the sandbox won't be selected by ListExpiredSandboxes queries.
var NoExpiryDeadline = time.Date(9999, 12, 31, 23, 59, 59, 0, time.UTC)
Comment on lines +112 to +116
// Filter out sandboxes with no hard expiry deadline (ExpiresAt >= NoExpiryDeadline)
// These are AgentRuntime sandboxes without maxSessionDuration that should not be GC'd by TTL.
filteredExpiredSandboxes := make([]*types.SandboxInfo, 0, len(expiredSandboxes))
for _, s := range expiredSandboxes {
if s.ExpiresAt.Before(NoExpiryDeadline) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove AgentRuntime default max ttl

4 participants