Skip to content

feat(harness): configure workspace memory recall instructions - #4219

Open
CryoThrust wants to merge 3 commits into
agentscope-ai:mainfrom
CryoThrust:feat/memory-recall-instructions
Open

CryoThrust wants to merge 3 commits into
agentscope-ai:mainfrom
CryoThrust:feat/memory-recall-instructions

Conversation

@CryoThrust

@CryoThrust CryoThrust commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Applications currently have to disable memory tools or broader workspace context to remove the built-in recall instruction (#4160). This adds MemoryConfig.Builder.recallInstructions(String) so they can change that instruction independently.

  • null retains the existing guidance.
  • Blank text omits only the Memory Recall section.
  • Nonblank text replaces the body without placeholder substitution.
  • Explicitly disabled memory tools suppress the section, whether the disable call comes before or after .memory(...).

This remains model guidance, not automatic pre-retrieval or an enforced retrieval policy. It does not guarantee fewer model calls or token savings. The existing constructors, memory references, tools and persistence/maintenance controls retain their behavior. The declared and general-purpose subagents inherit the configured instruction.

The branch is synced with main 80926f92d without rewriting history. Current main's long-term-memory opt-in is preserved: .memory(config) enables memory as before; an empty recall instruction does not disable it. Matching dev EN/ZH documentation explains that boundary. API-placement feedback on MemoryConfig is welcome.

Verification

JDK 17:

mvn -B -T1C -pl agentscope-harness -am clean test \
  -Dtest=MemoryConfigTest,WorkspaceContextMiddlewareMemoryPromptTest,HarnessAgentTest,HarnessAgentSubagentStreamTest \
  -Dsurefire.failIfNoSpecifiedTests=false
mvn -B -T1C verify

The four focused classes pass 131 tests, with no failures/errors/skips. They cover actual model-request text, all tool/hook flag combinations and builder order, independent configurations, default restoration and subagent inheritance. Documentation checks on Node.js 22 pass: 20 tests, strict Mintlify validation and broken-link checks.

The first full clean verify failed in the unchanged HarnessAgentSubagentStreamTest.call_localSubagent_returnsReplyWithoutStreaming: after about 899 seconds the journal writer lease was expired/fenced during cleanup. A clean class-level comparison then passed all 10 tests on unmodified main and on this branch, without changing source, assertions or lease settings. That does not establish the cause of the first failure. The subsequent full 114-module verify passed; its final Surefire XML reports contain 13,866 cases, zero failures/errors and 245 skips. The previously failing class passed all 10 cases in that run, too. No timeout or lease setting was changed for the full retry. Native Windows was not run locally; current-head hosted CI is still needed.

From docs/:

npm test
npm run validate
npm run broken-links

No live-provider retrieval decisions or cost savings were measured.

@mintlify

mintlify Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit b61e1aa.

Approve preview

@CryoThrust

CryoThrust commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Windows CI on 266c6551e failed in WorkerRuntimeTest.staleWorkerCannotPublishResult, at store.release(old, Duration.ZERO) (line 553), with DurableException: Worker lease lost. The test claims a one-second lease and performs begin before that release. This is in agentscope-durable-worker, which this PR does not change; the Windows reactor then skips dependent modules, so this run does not validate the Harness tests.

The full local JDK 17 build passed, including that worker test, but I have not reproduced the Windows failure on the base commit or established its cause. No lease timeout, guard or assertion was changed to make this feature pass. GitHub rejected my job-rerun request with "Must have admin rights to Repository." Could a maintainer rerun the Windows job on this unchanged head?

Update: the Linux job on the same head completed successfully. Its log confirms WorkerRuntimeTest ran 12 cases with no failures/errors/skips, and the three affected Harness test classes ran 89 + 11 + 10 cases, also with no failures/errors/skips. That gives Linux coverage for this change, but does not resolve the Windows failure.

Windows diagnostic update: a fork-only comparison now passes on both the exact base 5525ac1aa and this unchanged feature head 266c6551e. Each Windows/Temurin 17 job ran the original WorkerRuntimeTest five times: 12 cases per attempt, zero failures/errors/skips (60 executions per revision). The lease fixture, assertions and production guards were unchanged. The diagnostic workflow is on a separate fork branch and is not part of this PR. This did not reproduce the lease failure in either revision; it is a scoped worker-reactor check, not a rerun of the original full Windows job, so that upstream job still needs a maintainer rerun.

xzxiaoshan added a commit that referenced this pull request Nov 20, 2026
…#4274)

## Background

Swept the last 125 PRs (#4272→#4075) for single-OS CI failures under
`mvn -B -T1C clean verify` (one build OS red, the other green on the
same commit = flake suspect). Cross-PR repeats and main's own red run on
2026-11-19 (ubuntu, run 44516464414) pinpoints four still-broken test
classes; all fixes are test-side only (no `src/main` changes).

## Fixes and evidence

| Test class | Victims | Signature | Fix |
|---|---|---|---|
| `RocketMqExecutionTest` | #4182, #4192, #4103 + main run 44516464414
(2026-11-19, ubuntu) | `turn reaches SUCCEEDED did not become true
within 10s` while the turn kept progressing (modelCalls complete, acks
climbing, lastFailure=none) — deadline breakthrough under starvation,
not a lost turn | shared `waitUntil` deadline 10s→30s (repo tier
#3726/#3774) |
| `AgentScopeAdapterTest` | #4204 (same-commit re-run green = confirmed
flake), #4191, #4246 | `Timed out observing Turn` at 6.7–8.5s elapsed;
resume/recovery one step from terminal | `turn.await(5s)`→30s at all 3
sibling sites via `TURN_DEADLINE`, outer `get` budgets +5s margin |
| `WorkerRuntimeTest` | #4219, #4224, #4255 (windows) | (a) `Worker
lease lost` after 2.4s — 1s claim leases expired between claim and
release; (b) `renewed.await(5s)` missed at 6.5s while the recovery lane
was healthy; (c) `Interrupted sleep interrupted` —
`WorkerRuntime.process()` interrupts the calling thread on lease-renewal
failure and manual `tick()` runs it on the test thread | (a) claim
leases 1s→30s (staleness under test still comes from `release(ZERO)` +
re-claim); (b) latches 5s→30s; (c) raw `Thread.sleep`→interrupt-proof
`pause()` at 5 sites, mirroring the #4176 fix for the same signature in
`ProcessRecoveryTest` |
| `ChatSessionsTest.await` (shared with `ChatControllerTest`) | #4233,
#4182 (stuck-RUNNING at 40.8s/46.4s), #4268, #4163 (poll threw `Durable
database transaction failed`) | two surfaces of one cause: every
snapshot poll opens a writing sqlite transaction contending with the
runtime's own writes, and windows runners starve turns past 30s (same
file already measured 56.6s starvation and uses 120s elsewhere, #3726) |
deadline 30s→120s (aligned tier) + tolerate transient `UNAVAILABLE`
store exceptions while polling; persistent failure rethrows at the
deadline, FAILED-turn fast-fail unchanged |
| `CommandExecutorTest.missingExitCodeIsUnknown` | local -T2C full-repo
stress (2026-11-19; pristine-main baseline of the same class green) |
the 2s network budget fired on scheduler starvation before the instant
fake response was processed, misclassifying the failure as a deadline
miss instead of a missing exit code (2.97s elapsed) | budget 2s→30s for
this non-deadline-semantics test; the two deadline-semantics tests keep
their tight budgets |

## Constraint compliance

- Happy path zero cost: every change only extends failure-path deadlines
or hardens helpers; no new sleeps, no weakened assertions.
- Minimal widening anchored to measured data (each comment cites victims
+ measured values); 30s follows the repo's established deflake tier,
120s follows this file's own previously measured starvation tier.
- Structural hardening preferred: `pause()` helper, transient-lock
retry, lease decoupling from the tested invariant.
- No `src/main` changes.

## Observed but deliberately not fixed here

-
`ProcessRecoveryTest.replacementCollectsOriginalResultWithoutRepeatingEffect`
(#4214: `expected: 2 but was: 3`): recovery-semantics race (model re-run
without effect re-run after abrupt halt) — a product question for the
durable recovery work, not a deadline flake.
-
`JevEvidenceProcessorTest.filterFailureIsWithheldButRankFailureFollowsScoredEvidence`
(#4265: delivered `[]` on a 25×-slowed runner): root cause not
established; single occurrence.
- Already fixed upstream, victims predate the fix:
`AgentScopeAgentExecutorInputRequiredTest` (#4157/#4187/#4152 all
predate #4176's `BaseReActAgentRunner` change), `InboxMiddlewareTest`
(#4093 predates #3738), `HarnessAgentSubagentStreamEventsTest` (#4183
predates #2917).
- `SkillBoxTest$UploadContainment` quartet (#4201/#4202/#4212/#4229):
test does not exist on main (fork stack only); deterministic cross-drive
path bug, not load flakiness.
- #4184/#4185: both-OS compile breaks from dependency major bumps
(dependabot), out of scope.

Also applied during review: sibling sites with the identical measured
mechanism were widened in the same pass — the remaining 1s fixture claim
leases in `WorkerRuntimeTest` (fenced begin/update/release sequences,
same #4219 signature), the start/PAUSED 5s budgets in the same
`AgentScopeAdapterTest` method as the victims, and the 5s/4s observe
budgets in
`completeLocalBackendRunsNativeAgentWhileManagedObserverIsBlocked`.

## Test plan

- [x] Full local `mvn -B -T2C clean verify` green (stricter than CI's
-T1C). Locally excluded, each verified to fail identically on pristine
main on this machine (Windows/git-bash) while passing on CI:
`JsonFileAgentStateStoreTest` (symlink permissions), the
`agentscope-extensions-durable-sandbox` trio plus
`ToolInSandboxExampleTest`/`SandboxRoundTripTest` (sandbox shell heredoc
incompatible with local git-bash python3), and the
`AgentScopeAdapterTest`/`ProcessRecoveryTest`/`HarnessExternalToolProcessRecoveryTest`
trio (durable-adapter classes whose Windows runs are skipped on CI; the
same named tests fail on pristine main locally).
- [ ] CI green on both OS.

This branch has not been deployed

No deployments
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