Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/bedrock_agentcore/runtime/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ def entrypoint(self, func: Callable) -> Callable:
The decorated function with added serve method
"""
self.handlers["main"] = func
func.run = lambda port=8080, host=None: self.run(port, host)
try:
func.run = lambda port=8080, host=None: self.run(port, host)
except AttributeError:
pass
return func

def ping(self, func: Callable) -> Callable:
Expand Down
15 changes: 15 additions & 0 deletions tests/bedrock_agentcore/runtime/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ def test_handler(payload):
assert hasattr(test_handler, "run")
assert callable(test_handler.run)

def test_entrypoint_bound_method(self):
"""Test entrypoint accepts a bound method without raising AttributeError."""

class MyAgent:
def __init__(self):
self.app = BedrockAgentCoreApp()
self.app.entrypoint(self.handle)

def handle(self, payload):
return {"result": "success"}

agent = MyAgent()
assert "main" in agent.app.handlers
assert agent.app.handlers["main"] == agent.handle

def test_invocation_without_context(self):
"""Test handler without context parameter works correctly."""
bedrock_agentcore = BedrockAgentCoreApp()
Expand Down
Loading