Skip to content

fix(harness): preserve workspace instruction content and cap AGENTS.md - #3723

Merged
Buktal merged 1 commit into
agentscope-ai:mainfrom
Buktal:codex/harness-rule-injection-fidelity
Oct 23, 2026
Merged

Buktal merged 1 commit into
agentscope-ai:mainfrom
Buktal:codex/harness-rule-injection-fidelity

Conversation

@Buktal

@Buktal Buktal commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

AgentScope-Java Version

2.1.0-SNAPSHOT

Summary

Closes #3722.

Workspace instruction examples currently reach the model with HTML entities, and oversized AGENTS.md content is injected without a source limit. Preserve literal bodies and bound the workspace rules before rendering:

workspace AGENTS.md
  → strip surrounding whitespace
  → retain at most 100 KiB of UTF-8 text, without splitting a character
  → append a visible marker when truncated
  → prefix the existing applicability sentence
  → render as SYSTEM project_rules
  • ContextRenderer preserves body characters and neutralizes only its own closing delimiters. Reference/runtime items also neutralize the outer HARNESS_CONTEXT delimiter; attribute values remain escaped.
  • WorkspaceContextMiddleware uses a bounded UTF-8 encoding buffer and keeps the applicability sentence inside nonempty rules instead of repeating it in environment text.
  • Remove unused internal legacy-format state and its child-builder propagation; retain useLegacyXmlWorkspaceContext(boolean) as a deprecated fluent no-op. Remove the unused RULES_DIR constant.
  • Add renderer/rule-content regression tests, update context snapshots, and document the behavior in English and Chinese.

Evidence

  • Before: executing the upstream renderer at 31c7db8c90866502b8685add63adcfc801555eda produces mvn test && echo "OK" and List<String>.
    After: regression tests and an offline final-request probe preserve mvn test && echo "OK" and List<String> while neutralizing embedded frame-closing delimiters.
  • Before: workspace rules have no individual source cap.
    After: 102,400-byte content remains unchanged; 102,401-byte content is capped with \n\n[File truncated: AGENTS.md]. The probe verifies every cut offset for 1–4-byte UTF-8 characters, per-user isolation, stable SYSTEM bytes, absent-file behavior, and the deprecated builder method.

Validation on Windows with GraalVM 21.0.12 (Java release target 17):

  • mvn -B -T1C clean verify: BUILD SUCCESS; 11,115 tests, 0 failures, 0 errors, 240 skipped. Spotless checks passed as part of the build.
  • npm test in docs: 13 passed.
  • npm run validate in docs: passed.
  • npm run broken-links in docs: exits 1 with 2,218 reported links in 326 files. Running the same command and CLI against an exported, unmodified 31c7db8c90866502b8685add63adcfc801555eda produces an identical report.

Merge Danger

Door: two-way

No persisted-state migration or dependency changes. The source cap does not guarantee that an entire request fits every model's token budget.

Blast Radius: Harness

The shared renderer changes literal body output for SYSTEM, runtime, and reference context. Oversized workspace rules now omit their tail and expose a truncation marker.

Checklist

  • Code formatting verified by Spotless.
  • Java tests verified; skipped tests and the existing docs link-check failure are reported above.
  • Javadoc comments describe the rendering and truncation behavior.
  • Related English and Chinese documentation updated.
  • Code is ready for review.

@agentscope-ai agentscope-ai deleted a comment from mintlify Bot Oct 22, 2026
@Buktal
Buktal merged commit 455be59 into agentscope-ai:main Oct 23, 2026
7 checks passed
chickenlj added a commit that referenced this pull request Nov 13, 2026
#3723)

Source: 455be59
Candidate: 9221b57c85b2f3d4b15a453a621150d8afbee026
Union-Of: execution53+skill-union(810c7d7) + tasks-standalone(511fd8a5)
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.

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

2 participants