Skip to content

Use TimeToLive (TimeSpan?) instead of TtlMs (long?) in public APIs#1644

Open
Copilot wants to merge 5 commits into
mainfrom
copilot/update-time-to-live-usage
Open

Use TimeToLive (TimeSpan?) instead of TtlMs (long?) in public APIs#1644
Copilot wants to merge 5 commits into
mainfrom
copilot/update-time-to-live-usage

Conversation

Copilot AI commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Ttl abbreviation in public APIs is hard to read. This PR spells it out as TimeToLive and also changes the type from long? (milliseconds) to TimeSpan? for a more idiomatic .NET API. A new TimeSpanMillisecondsConverter handles JSON serialization so the wire format is unchanged.

Changes

New type

  • TimeSpanMillisecondsConverter — a JsonConverter<TimeSpan> that reads/writes millisecond integers on the wire

Renamed and retyped identifiers

Type Before After
McpTaskInfo long? TtlMs TimeSpan? TimeToLive
CreateTaskResult long? TtlMs TimeSpan? TimeToLive
GetTaskResult long? TtlMs TimeSpan? TimeToLive
TaskStatusNotificationParams long? TtlMs TimeSpan? TimeToLive
InMemoryMcpTaskStore long? DefaultTtlMs TimeSpan? DefaultTimeToLive

The JSON wire format property name ("ttlMs") is unchanged — only C# identifiers and types are affected.

// Before
var store = new InMemoryMcpTaskStore { DefaultTtlMs = 30_000 };
long? ttl = result.TtlMs;

// After
var store = new InMemoryMcpTaskStore { DefaultTimeToLive = TimeSpan.FromSeconds(30) };
TimeSpan? ttl = result.TimeToLive;

…ic APIs

Co-authored-by: PranavSenthilnathan <12225508+PranavSenthilnathan@users.noreply.github.com>
Copilot AI changed the title [WIP] Consistently use TimeToLive instead of TTL in public APIs Rename TtlMs/DefaultTtlMs to TimeToLiveMs/DefaultTimeToLiveMs in public APIs Jun 12, 2026
Comment thread src/ModelContextProtocol.Core/Protocol/CreateTaskResult.cs Outdated
…llisecondsConverter

Co-authored-by: PranavSenthilnathan <12225508+PranavSenthilnathan@users.noreply.github.com>
Copilot AI changed the title Rename TtlMs/DefaultTtlMs to TimeToLiveMs/DefaultTimeToLiveMs in public APIs Use TimeToLive (TimeSpan?) instead of TtlMs (long?) in public APIs Jun 12, 2026
@halter73

Copy link
Copy Markdown
Contributor

@copilot This has conflicts with main. Can you fix that?

Co-authored-by: halter73 <54385+halter73@users.noreply.github.com>

Copilot AI commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

@copilot This has conflicts with main. Can you fix that?

Fixed in 5f8e777. The only conflict was TimeSpanMillisecondsConverter.cs — both branches added the file independently. Resolved by adopting main's more robust implementation (overflow clamping, fractional ms handling, .NET Framework edge cases). Build and all task tests pass.

Copilot AI requested a review from halter73 June 18, 2026 01:38
@PranavSenthilnathan PranavSenthilnathan marked this pull request as ready for review June 18, 2026 23:01
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

Consistently use TimeToLive instead of TTL in public APIs

4 participants