Budibase/budibase · error
Invalid agent request link response
Error message
Invalid agent request link response
What it means
analyzeAgentRequestLink asks an LLM to decide whether a prompt belongs to an existing agent request thread, expecting a strict JSON reply. extractJson parses and validates that reply; if it cannot produce a valid decision object (missing/unknown decision value, or existing_thread without requestId/entryAction), the function throws Error("Invalid agent request link response").
Source
Thrown at packages/server/src/sdk/workspace/ai/agentRequests/helpers.ts:133
prompt: JSON.stringify({
currentSessionId: sessionId,
latestPrompt: normalizedPrompt,
recentChatContext,
candidateRequests: candidateRequests.map(buildCandidateSummary),
}),
})
} 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,
}
}
View on GitHub (pinned to a81a902e9a)
Solutions
- Use a model/aiconfig that reliably follows JSON-only instructions; raise temperature constraints if configurable
- Catch the error and fall back to decision "new_thread" so the agent flow continues
- Retry the generateText call once on failure
- Strengthen output handling: request structured output / response_format JSON if the provider supports it
Example fix
// before
const analysis = await analyzeAgentRequestLink({...}) // throws on bad LLM reply
// after
let analysis
try {
analysis = await analyzeAgentRequestLink({...})
} 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 === "Invalid agent request link response") {
analysis = { decision: "new_thread" }
} else {
throw err
}
} Prevention
- Configure a model that reliably emits strict JSON for the agent's aiconfig
- Prefer provider JSON/structured output modes when available
- Always define a safe default decision (new_thread) for link analysis failures
When it happens
Trigger: The LLM returns prose instead of JSON, malformed JSON, a decision value other than existing_thread/new_thread, or existing_thread without a valid requestId and entryAction.
Common situations: A weak or non-instruct-tuning-capable model ignoring the JSON-only instruction; the model wraps JSON in markdown fences or adds commentary (only the first {...} block is extracted); truncated responses cutting off the JSON.
Related errors
- Invalid agent request link response: unknown requestId "${de
- Invalid agent request title response
- Invalid tool call summary response
- Error generating tables
- LLM not available
AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29).
Data as JSON: /api/errors/4c8d3bfe91ffba9a.
Report an issue: GitHub.