Skip to content

fix: truncate long output#35

Merged
dexhunter merged 6 commits intodevfrom
fix/truncate_long_output
Jul 9, 2025
Merged

fix: truncate long output#35
dexhunter merged 6 commits intodevfrom
fix/truncate_long_output

Conversation

@dexhunter
Copy link
Copy Markdown
Member

Some execution results have too long output and leading the 413 error

╭───────────────────────────── Optimization Error ─────────────────────────────╮
│ Error: 413 Client Error: Request Entity Too Large for url:                   │
│ https://api.weco.ai/v1/runs/a0fa10d7-3e4e-487b-b52e-5f8ba4cc0c68/suggest     │
╰──────────────────────────────────────────────────────────────────────────────╯

@dexhunter dexhunter requested a review from DhruvSrikanth July 6, 2025 08:42
@DhruvSrikanth DhruvSrikanth requested a review from Copilot July 7, 2025 10:48
@DhruvSrikanth DhruvSrikanth added the bug Something isn't working label Jul 7, 2025

This comment was marked as outdated.

DhruvSrikanth and others added 4 commits July 7, 2025 11:50
@DhruvSrikanth DhruvSrikanth changed the base branch from main to dev July 7, 2025 12:31
@DhruvSrikanth DhruvSrikanth requested a review from Copilot July 8, 2025 15:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds output truncation to prevent oversized responses and applies it to the evaluation runner to avoid 413 errors.

  • Introduce DEFAULT_MAX_LINES and DEFAULT_MAX_CHARS constants.
  • Implement truncate_output helper to trim by lines and/or characters with a descriptive prefix.
  • Update run_evaluation to return the truncated output.
Comments suppressed due to low confidence (1)

weco/utils.py:131

  • Add unit tests for truncate_output to cover scenarios where only lines exceed, only characters exceed, both conditions, and no truncation.
def truncate_output(output: str, max_lines: int = DEFAULT_MAX_LINES, max_chars: int = DEFAULT_MAX_CHARS) -> str:

Copy link
Copy Markdown
Member

@DhruvSrikanth DhruvSrikanth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Feel free to merge @dexhunter

@dexhunter dexhunter merged commit 7749a51 into dev Jul 9, 2025
1 check passed
@dexhunter dexhunter deleted the fix/truncate_long_output branch July 9, 2025 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants