Skip to content

fix(harness): gate memory prompt guidance on disable flags - #2565

Merged
oss-maintainer merged 1 commit into
mainfrom
fix/memory-prompt-gated-by-disable-flags
Aug 5, 2026
Merged

oss-maintainer merged 1 commit into
mainfrom
fix/memory-prompt-gated-by-disable-flags

Conversation

@chickenlj

Copy link
Copy Markdown
Collaborator

Summary

  • Wire disableMemoryTools / disableMemoryHooks into WorkspaceContextMiddleware so Memory Recall / Persistence guidance matches registered capabilities
  • When both are disabled, also skip <memory_context> (MEMORY.md) injection while keeping Domain Knowledge / AGENTS / knowledge
  • Document the prompt-side effects in en/zh harness workspace + memory docs; add unit and HarnessAgent coverage

Test plan

  • mvn -pl agentscope-harness -am test -Dtest=WorkspaceContextMiddlewareMemoryPromptTest,WorkspaceContextMiddlewarePathBoundsTest,HarnessAgentTest#disableMemoryTools_omitsHarnessMemoryAndSessionTools+disableMemoryToolsAndHooks_omitMemoryGuidanceFromSystemPrompt
  • Confirm a HarnessAgent built with both disable flags no longer shows Memory Recall/Persistence in the assembled system prompt
  • Confirm tools-only disable still injects MEMORY.md but omits memory_search / memory_save guidance

Align WorkspaceContextMiddleware with disableMemoryTools/disableMemoryHooks
so the system prompt no longer instructs the model to use tools or auto-extract
behavior that were turned off.
Copilot AI review requested due to automatic review settings August 5, 2026 06:41

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.

Pull request overview

This PR aligns the harness’s system-prompt memory guidance and MEMORY.md injection with the actual memory capabilities enabled on a HarnessAgent, based on disableMemoryTools and disableMemoryHooks.

Changes:

  • Gate Memory Recall / Persistence prompt guidance in WorkspaceContextMiddleware based on disableMemoryTools / disableMemoryHooks, and adjust truncation messaging when tools are disabled.
  • Skip <memory_context> (MEMORY.md) injection when both memory tools and hooks are disabled, while keeping AGENTS and Domain Knowledge context.
  • Update EN/ZH docs and add targeted unit/integration coverage for the new prompt behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
docs/v2/zh/docs/harness/workspace.md Documents how memory-related prompt sections and <memory_context> injection change under disable flags (ZH).
docs/v2/zh/docs/harness/memory.md Updates disable-flag semantics and prompt-side effects for memory (ZH).
docs/v2/en/docs/harness/workspace.md Documents prompt trimming/omission behavior tied to memory disable flags (EN).
docs/v2/en/docs/harness/memory.md Updates disable-flag semantics and prompt-side effects for memory (EN).
agentscope-harness/src/test/java/io/agentscope/harness/agent/middleware/WorkspaceContextMiddlewareMemoryPromptTest.java Adds coverage ensuring prompt guidance and <memory_context> match disable-flag combinations.
agentscope-harness/src/test/java/io/agentscope/harness/agent/HarnessAgentTest.java Adds an integration-style assertion that both disable flags remove memory guidance and <memory_context>.
agentscope-harness/src/main/java/io/agentscope/harness/agent/middleware/WorkspaceContextMiddleware.java Implements the new gating for memory guidance and memory context injection based on disable flags.
agentscope-harness/src/main/java/io/agentscope/harness/agent/HarnessAgent.java Wires disable flags into WorkspaceContextMiddleware and documents prompt-side effects on the builder methods.

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.10638% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...s/agent/middleware/WorkspaceContextMiddleware.java 85.10% 6 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@oss-maintainer
oss-maintainer merged commit 9b77823 into main Aug 5, 2026
11 checks passed
@oss-maintainer
oss-maintainer deleted the fix/memory-prompt-gated-by-disable-flags branch August 5, 2026 08:36
wzl521 pushed a commit to wzl521/agentscope-java that referenced this pull request Aug 12, 2026
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.

3 participants