Repository navigation
Description
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
-
Use the current
2.1.0-SNAPSHOTimplementation at31c7db8c90866502b8685add63adcfc801555eda. -
Put the following in workspace
AGENTS.md:Run `mvn test && echo "OK"` with List<String>.
-
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 && echo "OK"` with List<String>. -
Separately, make workspace
AGENTS.mdlarger than 100 KiB.WorkspaceContextMiddlewarereads 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.mdwith 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, commit31c7db8c90866502b8685add63adcfc801555eda - 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
fix(harness): preserve workspace instruction content and cap AGENTS.md (