gitbutlerapp/gitbutler · error

The host rejected the request.

Error message

The host rejected the request.

What it means

handleAction sends a chat 'explain'/'review' request to the MCP host via app.sendMessage and throws a generic 'The host rejected the request.' when the returned result.isError is set. Unlike tool errors, the host's reason is not surfaced — the fixed message hides the underlying rejection cause.

Solutions

  1. Inspect the host/agent logs for the actual rejection reason — the thrown message is generic by design.
  2. Include textFromToolResult(result) (or the result's error content) in the thrown message to surface the real cause.
  3. Confirm the host session has an agent/model configured and is connected.
  4. Retry the send after the agent session is idle; verify the message content matches the host's expected schema.
  5. Disable or hide the Explain/Review actions when the host does not support chat.

Example fix

// before
if (result.isError) throw new Error("The host rejected the request.");
// after
if (result.isError) {
  const reason = result.content?.map((c) => c.text ?? "").join("\n").trim();
  throw new Error(reason || "The host rejected the request.");
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!app.isConnected?.()) { setDetailError("Agent host is not connected."); return; }
if (!chatSupported) { setDetailError("Chat is not available in this host."); return; }

Type guard

function isSendOk(result: unknown): result is { isError: false } {
  return typeof result === "object" && result !== null && (result as any).isError !== true;
}

Try / catch

try {
  const result = await app.sendMessage({ role: "user", content: [{ type: "text", text: request }] });
  if (result.isError) throw new Error(extractHostReason(result) ?? "The host rejected the request.");
} catch (caught) {
  setDetailError(caught instanceof Error ? caught.message : "Could not start the agent request.");
} finally {
  setPendingAction(null);
}

Prevention

When it happens

Trigger: The host returns isError for the chat message: no agent/model session available, the host disallows chat for this app state, invalid message content shape, or host-side agent failure.

Common situations: Operating the app in a host that has no agent/LLM configured; sending a prompt while the agent session is busy or terminated; the host denying message sends for permissions/quota reasons.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/bd9695d30d9c64a6. Report an issue: GitHub.

Appendix: source

Thrown at packages/but-mcp-app/src/WorkspaceApp.tsx:792

					await app.updateModelContext(selectionContext(view, selection));
				} catch {
					// The message below carries the same repository and selection context.
				}
			}
			const identifier = selectionIdentifier(selection);
			const subject =
				selection.kind === "commit"
					? `commit ${identifier}`
					: `branch ${identifier} against its configured target`;
			const request =
				action === "explain"
					? `Explain ${subject} in repository ${view.repository.path}. Describe its intent and the important changes.`
					: `Review ${subject} in repository ${view.repository.path} for correctness, regressions, and missing tests.`;
			const result = await app.sendMessage({
				role: "user",
				content: [{ type: "text", text: request }],
			});
			if (result.isError) throw new Error("The host rejected the request.");
		} catch (caught) {
			setDetailError(
				caught instanceof Error ? caught.message : "Could not start the agent request.",
			);
		} finally {
			setPendingAction(null);
		}
	}

	function clearSelection() {
		detailRequest.current += 1;
		setSelection(null);
		setDetail(null);
		setDetailError(null);
		setDetailLoading(false);
		setCopied(null);
		setPendingAction(null);
		if (canUpdateContext) {

View on GitHub (pinned to 58e5313667)