Skip to content

[Bug]: Workspace instruction bodies are HTML-escaped and AGENTS.md has no size limit #3722

Closed

Description

@Buktal

Describe the bug

Harness HTML-escapes the entire body of workspace instructions before sending them to the model. This changes shell operators, quoted strings, Java generics, and other literal examples in AGENTS.md. Workspace AGENTS.md also has no source-size limit, so an oversized file is injected in full as required SYSTEM material.

To Reproduce

  1. Use the current 2.1.0-SNAPSHOT implementation at 31c7db8c90866502b8685add63adcfc801555eda.

  2. Put the following in workspace AGENTS.md:

    Run `mvn test && echo "OK"` with List<String>.
  3. Inspect the model request, or reproduce the rendering directly:

    String rendered = ContextRenderer.render(List.of(
        ContextItem.instruction(
            "project_rules",
            "workspace:AGENTS.md",
            "Run `mvn test && echo \"OK\"` with List<String>.")));
    System.out.println(rendered);

    The body becomes:

    Run `mvn test &amp;&amp; echo &quot;OK&quot;` with List&lt;String&gt;.
    
  4. Separately, make workspace AGENTS.md larger than 100 KiB. WorkspaceContextMiddleware reads and registers the complete stripped content without a source cap. Because these rules are required SYSTEM material, they cannot be omitted by optional-material selection and can exhaust the configured input budget.

The existing applicability sentence is also emitted separately in workspace environment text rather than next to the rules it describes.

Expected behavior

  • Preserve literal instruction bodies, while neutralizing the renderer's own closing delimiters and continuing to escape attribute values.
  • Bound workspace AGENTS.md with a documented head limit, preserve UTF-8 character boundaries, and show a truncation marker.
  • Keep the applicability sentence adjacent to nonempty rules.

A 100 KiB source cap is the proposed bound; it does not guarantee that the complete request fits every model's token budget.

Error messages

The short example has no exception: the defect is the changed text in the model input. This report does not depend on a real model call.

Environment

  • AgentScope-Java: 2.1.0-SNAPSHOT, commit 31c7db8c90866502b8685add63adcfc801555eda
  • Java: GraalVM 21.0.12; project release target 17
  • OS: Windows

Additional context

The shared renderer also handles reference and runtime context, so a fix should preserve their wrapper delimiters as well as the SYSTEM instruction frame. Existing workspace filesystem and user-isolation behavior should remain intact.

Activity

  1. added
    bug
    on Oct 22, 2026
  2. added a commit that references this issue on Oct 23, 2026
    455be59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions