microsoft/semantic-kernel · error · AgentInvokeException
Function call is expected but not found in the response.
Error message
Function call is expected but not found in the response.
What it means
Raised by _handle_return_control_event when parse_return_control_payload returns an empty list. parse_return_control_payload iterates over return_control_payload.get('invocationInputs', []); if invocationInputs is missing or empty, no FunctionCallContent objects are produced, yet the event was classified as a RETURN_CONTROL event, which is contradictory.
Source
Thrown at python/semantic_kernel/agents/bedrock/bedrock_agent.py:577
role=AuthorRole.ASSISTANT,
content=completion,
name=self.name,
inner_content=event,
ai_model_id=self.agent_model.foundation_model,
metadata=chunk,
)
async def _handle_return_control_event(
self,
event: dict[str, Any],
kernel: Kernel,
kernel_arguments: KernelArguments,
) -> dict[str, Any]:
"""Handle return control event."""
return_control_payload = event[BedrockAgentEventType.RETURN_CONTROL]
function_calls = parse_return_control_payload(return_control_payload)
if not function_calls:
raise AgentInvokeException("Function call is expected but not found in the response.")
function_result_contents = await self._handle_function_call_contents(function_calls)
return {
"invocationId": function_calls[0].id,
"returnControlInvocationResults": parse_function_result_contents(function_result_contents),
}
def _handle_files_event(self, event: dict[str, Any]) -> list[BinaryContent]:
"""Handle file event."""
files_event = event[BedrockAgentEventType.FILES]
return [
BinaryContent(
data=file["bytes"],
data_format="base64",
mime_type=file["type"],
metadata={"name": self._sanitize_filename(file["name"])},
)View on GitHub (pinned to c028a0c7dc)
Solutions
- Inspect the raw return_control_payload event to verify whether invocationInputs is present and populated.
- Verify the kernel function action group was created successfully and the function schema is registered with the agent.
- Re-create the agent's action group via create_kernel_function_action_group to ensure the schema is attached.
- If the issue is transient, retry the invocation; if persistent, check the Bedrock agent configuration in the AWS console.
Example fix
// before
# event = {'returnControl': {'invocationId': 'x', 'invocationInputs': []}}
# -> raises Function call is expected but not found
// after
# Debug before raising:
raw = await agent._invoke_agent(thread.id, "test")
for ev in raw.get('completion', []):
if 'returnControl' in ev:
print(ev['returnControl'].get('invocationInputs')) # inspect
# Then re-create the action group to fix schema registration Defensive patterns
Strategy: try-catch
Try / catch
from semantic_kernel.exceptions.agent_exceptions import AgentInvokeException
try:
resp = await agent.get_response(message=msg, thread=thread)
except AgentInvokeException as e:
if "Function call is expected but not found" in str(e):
# re-create the action group to ensure function schema is registered
await agent.create_kernel_function_action_group()
resp = await agent.get_response(message=msg, thread=thread)
else:
raise Prevention
- Ensure create_kernel_function_action_group succeeded so the function schema is registered with the Bedrock agent.
- Inspect RETURN_CONTROL payloads during development to confirm invocationInputs are populated.
- Re-prepare the agent after changing action groups.
When it happens
Trigger: Triggered when an event contains a 'returnControl' key but its payload has no 'invocationInputs' (or an empty list), so parse_return_control_payload yields [].
Common situations: The Bedrock service sent a malformed or empty RETURN_CONTROL event; the agent's action group/function schema is misconfigured so no function invocation input is included; an API version mismatch changes the payload shape; a race condition or partial response.
Related errors
- No function results were returned.
- Type {type_} is not allowed in bedrock function parameter ty
- Chat message content is expected but not found in the respon
- No response from the agent.
- Failed to get a response from the agent. Please consider inc
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/ae97e1c4ab69a0de.
Report an issue: GitHub.