Skip to content

fix(gateway): clear claude-cli session on sessions.reset RPC#1232

Merged
mrgoonie merged 1 commit into
nextlevelbuilder:devfrom
zezaeoh:fix/cli-session-reset-rpc
Jun 20, 2026
Merged

fix(gateway): clear claude-cli session on sessions.reset RPC#1232
mrgoonie merged 1 commit into
nextlevelbuilder:devfrom
zezaeoh:fix/cli-session-reset-rpc

Conversation

@zezaeoh

@zezaeoh zezaeoh commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

What

sessions.reset (JSON-RPC) only reset the native session store. For claude-cli-backed agents the actual conversation lives in the Claude CLI session files (.jsonl + CLAUDE.md), which were left in place — so the next turn resumed stale history despite a "reset".

The /reset chat command already clears these via providers.ResetCLISession (handleResetCommand in cmd/gateway_consumer_handlers.go). This brings the RPC path to parity with the chat command.

Change

  • handleReset now also calls ResetCLISession("", key), mirroring the chat path. It is a no-op when the CLI provider is not in use (the helper guards on missing files).
  • The call is wired through an overridable package var (cliSessionReset) so the behavior can be regression-tested without filesystem side effects.

Test

  • New TestSessionsReset_ClearsCLISession asserts the RPC reset invokes the CLI clear with the correct session key and still resets the native store.
  • go test ./internal/gateway/methods/ ✓, go vet ./internal/gateway/methods/ ✓, gofmt clean.

Notes

The sessions.reset RPC only reset the native session store, leaving the
Claude CLI-backed history (.jsonl + CLAUDE.md) in place. The /reset chat
command already clears it via providers.ResetCLISession, so RPC callers
got an incomplete reset for claude-cli agents — stale history was resumed
on the next turn.

Mirror the chat path by calling ResetCLISession from handleReset. It is a
no-op when the CLI provider is unused. The call is wired through an
overridable package var so the behavior can be regression-tested.

@mrgoonie mrgoonie 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.

Summary: This brings the JSON-RPC sessions.reset path into parity with the chat /reset command by clearing the Claude CLI session files as well as the native session store.

Risk level: Low

Mandatory gates:

  • Duplicate/prior implementation: clear — search found no existing PR/issue implementing this RPC-specific reset path; the only prior implementation is the chat-command path this mirrors.
  • Project standards: passed — small gateway-method change, provider helper reuse, and regression test fit the surrounding session-method patterns.
  • Strategic necessity: clear value — without this, web/RPC reset can leave claude-cli-backed agents resuming stale .jsonl/CLAUDE.md history despite reporting reset success.
  • CI/checks: green — release-versioning, go, and web checks succeeded.

Findings:

  • Critical: none
  • Important: none
  • Suggestion: none

Verdict: APPROVE

Evidence checked: internal/gateway/methods/sessions.go, internal/gateway/methods/sessions_reset_cli_test.go, existing /reset implementation in cmd/gateway_consumer_handlers.go, providers.ResetCLISession behavior in internal/providers/claude_cli_session.go, duplicate search, and local go test ./internal/gateway/methods/.

@mrgoonie mrgoonie merged commit cedd667 into nextlevelbuilder:dev Jun 20, 2026
3 checks passed
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