Skip to content

feat(harness): make workspace memory recall guidance configurable - #4250

Open
shanuo0312 wants to merge 1 commit into
agentscope-ai:mainfrom
shanuo0312:agent/fix-agentscope-4160-d4a70c4a1bb6
Open

shanuo0312 wants to merge 1 commit into
agentscope-ai:mainfrom
shanuo0312:agent/fix-agentscope-4160-d4a70c4a1bb6

Conversation

@shanuo0312

Copy link
Copy Markdown
Contributor

This is by an automated agent, not a human.

Summary

Fixes #4160. Adds an opt-in way to configure the Harness workspace-memory recall guidance without changing memory tool availability.

MemoryConfig.Builder.recallInstructions(String):

  • null (default) keeps the built-in ## Memory Recall guidance, so existing agents are unchanged.
  • Blank text omits the section while keeping memory_search / memory_get / memory_save / thread_search, MEMORY.md injection, and flush/consolidation.
  • Nonblank text replaces the section body under the existing ## Memory Recall heading, letting applications require a search only when the request actually depends on prior-session facts.

WorkspaceContextMiddleware applies the override, and HarnessAgent passes it from MemoryConfig, including to declared and general-purpose subagents. When memory tools are disabled the recall section is still suppressed, because the guidance would refer to unavailable tools.

Verification

  • mvn -B -T1C clean verify — full reactor, 114 modules: BUILD SUCCESS (harness: 1,844 tests, 0 failures/errors, 36 skipped).
  • Docs: npm test (20/20), npm run validate, npm run broken-links — all pass.
  • New tests cover default/custom/blank guidance, disabled-tools precedence, continued tool availability, builder wiring, declared + general-purpose subagent inheritance, and the rendered model request.

Limitations

  • This is guidance, not an enforced retrieval policy: it does not guarantee a single model call per turn and does not add automatic pre-retrieval (MEMORY.md is already injected per call).
  • No default behaviour changes.

Related: #4219 proposes a similar setting; this implementation is independent.

Add MemoryConfig.Builder.recallInstructions(String) so applications can replace or omit the Memory Recall guidance in the workspace system prompt while keeping memory tools, MEMORY.md injection, and flush/consolidation.

null keeps the current default, blank text omits only the recall section, and nonblank text replaces the section body under the existing heading. HarnessAgent passes the setting to WorkspaceContextMiddleware, so declared and general-purpose subagents inherit it.

Disabled memory tools still suppress recall guidance so the model is not instructed to use unavailable capabilities.

Fixes agentscope-ai#4160
Copilot AI balanced review requested due to automatic review settings November 18, 2026 11:10
@mintlify

mintlify Bot commented Nov 18, 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 f1ddfc1.

Approve preview

@CLAassistant

CLAassistant commented Nov 18, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the configurable workspace-memory recall guidance change.

No open issues 🎉

What changed in this PR

Adds configurable workspace-memory recall guidance to Harness, addressing #4160 without changing default behavior, memory tools, or background memory processing.

Changes:

  • Adds MemoryConfig.Builder.recallInstructions(String): null preserves defaults, blank text omits the section, and nonblank text replaces its body.
  • Wires the setting into workspace context, including inherited configuration for declared and general-purpose subagents.
  • Adds regression tests and matching English/Chinese documentation explaining behavior and limitations.

Verification: The PR reports successful full Java verification and documentation checks. These were not rerun here.

File Description
docs/​dev/​zh/​docs/​harness/​memory.md Documents configuration examples and limitations in Chinese.
docs/​dev/​en/​docs/​harness/​memory.md Documents configuration examples and limitations in English.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​middleware/​WorkspaceContextMiddlewareMemoryPromptTest.java Tests custom and blank guidance, memory retention, and disabled-tools precedence.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​memory/​MemoryConfigTest.java Tests defaults and preservation of configured recall text.
agentscope-harness/​src/​test/​java/​io/​agentscope/​harness/​agent/​HarnessAgentTest.java Tests rendered guidance, retained tools, and subagent inheritance.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​middleware/​WorkspaceContextMiddleware.java Applies default, omitted, or replacement recall guidance.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​memory/​MemoryConfig.java Adds the recall-instructions configuration API and Javadoc.
agentscope-harness/​src/​main/​java/​io/​agentscope/​harness/​agent/​HarnessAgent.java Passes recall configuration to middleware and updates API documentation.

Review effort: Balanced

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.

[Feature]: Configurable Harness workspace-memory recall guidance to avoid unnecessary tool round trips

3 participants