Skip to content

Commit 34948d7

Browse files
committed
remove body message
1 parent 86c7ab7 commit 34948d7

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

aws_lambda_powertools/event_handler/bedrock_agent_function.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,6 @@ def _resolve(self) -> dict[str, Any]:
174174

175175
function_name = self.current_event.function
176176

177-
if function_name not in self._tools:
178-
return BedrockFunctionsResponseBuilder(
179-
BedrockFunctionResponse(
180-
body=f"Function not found: {function_name}",
181-
),
182-
).build(self.current_event)
183-
184177
try:
185178
result = self._tools[function_name]["function"]()
186179
return BedrockFunctionsResponseBuilder(result).build(self.current_event)

tests/functional/event_handler/required_dependencies/test_bedrock_agent_functions.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def error_function():
3838
return BedrockFunctionResponse(
3939
body="Invalid input",
4040
response_state="REPROMPT",
41-
session_attributes={"error": "true"}
41+
session_attributes={"error": "true"},
4242
)
4343

4444
@app.tool(description="Function that raises error")
@@ -61,6 +61,7 @@ def test_bedrock_agent_function_registration():
6161

6262
# WHEN registering without description or with duplicate name
6363
with pytest.raises(ValueError, match="Tool description is required"):
64+
6465
@app.tool()
6566
def test_function():
6667
return "test"
@@ -70,6 +71,7 @@ def first_function():
7071
return "test"
7172

7273
with pytest.raises(ValueError, match="Tool 'custom' already registered"):
74+
7375
@app.tool(name="custom", description="Second registration")
7476
def second_function():
7577
return "test"
@@ -85,12 +87,12 @@ def test_function():
8587
body="Hello",
8688
session_attributes={"userId": "123"},
8789
prompt_session_attributes={"context": "test"},
88-
knowledge_bases=[{
89-
"knowledgeBaseId": "kb1",
90-
"retrievalConfiguration": {
91-
"vectorSearchConfiguration": {"numberOfResults": 5}
92-
}
93-
}]
90+
knowledge_bases=[
91+
{
92+
"knowledgeBaseId": "kb1",
93+
"retrievalConfiguration": {"vectorSearchConfiguration": {"numberOfResults": 5}},
94+
},
95+
],
9496
)
9597

9698
# WHEN calling the event handler
@@ -111,4 +113,4 @@ def test_bedrock_agent_function_invalid_event():
111113

112114
# WHEN calling with invalid event
113115
with pytest.raises(ValueError, match="Missing required field"):
114-
app.resolve({}, {})
116+
app.resolve({}, {})

0 commit comments

Comments
 (0)