Skip to content

WIP - Make connector AUTH_REQUIRED explicit in run_tool#16

Draft
eshwar-sundar-glean wants to merge 3 commits into
mainfrom
eshwar/connector-auth-elicitation
Draft

WIP - Make connector AUTH_REQUIRED explicit in run_tool#16
eshwar-sundar-glean wants to merge 3 commits into
mainfrom
eshwar/connector-auth-elicitation

Conversation

@eshwar-sundar-glean

Copy link
Copy Markdown
Collaborator

Summary

Makes downstream connector authorization explicit in run_tool. When a
connector (Jira/Slack/Salesforce via the Glean gateway) needs the user to
authorize their account — even though Glean itself is already authenticated
the gateway returns an isError result whose text is a JSON envelope with
authUrls. Previously the plugin passed this straight through, and the model
could under-surface it or confuse it with the plugin's own [SETUP_REQUIRED]
(Glean sign-in) and wrongly call setup
.

handleRunTool now detects that result and:

  1. Always appends a disambiguation note as an extra text block so the model
    gets the message regardless of client capabilities:

    NOTE: This is NOT [SETUP_REQUIRED]. Glean itself is already authenticated —
    only this downstream tool/connector needs authorization. Do NOT call
    setup. Show the link(s) above, have the user authorize, then retry this
    tool.

  2. If the client supports elicitation, fires a single best-effort
    form/confirm dialog surfacing the connector-auth requirement (accept /
    decline / timeout are ignored — the suffixed result is returned regardless).
  3. Is always-on — not gated by ENABLE_HITL (this is surfacing, not an
    approval gate).

Normal results and ordinary (non-authUrls) errors pass through unchanged.

Detection

result.isError === true AND the first text content parses as JSON with a
non-empty authUrls: string[]. Reuses the existing elicitation gate
(getClientCapabilities()?.elicitation) and hitlTimeoutMs() from the HITL
path.

Follow-up (noted, not in this PR): the gateway also sets an AUTH_REQUIRED
marker on the result _meta; keying on that would be more robust (and would
catch the no-authUrls fallback message). The exact _meta field name needs
confirming from a live response.

Changes

  • src/tools/run-tool.tsparseConnectorAuth, withConnectorAuthSuffix,
    connectorAuthPrompt, CONNECTOR_AUTH_SUFFIX; handleRunTool tail now
    captures the result, surfaces connector auth, and returns the suffixed result.
  • tests/run-tool.test.ts — 5 new cases (elicit + suffix; no-elicitation client;
    declined/errored dialog still suffixed; normal result unchanged; non-JSON error
    unchanged).
  • Plugin manifests bumped 0.2.26 → 0.2.27 (aligned); dist rebuilt.

Testing

  • npm run typecheck — clean.
  • npm test — 141/141 passing.
  • npm run build — dist in sync (esbuild 0.28.1).
  • bash scripts/check-version-bump.sh origin/main0.2.26 → 0.2.27 (all manifests aligned).

When a downstream connector (Jira/Slack/...) needs the user to authorize their
account, the Glean gateway returns an error result whose text is a JSON
envelope with authUrls. handleRunTool now detects that, fires a best-effort
informational elicitation dialog (when the client supports it), and appends a
disambiguation note so the model surfaces the connector sign-in and does NOT
confuse it with the plugin's own [SETUP_REQUIRED] Glean sign-in (i.e. does not
wrongly call setup). Always-on; not gated by ENABLE_HITL.

Detection keys on isError + a parseable authUrls array in the result text.
Bump plugin manifests to 0.2.27.
@eshwar-sundar-glean eshwar-sundar-glean marked this pull request as draft June 20, 2026 09:56
@eshwar-sundar-glean eshwar-sundar-glean changed the title Make connector AUTH_REQUIRED explicit in run_tool WIP - Make connector AUTH_REQUIRED explicit in run_tool Jun 20, 2026
Comment thread src/tools/run-tool.ts Outdated
// Plain-text heads-up shown to the user when a connector needs authorization.
// No clickable URLs (clients don't render markdown in elicitation; the spec
// discourages URLs in form fields) — the links come from the result text.
function connectorAuthPrompt(toolName: string): string {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This is separate from Glean setup; Glean is already connected.)
This part is not required

Per review: remove the '(This is separate from Glean setup; Glean is already
connected.)' clause from the connector-auth elicitation message; update the
test assertion to match.
…the link

Drop the in-run_tool form dialog (it fired before the LLM rendered the auth
link). On a connector AUTH_REQUIRED result, run_tool now rewrites the content
into a clickable Markdown link plus instructions to render it, call the new
request_auth_confirmation tool, and retry — replacing the backend's raw JSON
envelope (which rendered as a non-clickable link) while preserving isError and
_meta.

request_auth_confirmation is a new static tool that shows the confirm dialog
AFTER the link is visible (accept = Done; declines/no-capability fall back to a
chat prompt). Tests updated accordingly.
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.

1 participant