microsoft/semantic-kernel · error · KernelException
Run failed with status: `{response.Status}` for agent `{agen
Error message
Run failed with status: `{response.Status}` for agent `{agent.Name}` with error: {response.Error.Message} or incomplete details: {response.IncompleteStatusDetails.Reason} What it means
ResponseThreadActions.ThrowIfIncompleteOrFailed fires when an OpenAI Responses-API result has a status of Incomplete or Failed. It throws a KernelException including the agent name, the error message, and the incomplete-status reason.
Source
Thrown at dotnet/src/Agents/OpenAI/Internal/ResponseThreadActions.cs:316
yield return streamingFunctionResultMessage;
}
}
private static ChatHistory GetChatHistory(AgentThread agentThread)
{
if (agentThread is ChatHistoryAgentThread chatHistoryAgentThread)
{
return chatHistoryAgentThread.ChatHistory;
}
throw new InvalidOperationException("The agent thread is not a ChatHistoryAgentThread.");
}
private static void ThrowIfIncompleteOrFailed(OpenAIResponseAgent agent, ResponseResult response)
{
if (response.Status is ResponseStatus.Incomplete or ResponseStatus.Failed)
{
throw new KernelException(
$"Run failed with status: `{response.Status}` for agent `{agent.Name}` with error: {response.Error.Message} or incomplete details: {response.IncompleteStatusDetails.Reason}");
}
}
/// <summary>
/// Processes a function result and returns a string representation.
/// The OpenAI Responses API does not support multimodal tool results, so ImageContent returns an error message.
/// </summary>
internal static string GetFunctionResultAsString(object? result)
{
var processed = FunctionCallsProcessor.ProcessFunctionResult(result ?? string.Empty);
if (processed is ImageContent)
{
return FunctionCallsProcessor.ImageContentNotSupportedErrorMessage;
}
return (string?)processed ?? string.Empty;View on GitHub (pinned to c028a0c7dc)
Solutions
- Inspect response.Status, response.Error.Message, and response.IncompleteStatusDetails.Reason in the exception.
- Increase max_output_tokens (or prompt execution settings) if the cause is Incomplete due to length.
- Adjust prompt/content if a content filter triggered.
- Retry transient Failed responses with backoff.
Example fix
// before
var result = await agent.InvokeAsync(thread);
// after
try {
var result = await agent.InvokeAsync(thread);
}
catch (KernelException ex) when (ex.Message.Contains("Run failed with status")) {
logger.LogError(ex, "Responses run failed/incomplete");
// raise max_output_tokens or adjust prompt, then retry
} Defensive patterns
Strategy: try-catch
Try / catch
try { var result = await agent.InvokeAsync(thread); }
catch (KernelException ex) when (ex.Message.Contains("Run failed with status")) {
logger.LogError(ex, "Responses run failed/incomplete; raise max_output_tokens or adjust prompt");
} Prevention
- Set max_output_tokens high enough to avoid Incomplete-by-length.
- Review prompts for content that may trip filters.
- Log Status/Error/IncompleteStatusDetails from the exception.
When it happens
Trigger: A Responses-API call returns Incomplete (e.g., max_output_tokens reached, content filter, incomplete reason) or Failed (service/model error) for the agent invocation.
Common situations: Output token limit too low triggering Incomplete; content-policy block; model/endpoint error; malformed request causing failure.
Related errors
- OPENAI_API_KEY is not set.
- Unsupported role {message.Role.Label}. Only system, user, de
- The agent thread is not a ChatHistoryAgentThread.
- {type(self)} service encountered a content error
- AZURE_OPENAI_ENDPOINT is not set.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/b1fd4df1e2eff579.
Report an issue: GitHub.