Skip to content

fix(skill): move blocking skill reload off reactive event-loop threads - #3792

Merged
jujn merged 1 commit into
agentscope-ai:mainfrom
xzxiaoshan:fix/skill-mirror-0b-boundedelastic
Oct 27, 2026
Merged

jujn merged 1 commit into
agentscope-ai:mainfrom
xzxiaoshan:fix/skill-mirror-0b-boundedelastic

Conversation

@xzxiaoshan

Copy link
Copy Markdown
Collaborator

Summary

  • DynamicSkillMiddleware.onSystemPrompt executed repository reads (Git/DB/FS), signature computation and box materialization synchronously on the subscribing thread, blocking reactive event-loop threads.
  • Wrap the whole reload (including cache hits) in Mono.fromCallable(...).subscribeOn(Schedulers.boundedElastic()). The cache-hit fast path cannot stay on the calling thread because the cache key (content signature) is only known after the blocking repository read.
  • Per-call reload semantics, the content-addressed box cache, signature computation, and the filterVisible hook are unchanged; no reactive signatures added to the AgentSkillRepository SPI.

Tests

  • New: runsReloadOnBoundedElasticWhenCacheMisses (asserts getAllSkills runs on a boundedElastic thread), keepsCacheHitPathBehaviorUnchanged (same-signature reload reuses the cached box; repository still read once per call).
  • mvn -T1C -pl agentscope-core -am test: 2787 passed, 0 failed, 8 pre-existing skips; spotless:check clean.

DynamicSkillMiddleware.onSystemPrompt performed repository reads, signature
computation and box materialization synchronously on the subscribing thread,
blocking reactive event-loop threads. Wrap the reload in
Mono.fromCallable(...).subscribeOn(Schedulers.boundedElastic()); per-call
reload semantics and the content-addressed box cache are unchanged. The
cache-hit fast path cannot stay on the calling thread because the cache key
(content signature) is only known after the blocking repository read.
@jujn
jujn merged commit f0dcc6b into agentscope-ai:main Oct 27, 2026
5 checks passed
xzxiaoshan added a commit that referenced this pull request Oct 27, 2026
…le lock map (#3795)

Two targeted fixes in the skill materialisation path:

- `DynamicSkillMiddleware.computeSignature` copied the whole resource
map on every key inside the hash loop (O(n²) per skill). It now
enumerates keys once via `getResourcePaths()` and reads values with
per-key `getResource()`; the hashed bytes — and therefore signature
values — are unchanged (pinned by a golden-value regression test).
- `SkillBox.FILE_LOCKS` was a static per-path lock map that accumulated
one lock object per materialised path and was never cleaned. It is
replaced by a fixed 256-stripe lock table (`floorMod(pathHash, N)`):
same-path mutual exclusion is preserved, unrelated paths colliding on a
stripe merely serialise, and lock memory no longer grows with path
count.

Also includes (kept as separate commits):
- Merge of upstream/main; while resolving it, the two
`DynamicSkillMiddlewareTest` fixtures added by #3792 still used
`my_skill`, which the skill-name validation from #3787 rejects — renamed
to `my-skill` following the convention #3787 itself applied to the older
fixtures.
- `test(channel)`: deflake
`BotLoopGuardTest.activePeersSurviveEvictionOfIdleOnes` — `allow()`
piggybacks a sweep on the same threshold idle eviction uses, so a ~100ms
runner stall (e.g. under `mvn -T1C`) let the sweep evict the idle peer
before the explicit `evictIdlePeers()` assertion. Rebalanced sleeps for
a 400ms stall margin; assertions unchanged.

Verified with `mvn -T1C -pl agentscope-core -am test` (2805 tests, 0
failures) and `spotless:check`.
Buktal added a commit that referenced this pull request Oct 28, 2026
## AgentScope-Java Version

2.1.0-SNAPSHOT

## Description

Refs #3794, review unit 3 of 3. Synthetic messages can be durable
conversation records or request-only projections. Treating both as
transient moves persisted notifications out of order and keeps them
outside compaction. Comparing copied/restored messages by Java
object/value types can also prevent a valid summary from being written
back.

## Summary

```text
canonical history (including persisted synthetic notifications)
  -> ordered conversation -> budget/compact -> guarded summary writeback
request-only projections
  -> current request only
overflow retry
  -> latest canonical history + surviving request projections
system sources
  -> one System message / one TextBlock, joined by blank lines
```

- Use canonical membership/IDs to distinguish persisted notifications
from transient projections, retaining ordinary history order, budgeting,
and compaction behavior.
- Require complete serialized-history equality before durable writeback.
Use the configured JSON codec and a precision-preserving JSON-tree
comparison so restored number types match while edited content,
metadata, and high-precision decimal values do not.
- Rebuild overflow retries from current history without reviving
compacted-away notifications. Preserve concurrent-history and
final-budget rejection guards.
- Clarify the synthetic marker's lifetime contract and update
English/Chinese context documentation.

## Evidence

- **Before:** with the old history comparison, JSON-restored
notification cases failed summary persistence: 3 failures in a 37-test
context/compaction regression run.
**After:** all 37 passed after the numeric-comparison fix, including
protection for distinct `1.0000000000000000001` and
`1.0000000000000000002` metadata. `ContextPipelineV2Test` also covers
copied/converted notifications, same-ID edits, single-block system text,
final-budget rejection, and concurrent changes;
`CompactionMiddlewareTest` covers overflow reconstruction.
- Independent branch: `mvn -B -T1C clean verify` passed across 99
modules: **11,317 tests**, 0 failures/errors, **242 skipped**. Spotless
ran without skip flags. Docs: `npm test` (13/13) and `npm run validate`
(432 pages, 584 redirects, Mintlify build) passed. `npm run
broken-links` reports 2,218 links across 326 files, the same counts
recorded before; individual links were not baseline-attributed.
- Includes the shared three-line `my_skill` -> `my-skill` test-fixture
correction needed after #3787/#3792. It is also in both sibling PRs so
these branches validate independently and can merge in any order.

## Merge Danger

**Door:** two-way

No serialized-state schema change. The existing synthetic marker
continues to identify origin; canonical membership determines whether a
message is durable.

**Blast Radius:** context

Changes request layout, compaction eligibility, summary writeback, and
overflow retries. Fake-model regressions verify these paths; provider
cache behavior and task quality were not benchmarked. #3780's older
streaming/backport and custom memory-flush-prompt concerns are separate.

## Checklist

- [x] Spotless formatting check passes as part of full verification
- [x] All executed tests pass; skipped-test count is reported above
- [x] Javadoc updated for changed contracts
- [x] Related English and Chinese documentation updated
- [x] Code ready for review
chickenlj added a commit that referenced this pull request Nov 13, 2026
#3792)

Source: f0dcc6b
Candidate: 97476565ff0e691485ccc8bd9d1fb93170bca49a
Union-Of: execution53(468e2c2) + skill-standalone(97476565)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants