Commit f43172a
Re-implement conversation-manager as a hook provider (#222)
* refactor: simplify test helpers and use createMockAgent
- Use hooks.addHook() instead of manual registerCallbacks()
- Create createMockAgent() helper in fixtures
- Simplify test helpers to use invokeCallbacks directly
- Update all tests to use createMockAgent helper
- Make all tests properly async with await
Addresses PR review feedback.
refactor: keep conversationManager as first-class config option
- Restore conversationManager to AgentConfig and Agent class
- Agent automatically registers conversation manager hooks internally
- Update tests to use HookRegistryImplementation and focus on behavior
- Remove public mentions of hooks from conversation manager docs
- Simplify NullConversationManager tests to focus on behavior
This maintains conversationManager as a top-level concept while using
hooks internally as an implementation detail.
refactor!: convert conversation managers to hook providers
BREAKING CHANGE: Removed ConversationManager base class and Agent.conversationManager field.
Conversation managers are now hook providers that must be registered via the hooks config.
Changes:
- Added retryModelCall field to AfterModelCallEvent for retry control
- Converted NullConversationManager to HookProvider (0 hooks registered)
- Converted SlidingWindowConversationManager to HookProvider with AfterInvocationEvent and AfterModelCallEvent callbacks
- Removed Agent.conversationManager field and related config
- Updated Agent retry logic to use retryModelCall flag instead of catching ContextWindowOverflowError
- Added messages field to AgentData interface for hook access
- Deleted ConversationManager base class and ConversationContext interface
- Updated public API exports to remove ConversationManager
Migration:
Before: new Agent({ conversationManager: new SlidingWindowConversationManager() })
After: new Agent({ hooks: [new SlidingWindowConversationManager()] })
Resolves: #210
* refactor: address PR review feedback
- Create MockAgentData interface with optional messages and state
- Update createMockAgent to accept interface-based parameter
- Update all test usages to use object syntax
- Add retryModelCall tests to agent.hook.test.ts
- Update test helpers to use registry.addHook(manager)
Addresses review comments on PR #222
---------
Co-authored-by: Strands Agent <[email protected]>1 parent 76afd8f commit f43172a
File tree
18 files changed
+268
-235
lines changed- src
- __fixtures__
- agent
- __tests__
- conversation-manager
- __tests__
- hooks
- __tests__
- types
- vended_tools
- bash/__tests__
- file_editor/__tests__
- notebook/__tests__
18 files changed
+268
-235
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
301 | 302 | | |
302 | 303 | | |
303 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
304 | 338 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
| |||
74 | 73 | | |
75 | 74 | | |
76 | 75 | | |
77 | | - | |
| 76 | + | |
78 | 77 | | |
79 | 78 | | |
80 | 79 | | |
| |||
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
110 | | - | |
| 109 | + | |
111 | 110 | | |
112 | 111 | | |
113 | 112 | | |
| |||
140 | 139 | | |
141 | 140 | | |
142 | 141 | | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
146 | 146 | | |
| 147 | + | |
147 | 148 | | |
148 | 149 | | |
149 | 150 | | |
| |||
283 | 284 | | |
284 | 285 | | |
285 | 286 | | |
286 | | - | |
287 | | - | |
288 | 287 | | |
289 | 288 | | |
290 | 289 | | |
| |||
362 | 361 | | |
363 | 362 | | |
364 | 363 | | |
365 | | - | |
| 364 | + | |
366 | 365 | | |
367 | | - | |
368 | | - | |
369 | | - | |
| 366 | + | |
| 367 | + | |
370 | 368 | | |
371 | 369 | | |
372 | | - | |
| 370 | + | |
| 371 | + | |
373 | 372 | | |
374 | 373 | | |
375 | 374 | | |
| |||
Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 19 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | | - | |
8 | | - | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
14 | | - | |
| 17 | + | |
15 | 18 | | |
16 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
17 | 23 | | |
18 | 24 | | |
19 | 25 | | |
20 | 26 | | |
21 | 27 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | 28 | | |
35 | | - | |
| 29 | + | |
36 | 30 | | |
37 | | - | |
| 31 | + | |
| 32 | + | |
38 | 33 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
| 34 | + | |
| 35 | + | |
43 | 36 | | |
44 | | - | |
45 | | - | |
46 | | - | |
| 37 | + | |
47 | 38 | | |
48 | | - | |
49 | | - | |
50 | | - | |
| 39 | + | |
51 | 40 | | |
52 | 41 | | |
53 | 42 | | |
0 commit comments