windmill-labs/windmill · error

AI response was empty

Error message

AI response was empty

What it means

AIChatManager.sendInlineRequest streams the model's reply via the onNewToken callback accumulating into `reply`. After chatRequest resolves, it validates that some non-whitespace text was received. If the stream produced nothing (empty completion), this error is thrown to signal that the inline code-edit request got no usable AI output.

Source

Thrown at frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts:2829

			const params = {
				messages,
				abortController: this.inlineAbortController,
				callbacks: {
					onNewToken: (token: string) => {
						reply += token
					},
					onMessageEnd: () => {},
					setToolStatus: () => {},
					removeToolStatus: () => {}
				},
				systemMessage
			}

			await this.chatRequest({ ...params })

			// Validate we received a response
			if (!reply.trim()) {
				throw new Error('AI response was empty')
			}

			// Try to extract new code from response
			const newCodeMatch = reply.match(/<new_code>([\s\S]*?)<\/new_code>/i)
			if (newCodeMatch && newCodeMatch[1]) {
				const code = newCodeMatch[1].trim()
				if (!code) {
					throw new Error('AI response contained empty code block')
				}
				return code
			}

			// Fallback: try to take everything after the last <new_code> tag
			const lastNewCodeMatch = reply.match(/<new_code>([\s\S]*)/i)
			if (lastNewCodeMatch && lastNewCodeMatch[1]) {
				const code = lastNewCodeMatch[1].trim().replace(/```/g, '')
				if (!code) {
					throw new Error('AI response contained empty code block')

View on GitHub (pinned to e474e8803c)

Solutions

  1. Retry the inline request; transient provider issues often cause empty completions.
  2. Check the workspace AI provider/model configuration (API key, base URL, model name) and test it.
  3. Inspect the browser console for the 'chatRequest error' log emitted just before the throw to find the upstream cause.
  4. Reduce prompt size (smaller selection/context) and resend.

Example fix

// before
const code = await manager.sendInlineRequest(instructions, selected, selection)
// after
let code
try {
  code = await manager.sendInlineRequest(instructions, selected, selection)
} catch (e) {
  if (e.message === 'AI response was empty') {
    notify('AI returned no output — please retry')
    return
  }
  throw e
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  const code = await manager.sendInlineRequest(instr, sel, selection)
} catch (e) {
  if (e.message === 'AI response was empty') { retryOrNotify(); return }
  throw e
}

Prevention

When it happens

Trigger: Calling sendInlineRequest and the LLM completion finishes with zero tokens: the backend returns an empty completion, the model is misconfigured/unavailable and silently returns nothing, or all streamed tokens are whitespace.

Common situations: Model provider outage or rate limit swallowed upstream, an AI model configured in workspace settings that returns empty responses, prompt so large the provider truncates to nothing, or a proxy/gateway returning 200 with an empty body.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/3265aa31022e0406. Report an issue: GitHub.