SIGN IN SIGN UP

fix(harness): inherit memory config in subagents (#2611)

## AgentScope-Java Version

2.0.1-SNAPSHOT

## Description

Fixes #2549.

### Background and root cause

Automatically built subagents inherited the parent agent's memory
enable/disable flags, but both `buildGeneralPurposeFactory(...)` and
`buildDeclaredFactory(...)` omitted the parent's `MemoryConfig`. Their
child builders therefore fell back to `MemoryConfig.defaults()`, which
could trigger unexpected flush/consolidation model calls and ignore
custom memory prompts, retention settings, and model overrides.

### Changes

- Propagate the parent's immutable `MemoryConfig` to general-purpose
subagents.
- Apply the same inheritance rule to declared subagents.
- Keep the existing memory tools/hooks disable flag propagation
unchanged.
- Add focused regression tests for both factory paths. The tests
configure `FlushTrigger.never()` and verify that a child call performs
only the normal model invocation, with no unexpected memory flush call.

This PR is intentionally limited to configuration inheritance. Broader
asynchronous memory-maintenance latency is outside its scope.

### Validation

- `mvn -pl agentscope-harness -am -Dtest=HarnessAgentTest
-Dsurefire.failIfNoSpecifiedTests=false test`
  - 39 tests, 0 failures, 0 errors
- `mvn -pl agentscope-harness -am -Djava.awt.headless=true test`
  - `agentscope-core`: 2264 tests, 0 failures, 0 errors
  - `agentscope-harness`: 786 tests, 0 failures, 0 errors
- `git diff --check`

## Checklist

- [x] Code has been formatted with `mvn spotless:apply`
- [x] All tests are passing
- [x] Javadoc comments are complete and follow project conventions (no
public API added)
- [x] Related documentation has been updated (not applicable; no
documentation contract changed)
- [x] Code is ready for review

Co-authored-by: Joe Zou <yixian.zou@gmail.com>
S
steven-ji committed
18b886ed71b0600e7f5c56ac010fe81c7aad5488
Parent: 40e77c0
Committed by GitHub <noreply@github.com> on 8/12/2026, 3:24:44 PM