Budibase/budibase · error · Error

Invalid agent request link response: unknown requestId "${de

Error message

Invalid agent request link response: unknown requestId "${decision.requestId}"

What it means

After parsing the LLM link decision, analyzeAgentRequestLink verifies that a decision of "existing_thread" references a requestId actually present in candidateRequests. If the model hallucinates or returns a requestId not among the candidates, it throws Error(`Invalid agent request link response: unknown requestId "${decision.requestId}"`).

Source

Thrown at packages/server/src/sdk/workspace/ai/agentRequests/helpers.ts:140

  } catch (error) {
    console.error("Failed to analyze agent request link", {
      agentId,
      sessionId,
      error,
    })
    throw error
  }

  const decision = extractJson(result.text || "")
  if (!decision) {
    throw new Error("Invalid agent request link response")
  }

  if (
    decision.decision === "existing_thread" &&
    !candidateRequests.some(request => request._id === decision.requestId)
  ) {
    throw new Error(
      `Invalid agent request link response: unknown requestId "${decision.requestId}"`
    )
  }

  return {
    decision: decision.decision,
    requestId: decision.requestId,
    entryAction: decision.entryAction,
  }
}

export async function generateAgentRequestTitle({
  latestPrompt,
  agentId,
  sessionId,
  operation,
}: {
  latestPrompt: string

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Catch the error and fall back to decision "new_thread"
  2. Retry the analysis call; if it recurs, disable request linking for the model config
  3. Use a stronger model that respects the candidate list, or include only clearly-labeled candidate IDs in the prompt

Example fix

// before
const analysis = await analyzeAgentRequestLink({ candidateRequests, ... })
// after
let analysis
try {
  analysis = await analyzeAgentRequestLink({ candidateRequests, ... })
} catch {
  analysis = { decision: "new_thread" }
}
Defensive patterns

Strategy: fallback

Try / catch

let analysis
try {
  analysis = await analyzeAgentRequestLink({ latestPrompt, candidateRequests, ... })
} catch (err) {
  if (err instanceof Error && err.message.includes("unknown requestId")) {
    analysis = { decision: "new_thread" }
  } else {
    throw err
  }
}

Prevention

When it happens

Trigger: The LLM returns {"decision":"existing_thread","requestId":"..."} where the ID is fabricated, from another session, truncated, or not in the candidate list passed to the function.

Common situations: Hallucinated IDs from smaller models; candidates filtered down between analysis and validation; the model echoing an ID from recentChatContext instead of candidateRequests.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/8483325b27de76a8. Report an issue: GitHub.