Repository navigation
Commit 2723927
authored
refactor(agent): unify run context and add integration harness (#1009)
* refactor(agent): unify run context and add integration harness
- Make AgentRunContext the canonical per-run context threaded through
main and sub-agent executions; attach parent request ids for tracing
- Thread requestId/conversationId consistently into agent, chain, and
computer tool calls
- Add maxTokenLimit handling and detect token-limit finish reasons in
shared adapter error mapping
- Add deterministic integration harness and agent eval bench scripts,
replace the previous mocha test suite
- Add file-changes tracking for computer tools
* refactor(agent): drop eval harness and simplify stream/sandbox
- Remove bench/ and integration/ from version control, keep them locally
- Revert integration/bench scripts and their devDependencies in package.json
- Simplify readSSE abort handling: cancel reader and throw signal reason
- sseIterable takes a params object instead of positional timeout/signal
- Split local sandbox builder into sandbox_darwin.ts / sandbox_linux.ts
- Restore caller-first toolMask priority
* fix(agent): address code review findings
- Cover HTTP connect phase with request timeout in deepseek/dify/gemini/qwen
stream requesters via createRequestSignal
- Forward maxTokenLimit and caller source through the plain chat chain
- Guard LocalComputerSession methods against disconnected state; clear
FileStore on disconnect; mkdir session tmp with 0o700
- Reject empty tmp in wrapCommandWithSandbox and empty oldString in
replaceFileContent
- Cache FileStore.scope realpath in constructor instead of per-access
realpathSync
- Clean up expired chatluna-agent-* session temp dirs by mtime
- Isolate bwrap sandbox with --unshare-pid/--unshare-ipc/--new-session
- Support AbortSignal in open-terminal and e2b execute (kill remote command
on abort)
* fix(adapter): honor explicit timeouts instead of capping at 60s
- Remove the 60s clamp on stream request timeouts everywhere
(shared-adapter, deepseek, dify, gemini, qwen, sseIterable): an explicit
params.timeout is now used as-is; the 60s default already comes from the
model/reranker layer when no timeout is set
- Align dify _agentStream/_workflowStream error handling with the other
adapters: rethrow signal reason on abort, keep ChatLunaError as-is, wrap
the rest in API_REQUEST_FAILED, dispose signal in finally
* fix(sse): pass signal into ollama sse reader, reset idle timer on any chunk
- Ollama requester now forwards params.signal to rawSeeAsIterable so the
stream read phase preserves the abort reason after the response is
established
- sseIterable resets the idle timeout on every raw chunk instead of only on
non-comment events, so keepalive comments (e.g. ': ping') keep long-lived
streams alive
* fix(search): build AgentRunContext in browsing chain tool configs
ChatLunaToolRunnable.configurable now requires agentContext; browsing_chain
constructed its tool run configs with the old { model, session,
conversationId } shape. Add a shared buildRunConfig helper that builds a
main-kind AgentRunContext and use it for both web_search invoke and browser
readText calls.
* fix(search): thread abort signal and per-call context in browsing chain
- Pass the AbortSignal into buildRunConfig so tool.invoke and readText
receive cancellation through runConfig.signal instead of only racing it
- Use the stable browsing agent identity (agentId 'browsing-chain', agentName
botName) instead of reusing conversationId for agentId/agentName
- Build the run config inside each urls.map callback so every readText call
gets its own requestId1 parent a3f2518 commit 2723927
86 files changed
Lines changed: 2065 additions & 7283 deletions
File tree
- packages
- adapter-claude/src
- adapter-deepseek/src
- adapter-dify/src
- adapter-doubao/src
- adapter-gemini/src
- adapter-hunyuan/src
- adapter-ollama/src
- adapter-qwen/src
- adapter-spark/src
- adapter-wenxin/src
- adapter-zhipu/src
- core
- src
- llm-core
- agent
- openai
- sub-agent
- chain
- chat
- platform
- prompt
- middlewares/conversation
- migration
- services
- utils
- tests
- extension-agent/src
- computer
- backends
- local
- tools
- service
- sub-agent
- trigger
- utils
- extension-long-memory/src/plugins
- extension-tools/src/plugins
- service-multimodal/src/plugins
- service-search/src
- chain
- tools/browser
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| 91 | + | |
| 92 | + | |
90 | 93 | | |
91 | 94 | | |
92 | | - | |
| 95 | + | |
93 | 96 | | |
| 97 | + | |
94 | 98 | | |
95 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
96 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
97 | 110 | | |
98 | 111 | | |
99 | 112 | | |
100 | 113 | | |
| 114 | + | |
| 115 | + | |
101 | 116 | | |
102 | 117 | | |
103 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
162 | 163 | | |
163 | 164 | | |
164 | 165 | | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | | - | |
172 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
173 | 178 | | |
174 | | - | |
175 | | - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
176 | 184 | | |
177 | | - | |
178 | | - | |
| 185 | + | |
| 186 | + | |
179 | 187 | | |
180 | | - | |
181 | | - | |
182 | | - | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
183 | 191 | | |
184 | | - | |
| 192 | + | |
185 | 193 | | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | | - | |
191 | | - | |
192 | | - | |
193 | | - | |
194 | | - | |
195 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
196 | 200 | | |
197 | | - | |
198 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
199 | 209 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
205 | 217 | | |
206 | | - | |
207 | | - | |
| 218 | + | |
208 | 219 | | |
209 | | - | |
| 220 | + | |
210 | 221 | | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
217 | 228 | | |
218 | | - | |
219 | | - | |
| 229 | + | |
| 230 | + | |
220 | 231 | | |
221 | | - | |
| 232 | + | |
222 | 233 | | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
231 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
232 | 254 | | |
233 | 255 | | |
234 | 256 | | |
| |||
267 | 289 | | |
268 | 290 | | |
269 | 291 | | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
| 292 | + | |
278 | 293 | | |
279 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
280 | 304 | | |
281 | | - | |
282 | | - | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
283 | 309 | | |
284 | | - | |
285 | | - | |
286 | | - | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
287 | 316 | | |
288 | | - | |
| 317 | + | |
289 | 318 | | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
300 | 325 | | |
301 | | - | |
302 | | - | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
303 | 334 | | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
309 | 342 | | |
310 | | - | |
311 | | - | |
| 343 | + | |
312 | 344 | | |
313 | | - | |
| 345 | + | |
314 | 346 | | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
321 | 353 | | |
322 | | - | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
323 | 363 | | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
324 | 367 | | |
325 | 368 | | |
326 | 369 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
0 commit comments