Commit 0460052
committed
fix(image-batch): give each image its own agent instead of sharing one
ImageAgentBatchProcessor submits the same Agent object once per image and
never resets it, so image N is answered with images 1..N-1 still in context.
Memory grows for the whole batch and is re-sent on every later call, and
concurrent workers append to one short_memory at the same time.
Hand each submission a private copy with empty short-term memory. Copying
also closes the race, since no two workers touch the same object.
Where the agent cannot be copied -- a held thread lock, an HTTP connection
pool -- fall back to the original, matching AgentRearrange._clone_for_task.
The fallback returns the agent untouched rather than resetting it: resetting
an object another worker is mid-run on would be worse than the sharing it is
meant to fix.
Closes kyegomez#20461 parent cfc4366 commit 0460052
1 file changed
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
110 | 119 | | |
111 | 120 | | |
112 | 121 | | |
| |||
217 | 226 | | |
218 | 227 | | |
219 | 228 | | |
220 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
221 | 233 | | |
222 | 234 | | |
223 | 235 | | |
| |||
0 commit comments