Skip to content

fix: make get_html truncation configurable instead of hard-coded#490

Open
xlyoung wants to merge 1 commit into
strands-agents:mainfrom
xlyoung:fix/get-html-remove-hardcoded-truncation
Open

fix: make get_html truncation configurable instead of hard-coded#490
xlyoung wants to merge 1 commit into
strands-agents:mainfrom
xlyoung:fix/get-html-remove-hardcoded-truncation

Conversation

@xlyoung
Copy link
Copy Markdown

@xlyoung xlyoung commented Jun 4, 2026

Problem

The get_html browser action had a hard-coded 1,000-character truncation limit that returned broken HTML fragments:

truncated_result = result[:1000] + "..." if len(result) > 1000 else result

This caused issues because:

  1. 1,000 characters is too small for most real-world HTML content
  2. Truncating at a character boundary breaks HTML structure (mid-tag)
  3. Users had no way to control or disable the truncation

Fix

  • Add optional max_length parameter to GetHtmlAction model
  • Only truncate when max_length is explicitly set by the user
  • Default is None (no truncation, return full content)
  • Truncation message now includes "...[truncated]" indicator for clarity

Before

# Hard-coded truncation at 1000 chars
truncated_result = result[:1000] + "..." if len(result) > 1000 else result

After

# Only truncate if user explicitly sets max_length
if action.max_length is not None and len(result) > action.max_length:
    result = result[:action.max_length] + "...[truncated]"

Testing

Existing tests pass. The browser tests require bedrock_agentcore which is not available in the test environment (pre-existing issue).

Fixes #407

The get_html action had a hard-coded 1,000-character truncation limit
that returned broken HTML fragments (mid-tag). This was problematic
because:

1. 1,000 characters is too small for most real-world HTML content
2. Truncating at a character boundary breaks HTML structure
3. Users had no way to control or disable the truncation

Changes:
- Add optional `max_length` parameter to GetHtmlAction model
- Only truncate when max_length is explicitly set by the user
- Default is None (no truncation, return full content)
- Truncation message now includes "...[truncated]" indicator

Fixes strands-agents#407
@xlyoung xlyoung requested a deployment to manual-approval June 4, 2026 03:25 — with GitHub Actions Waiting
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] get_html hard-coded 1,000-character truncation returns broken HTML fragments

1 participant