Skip to content

fix(agent): load_skill carries an in-band truncation marker (#4163) - #4265

Open
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:fix/4163-skill-truncation-marker
Open

fix(agent): load_skill carries an in-band truncation marker (#4163)#4265
iroiro147 wants to merge 1 commit into
block:mainfrom
iroiro147:fix/4163-skill-truncation-marker

Conversation

@iroiro147

Copy link
Copy Markdown

What

load_skill truncated any output over MAX_SKILL_BODY_BYTES (32 KiB) via
truncate_at_boundary and returned the truncated text as if complete — no
log, no error, is_error: false. Instructions at the tail of a SKILL.md
(often the output format, refusal rules, or verification checklist) silently
vanished from the model's context.

Changes

  • New truncate_skill_output helper: when the cap trips, reserves room for
    \n\n[…truncated…], truncates via the existing boundary-aware fn, then
    appends the marker in-band. Model can see the loss; callers can detect it
    without a separate channel.
  • Both truncation sites (skill body, supporting files) route through the
    helper — no behavioral drift between paths.
  • Existing call_load_skill_truncates_large_supporting_file test strengthened
    to require the marker.

Tests

  • New: truncate_skill_output_under_cap_is_unchanged
  • New: truncate_skill_output_over_cap_appends_marker_and_stays_within_cap
  • New: truncate_skill_output_emits_valid_utf8_at_boundary
  • Extended: call_load_skill_truncates_large_supporting_file now asserts the
    marker is present in the tail.
  • All 14 builtin:: tests pass; full buzz-agent --lib suite 385/385.

Refs #4163

`load_skill` capped `output` at `MAX_SKILL_BODY_BYTES` (32 KiB) with
`truncate_at_boundary` and returned the truncated text as if it were complete:
no log, no error, no in-band marker, `is_error: false`. A truncated SKILL.md
was indistinguishable from a whole one, so instructions at the tail — often
the output format, refusal rules, or verification checklist — silently
disappeared from the model's context.

Add a shared `truncate_skill_output` helper: when the cap trips, reserve room
for a `\n\n[…truncated…]` marker, truncate to fit, then append the marker in-
band so the model can see content was lost and callers can detect it without
a separate channel. Both truncation sites (skill body and supporting files)
now route through the helper.

The existing `call_load_skill_truncates_large_supporting_file` test is
extended to require the marker; two new unit tests cover pass-through under
the cap and cap+marker+Utf8 boundary behavior over the cap.

Refs block#4163

Signed-off-by: Sarthak Singh <sarthak.singh@juspay.in>
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.

1 participant