openworker icon indicating copy to clipboard operation
openworker copied to clipboard

Connecting a connector from Settings leaves open sessions without its tools, and `request_connector` then reports "connected" indefinitely

Open liquidaty opened this issue 2 days ago • 0 comments

Summary

A session that is already open when the user connects a connector from Settings never receives that connector's tools. When the agent calls request_connector to recover, the server replies {"approved": true, "connected": true, "note": "<connector> is already connected"} and still does not rebuild the session's tools. The agent sees a connected connector and no tools, on every retry.

Environment

  • openworker 0.3.4, commit 9b91c232
  • macOS 15.1.1, Python 3.15.2
  • Connector: Gmail, manual connect (pasted OAuth access token, gmail.readonly scope)
  • Persona: Cowork

Steps to reproduce

  1. Start a session with no Gmail connector configured.
  2. Ask for something that needs Gmail, so the agent reports that it has no Gmail tools.
  3. Leave the session open. In Settings, open the Gmail connector, paste a valid access token and connect. Settings shows the connector as connected, with "Search Gmail" and "Read message" enabled.
  4. Return to the session and ask the agent to retry.

Expected

From the next turn, the session exposes gmail_search_messages and gmail_get_message.

Actual

The agent calls request_connector("gmail", ...) and receives approved: true, connected: true, note: "gmail is already connected". The session's tool list is unchanged on that turn and on every later turn. Repeating the request returns the same reply.

The token is valid: Google's tokeninfo endpoint accepts it with the expected scope, and secrets.json holds gmail:default (enabled) and a gmail:account:* profile with the token.

Cause

Each session caches its engine, and the engine's tool registry is built once from the connectors that are connected at build time (coworker/agent.py:425-445). Two code paths leave that cache stale:

  1. POST /v1/connectors/{name}/connect (coworker/server/app.py:1601-1613) stores the credentials and refreshes two-way listeners. It does not call _refresh_session_tools for live sessions.
  2. inbox_connector_requester returns early when the connector is already connected (coworker/server/manager.py:1999-2000). The normal approval path calls self._refresh_session_tools(session_id) at line 2025; the early return skips it.

_refresh_session_tools has three callers: the sandbox provider change, a worker grant, and the approved request_connector path. No Settings connector endpoint reaches it.

Suggested fix

  • In the "already connected" branch, check whether the session's engine already has the connector's tools. If it does not, call _refresh_session_tools(session_id) and return the "its tools are available from your next turn" note.
  • After a successful connect from Settings, refresh the tools of every live session, in the way the sandbox provider change does at manager.py:876-886.

The disconnect endpoint (app.py:1846) and the per-tool toggles (PATCH /v1/connectors/{name}/tools, app.py:2416) also skip the refresh. I have read those paths but have not reproduced a fault through them.

Workaround

Start a new session, or quit and relaunch openworker so that the existing session rebuilds its engine.

liquidaty avatar Dec 03 '26 22:12 liquidaty