Skip to content

Commit 5b0fe65

Browse files
committed
Add Snipsync markers to AgentCore Worker
1 parent 77768ed commit 5b0fe65

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

bedrock_agentcore/strands-agent/agentcore_worker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def required_env(key: str) -> str:
4747
DEPLOYMENT_NAME = os.environ.get("TEMPORAL_DEPLOYMENT_NAME", workflows.DEPLOYMENT_NAME)
4848
BUILD_ID = os.environ.get("TEMPORAL_BUILD_ID", workflows.BUILD_ID)
4949

50+
# @@@SNIPSTART python-agentcore-activity-tracker
5051
# How long the Worker keeps polling after it goes idle.
5152
DEBOUNCE = float(os.environ.get("AGENTCORE_DEBOUNCE_SECONDS", "60"))
5253
# How long the drain waits for in-flight Activities (a model or tool call).
@@ -94,8 +95,10 @@ async def execute_activity(self, input: ExecuteActivityInput):
9495
finally:
9596
self._tracker.inflight -= 1
9697
self._tracker.changed.set()
98+
# @@@SNIPEND
9799

98100

101+
# @@@SNIPSTART python-agentcore-runtime-handler
99102
@app.entrypoint
100103
@app.async_task # keeps /ping on "HealthyBusy" until this returns
101104
async def invoke(payload: dict) -> dict:
@@ -135,6 +138,7 @@ async def invoke(payload: dict) -> dict:
135138
await tracker.wait_until_idle(DEBOUNCE)
136139
log.info("worker idle for %ss; drained", DEBOUNCE)
137140
return {"message": "worker drained", "task_queue": task_queue}
141+
# @@@SNIPEND
138142

139143

140144
if __name__ == "__main__":

0 commit comments

Comments
 (0)