Commit 0058bff
authored
feat(memory): support async recording for StaticLongTermMemoryHook. (#1177)
## AgentScope-Java Version
io.agentscope:agentscope-parent:pom:1.0.12-SNAPSHOT
## Description
LongTermMemory will block the agent when the LLM stops responding. This
commit enables the framework to record long term memory asynchronously.
Added `longTermMemoryAsyncRecord` option to `ReActAgent.Builder` to
support fire-and-forget long-term memory recording in `STATIC_CONTROL` /
`BOTH` mode.
When enabled, the `StaticLongTermMemoryHook` performs `record()`
asynchronously without blocking the agent's response, reducing latency
in `STATIC_CONTROL` mode. Agent-controlled recording (`AGENT_CONTROL`)
remains synchronous.
## Checklist
Please check the following items before code is ready to be reviewed.
- `ReActAgent.Builder` — new `longTermMemoryAsyncRecord(boolean)` setter
- `StaticLongTermMemoryHook` — overloaded constructor accepting
`asyncRecord` flag; `handlePostCall()` splits sync/async paths
- `StaticLongTermMemoryHookTest` — added 3 async recording test cases
- [X] Code has been formatted with `mvn spotless:apply`
- [X] All tests are passing (`mvn test`)
- [X] Javadoc comments are complete and follow project conventions
- [X] Related documentation has been updated (e.g. links, examples,
etc.)
- [X] Code is ready for review1 parent a951efe commit 0058bff
4 files changed
Lines changed: 438 additions & 12 deletions
File tree
- agentscope-core/src
- main/java/io/agentscope/core
- memory
- test/java/io/agentscope/core
- agent
- memory
Lines changed: 26 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1120 | 1120 | | |
1121 | 1121 | | |
1122 | 1122 | | |
| 1123 | + | |
1123 | 1124 | | |
1124 | 1125 | | |
1125 | 1126 | | |
| |||
1418 | 1419 | | |
1419 | 1420 | | |
1420 | 1421 | | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
1421 | 1445 | | |
1422 | 1446 | | |
1423 | 1447 | | |
| |||
1591 | 1615 | | |
1592 | 1616 | | |
1593 | 1617 | | |
1594 | | - | |
| 1618 | + | |
| 1619 | + | |
1595 | 1620 | | |
1596 | 1621 | | |
1597 | 1622 | | |
| |||
Lines changed: 67 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
| 87 | + | |
79 | 88 | | |
80 | 89 | | |
81 | | - | |
| 90 | + | |
82 | 91 | | |
83 | 92 | | |
84 | 93 | | |
85 | 94 | | |
86 | 95 | | |
87 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
88 | 110 | | |
89 | 111 | | |
90 | 112 | | |
| |||
93 | 115 | | |
94 | 116 | | |
95 | 117 | | |
| 118 | + | |
96 | 119 | | |
97 | 120 | | |
98 | 121 | | |
| |||
179 | 202 | | |
180 | 203 | | |
181 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
182 | 215 | | |
183 | 216 | | |
184 | 217 | | |
| |||
190 | 223 | | |
191 | 224 | | |
192 | 225 | | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
203 | 259 | | |
204 | 260 | | |
205 | 261 | | |
| |||
0 commit comments