File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -499,7 +499,7 @@ def _prepare_options(
499499 # client_kwargs) join the request before the prompt-ARN cleanup so that
500500 # branch still strips fields Converse rejects, mirroring the other clients.
501501 run_options .update (kwargs )
502- if ":prompt/" in model :
502+ if ":prompt/" in run_options [ "modelId" ] :
503503 # A Prompt Management ARN takes these fields from the prompt, and Converse rejects requests that set them.
504504 if run_options ["inferenceConfig" ] == {"maxTokens" : DEFAULT_MAX_TOKENS }:
505505 del run_options ["inferenceConfig" ] # only the client default, nothing the caller asked for
Original file line number Diff line number Diff line change @@ -1031,3 +1031,20 @@ def test_prepare_options_keeps_per_call_client_kwargs() -> None:
10311031
10321032 assert request ["guardrailConfig" ] == {"guardrailIdentifier" : "gr-1" , "guardrailVersion" : "DRAFT" }
10331033 assert request ["requestMetadata" ] == {"channel" : "test" }
1034+
1035+
1036+ def test_prepare_options_prompt_cleanup_uses_overridden_model_id () -> None :
1037+ """A prompt ARN arriving through client kwargs must trigger the ARN cleanup (#9344)."""
1038+ client = _make_client ()
1039+ messages = [Message (role = "user" , contents = [Content .from_text (text = "hello" )])]
1040+
1041+ request = client ._prepare_options (
1042+ messages ,
1043+ {},
1044+ modelId = "arn:aws:bedrock:us-east-1:123456789012:prompt/PROMPT123" ,
1045+ )
1046+
1047+ assert ":prompt/" in request ["modelId" ]
1048+ assert "inferenceConfig" not in request , "prompt ARN requests must not carry inferenceConfig"
1049+ assert "system" not in request
1050+ assert "toolConfig" not in request
You can’t perform that action at this time.
0 commit comments