You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
code-mode runs (codebase documentation, outputMode: "repository") are handed the full set of external connector ingest tools — openwiki_ingest_connector (enum includes google, slack, x, notion, hackernews, web-search, git-repo), openwiki_ingest_all_connectors, and the MCP connector tools. A codebase-documentation agent reads a git repo and writes openwiki/*.md; it has no business ingesting Gmail/Slack/X and should never be offered those tools.
The toolset is built unconditionally: src/agent/index.ts:250 calls tools: createOpenWikiConnectorTools() with no dependence on the run mode/command, and createOpenWikiConnectorTools() (src/connectors/tools.ts:23) takes no mode argument. So personal (local-wiki) and code (repository) runs get an identical toolset.
The practical failure: under a large/--recursive codebase run the subagent machinery fans out, and a subagent can call openwiki_ingest_connector({connectorId:"google"}). With no connector credentials configured (a normal state for a pure codebase-doc run, e.g. CI), that path throws Gmail refresh token is required for OAuth refresh. (src/auth/tokens.ts:66-68, reached because isGmailEnabled defaults to enabled at src/connectors/sources/gmail.ts:331). Combined with the uncaught-tool-error behavior tracked in #426/#427, a single unwanted connector call terminates the entire run — after it may have executed for a long time and produced zero output.
This issue is specifically about mode-gating the toolset (the tools shouldn't be present in code mode at all). It is complementary to, not a duplicate of:
Gating (this issue) removes the tools from the mode where they make no sense; #427/#426 make whatever remains survivable. All three are worth fixing.
Steps to Reproduce
Build from source.
Run a code-mode codebase-documentation run (repository output mode) with no connector credentials configured, ideally --recursive over a large tree so subagents fan out.
If any (sub)agent calls openwiki_ingest_connector({connectorId:"google"}) (or openwiki_ingest_all_connectors), the connector path is entered even though this is a codebase-doc run.
Expected Behavior
code-mode (codebase documentation, outputMode: "repository") runs should not be offered external connector-ingest tools at all. Connector ingestion belongs to the personal/connector workflow (local-wiki).
Actual Behavior
code-mode agents receive the full connector-ingest toolset (openwiki_ingest_connector, openwiki_ingest_all_connectors, MCP connector tools). A subagent can invoke Gmail/Slack/X ingestion during what should be a pure git-repo → markdown run; with no credentials this throws and (via #426) can crash the whole run.
Environment
OS: Linux (ubuntu-latest CI); reproducible cross-platform
Node.js version: 22.x
OpenWiki version: 0.2.x (main); createOpenWikiConnectorTools call site unchanged across 0.1.x–0.2.x
Additional Context
Relevant source (main):
src/agent/index.ts:250 — tools: createOpenWikiConnectorTools() (unconditional; outputMode is already in scope at runOpenWikiAgentCore line ~213 and is the natural gating axis — "repository" = code mode).
src/connectors/tools.ts:23 — createOpenWikiConnectorTools() takes no mode arg; openwiki_ingest_connector enum at lines 96–104.
src/connectors/sources/gmail.ts:122 → getOAuthAccessToken("gmail"); :331isGmailEnabled defaults to enabled.
src/auth/tokens.ts:66-68 — throws when refresh token is absent.
Suggested fix: pass the run mode/outputMode into createOpenWikiConnectorTools() (or filter at the createDeepAgent call site) so repository/code runs get no connector-ingest tools. A per-mode allowlist would also cover the MCP connector tools.
Description
code-mode runs (codebase documentation,outputMode: "repository") are handed the full set of external connector ingest tools —openwiki_ingest_connector(enum includesgoogle,slack,x,notion,hackernews,web-search,git-repo),openwiki_ingest_all_connectors, and the MCP connector tools. A codebase-documentation agent reads a git repo and writesopenwiki/*.md; it has no business ingesting Gmail/Slack/X and should never be offered those tools.The toolset is built unconditionally:
src/agent/index.ts:250callstools: createOpenWikiConnectorTools()with no dependence on the run mode/command, andcreateOpenWikiConnectorTools()(src/connectors/tools.ts:23) takes no mode argument. Sopersonal(local-wiki) andcode(repository) runs get an identical toolset.The practical failure: under a large/
--recursivecodebase run the subagent machinery fans out, and a subagent can callopenwiki_ingest_connector({connectorId:"google"}). With no connector credentials configured (a normal state for a pure codebase-doc run, e.g. CI), that path throwsGmail refresh token is required for OAuth refresh.(src/auth/tokens.ts:66-68, reached becauseisGmailEnableddefaults to enabled atsrc/connectors/sources/gmail.ts:331). Combined with the uncaught-tool-error behavior tracked in #426/#427, a single unwanted connector call terminates the entire run — after it may have executed for a long time and produced zero output.This issue is specifically about mode-gating the toolset (the tools shouldn't be present in
codemode at all). It is complementary to, not a duplicate of:Gating (this issue) removes the tools from the mode where they make no sense; #427/#426 make whatever remains survivable. All three are worth fixing.
Steps to Reproduce
code-mode codebase-documentation run (repositoryoutput mode) with no connector credentials configured, ideally--recursiveover a large tree so subagents fan out.openwiki_ingest_connector({connectorId:"google"})(oropenwiki_ingest_all_connectors), the connector path is entered even though this is a codebase-doc run.Expected Behavior
code-mode (codebase documentation,outputMode: "repository") runs should not be offered external connector-ingest tools at all. Connector ingestion belongs to thepersonal/connector workflow (local-wiki).Actual Behavior
code-mode agents receive the full connector-ingest toolset (openwiki_ingest_connector,openwiki_ingest_all_connectors, MCP connector tools). A subagent can invoke Gmail/Slack/X ingestion during what should be a pure git-repo → markdown run; with no credentials this throws and (via #426) can crash the whole run.Environment
createOpenWikiConnectorToolscall site unchanged across 0.1.x–0.2.xAdditional Context
Relevant source (main):
src/agent/index.ts:250—tools: createOpenWikiConnectorTools()(unconditional;outputModeis already in scope atrunOpenWikiAgentCoreline ~213 and is the natural gating axis —"repository"= code mode).src/connectors/tools.ts:23—createOpenWikiConnectorTools()takes no mode arg;openwiki_ingest_connectorenum at lines 96–104.src/connectors/tools.ts:241-248—ingestConnectorcallsregistry[connectorId].ingest(options)with no try/catch. NoteingestAllConnectors(lines 270–281) is also an unguarded loop — neither single- nor all-connector ingest isolates a per-connector failure (relevant to Connector tools throw instead of returning errors as tool results, so the model can't self-correct (e.g. wrong MCP tool name) #427).src/connectors/sources/gmail.ts:122→getOAuthAccessToken("gmail");:331isGmailEnableddefaults to enabled.src/auth/tokens.ts:66-68— throws when refresh token is absent.Suggested fix: pass the run mode/
outputModeintocreateOpenWikiConnectorTools()(or filter at thecreateDeepAgentcall site) sorepository/code runs get no connector-ingest tools. A per-mode allowlist would also cover the MCP connector tools.