Skip to content

❗ NOTICE: stepfunctions-tasks: BedrockInvokeModel outputPath no longer passes output to next stateΒ #31302

@clareliguori

Description

@clareliguori

Please add your +1 πŸ‘ to let us know you have encountered this

Status: IN-PROGRESS

Overview:

Previously, the BedrockInvokeModel outputPath parameter could be used to select a portion of the model output to pass to the next state. This behavior aligns with how the parameter is documented "JSONPath expression to select select a portion of the state output to pass to the next state."
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions_tasks.BedrockInvokeModel.html#outputpath

Now, the outputPath parameter is assumed to be an S3Uri where the model output should be saved. The parameter can no longer be used to select model output and pass it to the next state.

This behavior appears to have changed in f5dd73b

Complete Error Message:

Workaround:

Solution:

Revert existing code for encoding the path under S3Uri, and possibly introduce another variable in BedrockTaskProps instead of extending the existing TaskStateBaseProps.

Related Issues:

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

2.150.0

Expected Behavior

In a BedrockInvokeModel task, set outputPath:

# Extract the response from the model
output_path="$.Body.content[0].text",

The Step Functions workflow definition is synthesized as:

"OutputPath": "$.Body.content[0].text",

When I execute the deployed Step Functions state machine, the model text output is passed as the output of the task.

"Here is a one sentence summary of ...."

Current Behavior

The outputPath parameter is synthesized as:

"Output": {
   "S3Uri": "$.Body.content[0].text"
}

When I execute the deployed Step Functions state machine, I get a validation exception:

The value for the S3Uri field is not recognized as a valid URI: $.Body.content[0].text

Reproduction Steps

This is my stack:
https://github.com/aws-samples/amazon-bedrock-serverless-prompt-chaining/blob/main/techniques/stacks/model_invocation.py

Possible Solution

I suggest reverting the change above, so that outputPath works as documented and expected. The input and output parameters were intended to distinguish between state that should be passed between states (inputPath/outputPath) vs destinations where input and output should be sourced from (input/output).

Additional Information/Context

No response

CDK CLI Version

2.155.0

Framework Version

No response

Node.js Version

v20.17.0

OS

Linux

Language

Python

Language Version

Python 3.12.3

Other information

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions