crewAIInc/crewAI · error · BedrockAgentError

Unexpected error: {e!s}

Error message

Unexpected error: {e!s}

What it means

A BedrockAgentError raised as the catch-all for any non-ClientError, non-BedrockAgentError exception during _run (e.g. AttributeError, KeyError, TypeError, network errors from the stream). The original exception is chained with `from e`, and its str() is embedded after 'Unexpected error:'.

Source

Thrown at lib/crewai-tools/src/crewai_tools/aws/bedrock/agents/invoke_agent_tool.py:177

                )

            return completion

        except ClientError as e:
            error_code = "Unknown"
            error_message = str(e)

            # Try to extract error code if available
            if hasattr(e, "response") and "Error" in e.response:
                error_code = e.response["Error"].get("Code", "Unknown")
                error_message = e.response["Error"].get("Message", str(e))

            raise BedrockAgentError(f"Error ({error_code}): {error_message}") from e
        except BedrockAgentError:
            # Re-raise BedrockAgentError exceptions
            raise
        except Exception as e:
            raise BedrockAgentError(f"Unexpected error: {e!s}") from e

View on GitHub (pinned to 754d7323be)

Solutions

  1. Look at the chained cause in the traceback — the true exception type and line are there, not in the wrapper message.
  2. Upgrade boto3 and crewai-tools to current versions.
  3. If it reproduces, capture the raw response (wrap the call, log response keys) and report with the traceback.
  4. Retry once if the cause looks transient (connection reset).
Defensive patterns

Strategy: try-catch

Try / catch

try:
    result = tool._run(query)
except BedrockAgentError as e:
    cause = e.__cause__  # the real exception — inspect its type/traceback
    logger.exception("Bedrock tool crashed: %r", cause)
    raise

Prevention

When it happens

Trigger: Programming/environment errors inside _run: unexpected None in the response dict, a KeyError reading a missing response field, socket errors mid-stream that botocore does not classify as ClientError, or issues serializing the query.

Common situations: Library bugs against new AWS response shapes, partial network failures, or incompatible boto3 versions producing different event objects. The chained traceback (the `from e` cause) is essential to diagnose.

Related errors


AI-assisted analysis of crewAIInc/crewAI@754d7323be (2026-08-15). Data as JSON: /api/errors/fbb9f2571c293971. Report an issue: GitHub.