Skip to content

Add configurable session idle timeout option#1093

Draft
MackinnonBuck wants to merge 4 commits intomainfrom
mackinnonbuck/add-session-idle-timeout-option
Draft

Add configurable session idle timeout option#1093
MackinnonBuck wants to merge 4 commits intomainfrom
mackinnonbuck/add-session-idle-timeout-option

Conversation

@MackinnonBuck
Copy link
Copy Markdown
Collaborator

Summary

Adds SDK-side support for configurable session idle timeout, addressing github/copilot-sdk-partners#28.

The corresponding runtime changes that add the --session-idle-timeout CLI arg are in github/copilot-agent-runtime#6414.

Changes

nodejs/src/types.ts

  • Added sessionIdleTimeoutMs?: number to CopilotClientOptions with JSDoc documenting default (0/disabled), minimum (300,000ms / 5 minutes), and behavior.

nodejs/src/client.ts

  • Added sessionIdleTimeoutMs to the defaults object (defaulting to 0).
  • When a positive value is configured, passes --session-idle-timeout <ms> to the CLI process on startup.

docs/features/session-persistence.md

  • Updated the "Automatic Cleanup: Idle Timeout" section to reflect that sessions now have no idle timeout by default (previously hardcoded 30 minutes).
  • Added documentation for the new sessionIdleTimeoutMs option with usage example.
  • Noted that the option only applies when the SDK spawns the runtime (not when using cliUrl).

Notes

  • This is a CopilotClientOptions field (server/process level), not a per-session config.
  • The option is only relevant when the SDK spawns the runtime process.

@MackinnonBuck MackinnonBuck requested a review from a team as a code owner April 16, 2026 18:28
Copilot AI review requested due to automatic review settings April 16, 2026 18:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new Node SDK client option to configure a server-wide session idle timeout and wires it through to the spawned Copilot CLI runtime via a new --session-idle-timeout argument, with accompanying documentation updates.

Changes:

  • Adds sessionIdleTimeoutMs?: number to CopilotClientOptions with documented defaults/minimums.
  • Sets a default of 0 (disabled) and forwards --session-idle-timeout <ms> when configured to a positive value.
  • Updates session persistence docs to describe the new default behavior and configuration caveats (only applies when the SDK spawns the runtime).
Show a summary per file
File Description
nodejs/src/types.ts Introduces the new CopilotClientOptions.sessionIdleTimeoutMs option and documents intended semantics.
nodejs/src/client.ts Applies defaulting and forwards the new option to the CLI as --session-idle-timeout.
docs/features/session-persistence.md Documents the new option, updated defaults, and cliUrl caveat.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Comment thread nodejs/src/client.ts
Comment on lines 339 to 343
// Default useLoggedInUser to false when githubToken is provided, otherwise true
useLoggedInUser: options.useLoggedInUser ?? (options.githubToken ? false : true),
telemetry: options.telemetry,
sessionIdleTimeoutMs: options.sessionIdleTimeoutMs ?? 0,
};
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

sessionIdleTimeoutMs is documented as having a minimum of 300000ms, but the client currently forwards any positive value to the runtime without validation. This can lead to unexpected runtime failures or behavior when users pass values < 300000, negative numbers, non-integers, or NaN. Consider validating in the constructor (e.g., finite number, integer, >= 0, and if > 0 then >= 300000) and throwing a clear error when invalid.

Copilot uses AI. Check for mistakes.
Comment thread nodejs/src/client.ts Outdated
Comment on lines +1389 to +1391
if (this.options.sessionIdleTimeoutMs !== undefined && this.options.sessionIdleTimeoutMs > 0) {
args.push("--session-idle-timeout", this.options.sessionIdleTimeoutMs.toString());
}
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

No automated test currently asserts that sessionIdleTimeoutMs results in the expected --session-idle-timeout <ms> CLI argument (and that 0/unset does not). Adding a unit test that mocks spawn and inspects the argv would prevent regressions in the option-to-flag mapping.

Copilot uses AI. Check for mistakes.
@MackinnonBuck MackinnonBuck marked this pull request as draft April 16, 2026 20:24
MackinnonBuck and others added 4 commits April 16, 2026 16:45
Add a new optional sessionIdleTimeoutMs field to CopilotClientOptions that
allows consumers to configure the server-wide session idle timeout. When set
to a positive value, the SDK passes --session-idle-timeout to the CLI process.

Sessions have no idle timeout by default (infinite lifetime). The minimum
configurable value is 300000ms (5 minutes).

Also updates the session persistence documentation to reflect the new
default behavior and configuration option.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MackinnonBuck MackinnonBuck force-pushed the mackinnonbuck/add-session-idle-timeout-option branch from f3008df to ede32da Compare April 16, 2026 23:52
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