Skip to content

fix(mcp, cli): Keep tool sessions alive through long turns - #1247

Merged
JeanMertz merged 4 commits into
mainfrom
mcp-issue
Oct 24, 2026
Merged

JeanMertz merged 4 commits into
mainfrom
mcp-issue

Conversation

@JeanMertz

Copy link
Copy Markdown
Collaborator

A turn could lose every tool for the rest of its run once the model spent more than five minutes generating between tool calls. The in-process JP MCP Server used rmcp's default session config, whose 300-second idle timeout ended the Host's session while no traffic flowed. Every later call then failed with Session expired (HTTP 404), and the assistant was handed those failures as tool results to retry against a connection that could not recover.

The endpoint's sessions no longer expire when idle. They last until their client closes them or the endpoint shuts down at the end of the turn, which already bounds a session an external client abandons.

When JP's own connection to the server is lost anyway, the turn now ends with "Lost the connection to the JP MCP Server" instead of continuing. Every unsettled call is recorded as not executed, or as possibly run if it had been released, so each request stays paired with a response; no follow-up request is sent, and nothing more is prompted for. A single WARN names the error and the endpoint. A tool that fails on its own still fails only its own call.

A turn could lose every tool for the rest of its run once the model
spent more than five minutes generating between tool calls. The
in-process JP MCP Server used rmcp's default session config, whose
300-second idle timeout ended the Host's session while no traffic
flowed. Every later call then failed with `Session expired (HTTP 404)`,
and the assistant was handed those failures as tool results to retry
against a connection that could not recover.

The endpoint's sessions no longer expire when idle. They last until
their client closes them or the endpoint shuts down at the end of the
turn, which already bounds a session an external client abandons.

When JP's own connection to the server is lost anyway, the turn now
ends with "Lost the connection to the JP MCP Server" instead of
continuing. Every unsettled call is recorded as not executed, or as
possibly run if it had been released, so each request stays paired
with a response; no follow-up request is sent, and nothing more is
prompted for. A single `WARN` names the error and the endpoint. A tool
that fails on its own still fails only its own call.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz
JeanMertz merged commit 1b0e9f8 into main Oct 24, 2026
23 checks passed
@JeanMertz
JeanMertz deleted the mcp-issue branch October 24, 2026 18:03
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.

1 participant