Connecting a connector from Settings leaves open sessions without its tools, and `request_connector` then reports "connected" indefinitely
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.readonlyscope) - Persona: Cowork
Steps to reproduce
- Start a session with no Gmail connector configured.
- Ask for something that needs Gmail, so the agent reports that it has no Gmail tools.
- 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.
- 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:
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_toolsfor live sessions.inbox_connector_requesterreturns early when the connector is already connected (coworker/server/manager.py:1999-2000). The normal approval path callsself._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.