Skip to content

fix: refresh connector tools between turns in existing sessions - #663

Open
apoorvgarg31 wants to merge 1 commit into
andrewyng:mainfrom
apoorvgarg31:fix/refresh-session-connector-tools
Open

apoorvgarg31 wants to merge 1 commit into
andrewyng:mainfrom
apoorvgarg31:fix/refresh-session-connector-tools

Conversation

@apoorvgarg31

@apoorvgarg31 apoorvgarg31 commented Sep 14, 2026 •

Copy link
Copy Markdown

Summary

Fixes #662.

Refresh connector and MCP tool selection before a new turn, retry, or durable resume. This lets an existing chat pick up a newly connected account or MCP server without restarting the application or replacing its worker.

  • Re-read native connection state, tool enablement, and effective chat/persona restrictions.
  • Reuse existing MCP transports while rebuilding the callable selection from current configuration/discovery.
  • Preserve the engine, history, permission object, and unrelated/stateful tools.
  • Replace the connection-tool group atomically at a turn boundary; do not replace tools while the current tool loop or question/approval is in flight.
  • Apply the same preparation path to interactive, background and scheduled execution. A preparation exception reports an error rather than running the stale registry.

The source diff is limited to four backend files and one regression-test file. No UI, dependency, database, or deployment changes.

Reproduction and tests

Tested against upstream 5bc10d928e0b64aae74313349a3b17bd19643ae2 with Python 3.12 and Node 20, matching the repository CI versions.

  • Unmodified upstream backend baseline: 1,955 passed, 1 skipped.
  • Behavioral regression suite against the original implementation: 12 failed, 1 passed (two new-helper tests excluded from that before/after comparison).
  • Fixed pytest tests/test_connection_refresh.py -q: 15 passed.
  • Fixed pytest tests -q: 1,970 passed, 1 skipped.
  • GUI TypeScript check: passed.
  • npm test: 181 passed.
  • npm run e2e: 221 passed.
  • npm run build and git diff --check: passed.

The new tests include a continuously open real-backend WebSocket for both manual connection and the managed OAuth callback, disconnect/re-enable, tool/chat/persona restrictions, pending questions, background turns, retry/resume, unrelated tool preservation, and refresh failure. A real local stdio MCP server is discovered, approved, and executed after the original session has started.

GitHub CI: the upstream workflow is awaiting maintainer approval before it can run.

These are local macOS results, not a claim that GitHub CI or packaged Desktop acceptance has already passed. Upstream's existing Playwright suite uses mocked HTTP/WebSocket endpoints; the real-backend same-socket case is covered separately by the new Python test.

Before / after screenshots

As requested by the README contribution guidance. Settings connection screenshots and reproduction details are in #662.

Before: the account is connected, but the original chat's next turn still lacks Outlook search.

Before: Outlook search missing from the existing chat

After: the next turn receives Outlook search and the earlier messages remain.

After: Outlook search available in the existing chat

The screenshots use the actual upstream UI/backend and a clearly labelled deterministic diagnostic provider that reports the actual received tool schema. External identity validation is stubbed; identities/tokens are synthetic. They do not claim live Outlook OAuth or model acceptance. Images are hosted at an immutable commit on a separate evidence branch in the contributor fork, keeping binary assets out of this PR's source diff.

Scope / limitations

This is a next-turn refresh, not immediate mid-turn revocation or cancellation redesign. It intentionally does not interrupt an already-running operation. It does not force a remote MCP tools/list on every turn, or add a new MCP transport/config reload mechanism; existing explicit reconnect/discovery behavior remains authoritative. No live external OAuth account or packaged Desktop build was used for this acceptance.

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.

Existing chats do not pick up newly connected connector and MCP tools

1 participant