Skip to content

Commit 3ae8d77

Browse files
authored
iterative event loop (#268)
1 parent df7c327 commit 3ae8d77

File tree

8 files changed

+277
-366
lines changed

8 files changed

+277
-366
lines changed

.github/workflows/integration-test.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ name: Secure Integration test
33
on:
44
pull_request_target:
55
branches: main
6-
6+
77
jobs:
88
authorization-check:
99
permissions: read-all
1010
runs-on: ubuntu-latest
11-
outputs:
11+
outputs:
1212
approval-env: ${{ steps.collab-check.outputs.result }}
1313
steps:
1414
- name: Collaborator Check
1515
uses: actions/github-script@v7
1616
id: collab-check
1717
with:
1818
result-encoding: string
19-
script: |
19+
script: |
2020
try {
2121
const permissionResponse = await github.rest.repos.getCollaboratorPermissionLevel({
2222
owner: context.repo.owner,
@@ -31,7 +31,7 @@ jobs:
3131
} else {
3232
console.log(`Verifed ${context.payload.pull_request.user.login} has write access. Auto Approving PR Checks.`)
3333
return "auto-approve"
34-
}
34+
}
3535
} catch (error) {
3636
console.log(`${context.payload.pull_request.user.login} does not have write access. Requiring Manual Approval to run PR Checks.`)
3737
return "manual-approval"
@@ -45,9 +45,9 @@ jobs:
4545
pull-requests: read
4646
contents: read
4747
steps:
48-
- name: Configure Credentials
48+
- name: Configure Credentials
4949
uses: aws-actions/configure-aws-credentials@v4
50-
with:
50+
with:
5151
role-to-assume: ${{ secrets.STRANDS_INTEG_TEST_ROLE }}
5252
aws-region: us-east-1
5353
mask-aws-account-id: true
@@ -70,5 +70,3 @@ jobs:
7070
id: tests
7171
run: |
7272
hatch test tests-integ
73-
74-

src/strands/agent/agent.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def _execute_event_loop_cycle(self, callback_handler: Callable[..., Any], kwargs
546546

547547
try:
548548
# Execute the main event loop cycle
549-
stop_reason, message, metrics, state = event_loop_cycle(
549+
events = event_loop_cycle(
550550
model=model,
551551
system_prompt=system_prompt,
552552
messages=messages, # will be modified by event_loop_cycle
@@ -559,6 +559,11 @@ def _execute_event_loop_cycle(self, callback_handler: Callable[..., Any], kwargs
559559
event_loop_parent_span=self.trace_span,
560560
**kwargs,
561561
)
562+
for event in events:
563+
if "callback" in event:
564+
callback_handler(**event["callback"])
565+
566+
stop_reason, message, metrics, state = event["stop"]
562567

563568
return AgentResult(stop_reason, message, metrics, state)
564569

src/strands/event_loop/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
iterative manner.
55
"""
66

7-
from . import error_handler, event_loop, message_processor
7+
from . import event_loop, message_processor
88

9-
__all__ = ["error_handler", "event_loop", "message_processor"]
9+
__all__ = ["event_loop", "message_processor"]

src/strands/event_loop/error_handler.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)