Skip to content

fix(desktop): scope -32001 mesh denial copy to mesh agents - #4273

Open
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:fix/4205-nonmesh-llm-auth-copy
Open

fix(desktop): scope -32001 mesh denial copy to mesh agents#4273
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:fix/4205-nonmesh-llm-auth-copy

Conversation

@iroiro147

Copy link
Copy Markdown

What

When a managed agent's underlying LLM call returns 401/403, buzz-agent classifies it as JSON-RPC -32001 (AgentError::LlmAuth, crates/buzz-agent/src/types.rs:390). The desktop supervisor recovers that into ManagedAgent.lastErrorCode and friendlyAgentLastError rewrites every -32001 to RELAY_MESH_DENIED_COPY = "Community access denied this agent — check its community membership.", regardless of provider.

That's wrong for non-mesh agents whose 401 came from their own upstream (their own llama.cpp, api.openai.com with a bad key, a Databricks host, …). The reporter in #4205 runs a Local OpenAI-compatible agent against llama.cpp at 127.0.0.1:8082; llama.cpp rejected with {"message":"multi-user-authorization"} (its multi-user key mismatch), and Buzz rewrote that to "Community access denied" — pointing the reporter at the wrong codepath entirely.

This PR makes the rewrite provider-aware: only provider === "relay-mesh" gets the mesh copy; other providers keep the raw error verbatim so the reporter sees the actionable upstream message. The legacy pre-code string fallback ("llm auth:" prefix) gets the same gate.

Changes

  • desktop/src/features/agents/lib/friendlyAgentLastError.ts: add optional provider param; gate -32001 rewrite and the legacy-string fallback on provider === "relay-mesh". friendlyTurnErrorCopy gains a matching optional provider param and threads it through.
  • desktop/src/features/agents/ui/ManagedAgentRow.tsx, UnifiedAgentsSection.tsx: pass agent.provider.
  • Tests: added a regression mirroring the reporter's lane (non-mesh provider + -32001 → preserved raw message, not mesh copy) plus null-provider conservative passthrough. Existing mesh-denied tests kept by passing "relay-mesh" explicitly.

agentSessionTranscript.ts (transcript path) doesn't have agent metadata handy and now falls through to raw for all providers, which is the conservative direction — better more detail to a mesh user than less to a non-mesh one.

Tests

  • desktop/node --import ./test-loader.mjs --experimental-strip-types --test "src/features/agents/lib/friendlyAgentLastError.test.mjs" → 36/36
  • Full webview suite: 3934/3934
  • pnpm exec tsc --noEmit clean

Why not change the agent instead

The -32001 code is correct — it really is an auth failure. The bug was purely in the desktop rewriting layer claiming all 401s are community-gating. Mesh's specific copy stays valuable for mesh agents, where "community membership" really is the next thing to check.

Fixes #4205

Signed-off-by: Sarthak Singh sarthak.singh@juspay.in

When a managed agent's underlying LLM call returns 401/403, buzz-agent
classifies it as JSON-RPC -32001 and the desktop previously rewrote that
to "Community access denied this agent — check its community membership."
for every agent, regardless of provider. That misleads the "Local
OpenAI-compatible" lane where the 401 came from the user's own upstream
(e.g. llama.cpp started with `--api-key`): the reporter's actual fix is
"your configured key doesn't match the server's", but the rewritten copy
points them at community membership — an unrelated codepath (see block#4205).

`friendlyAgentLastError` and `friendlyTurnErrorCopy` now accept the
agent's configured LLM provider and only substitute the mesh copy when
`provider === "relay-mesh"`; all other providers keep the raw error
verbatim. The legacy string fallback for pre-code records (`"llm auth:"`
prefix) gets the same gate so the conservative behavior is consistent.

Callers in ManagedAgentRow and UnifiedAgentsSection thread
`agent.provider` through. Tests mirror the reporter's lane (non-mesh +
-32001 → preserved) and the mesh case stays regression-tested.

http://github.com/block/buzz/issues/4205

Signed-off-by: Sarthak Singh <sarthak.singh@juspay.in>
@iroiro147
iroiro147 requested a review from a team as a code owner August 2, 2026 07:38
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.

Local OpenAI-compatible agent fails with community access error

1 participant