Class WorkspaceContextMiddleware

java.lang.Object
io.agentscope.harness.agent.middleware.WorkspaceContextMiddleware
All Implemented Interfaces:
io.agentscope.core.middleware.MiddlewareBase, HarnessRuntimeMiddleware

public class WorkspaceContextMiddleware extends Object implements HarnessRuntimeMiddleware
Appends workspace context (session info, AGENTS.md, MEMORY.md, knowledge) to the system prompt via onSystemPrompt(Agent, RuntimeContext, String).

Runs once per call() (just like the previous WorkspaceContextHook fired on PreCallEvent).

Memory-related guidance and <memory_context> injection are gated by the same builder flags as Harness memory tools/hooks (disableMemoryTools / disableMemoryHooks) so the model is not instructed to use capabilities that are turned off.

  • Constructor Details

    • WorkspaceContextMiddleware

      public WorkspaceContextMiddleware(WorkspaceManager workspaceManager)
    • WorkspaceContextMiddleware

      public WorkspaceContextMiddleware(WorkspaceManager workspaceManager, int maxContextTokens)
    • WorkspaceContextMiddleware

      public WorkspaceContextMiddleware(WorkspaceManager workspaceManager, String agentName, String environmentMemory, int maxContextTokens)
    • WorkspaceContextMiddleware

      public WorkspaceContextMiddleware(WorkspaceManager workspaceManager, String agentName, String environmentMemory, int maxContextTokens, boolean disableMemoryTools, boolean disableMemoryHooks)
  • Method Details

    • setAdditionalContextFiles

      public void setAdditionalContextFiles(List<String> files)
    • isDisableMemoryTools

      public boolean isDisableMemoryTools()
      Whether memory tools are disabled for this middleware (affects prompt guidance).
    • isDisableMemoryHooks

      public boolean isDisableMemoryHooks()
      Whether memory hooks are disabled for this middleware (affects prompt guidance).
    • setArtifactDeliveryEnabled

      public void setArtifactDeliveryEnabled(boolean artifactDeliveryEnabled)
      Whether an ArtifactDeliveryTarget is configured and the deliver_artifact tool is exposed. When true, the sandbox branch of the workspace paragraph tells the model to use that tool; when false, it states that files cannot leave the sandbox.
    • onSystemPrompt

      public reactor.core.publisher.Mono<String> onSystemPrompt(io.agentscope.core.agent.Agent agent, io.agentscope.core.agent.RuntimeContext ctx, String currentPrompt)
      Specified by:
      onSystemPrompt in interface io.agentscope.core.middleware.MiddlewareBase