Compact the error a failed command reports, instead of Playwright's whole retry log - #132
Merged
Merged
Conversation
DavertMik
force-pushed
the
fix/condense-playwright-call-log
branch
from
August 22, 2026 00:36
48e38ea to
c25c125
Compare
A failed browser command handed the model Playwright's entire call log: every wait and retry line, the same "element is not enabled" once per attempt, a class attribute broken across six lines, and terminal color codes around all of it. The one fact that decides what to do next -- the element resolved but was disabled -- sat buried in ~850 characters of bookkeeping. compactErrorMessage() strips ANSI, runs the text through the strip strategies and truncates. One strategy today: the call log loses its waiting/retrying/ attempting lines, the rest is deduped, leaving the element that was resolved and why it could not be clicked. The locator is not repeated -- the tool result already carries the command. Errors with no call log pass through untouched. The seven raw lastError.toString()/String(lastError) sites in click, hover, pressKey, form, back and reset now route through errorText(), so that stringification exists once. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
DavertMik
force-pushed
the
fix/condense-playwright-call-log
branch
from
August 22, 2026 00:43
c25c125 to
c479cd7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A failed browser command handed the model Playwright's entire call log — ~850 characters for one disabled Save button: every wait and retry line,
element is not enabledonce per attempt, a class attribute broken across six lines, and ANSI color codes around all of it.Before
After (192 chars)
The implementation
In
src/utils/strings.ts, next to thenormalizeInlineTextandtruncateit reuses. It takes anything and stringifies inside, so no call site wraps its error. No regex, no new file, no new module.stripCallLogis the only strategy today: split on the marker, dropwaiting/retrying/attemptinglines, dedupe the rest with aSet, join. Another error shape — a network failure, a stack trace — is a second function inSTRIP_STRATEGIES, and both the marker and its noise list stay local to the strategy that uses them.The locator line goes with the other
waitinglines because the tool result already carriescommandandlocator; repeating it costs tokens and tells the model nothing new. Errors with noCall log:section (MultipleElementsFoundand its element listing) come back unchanged.The seven raw
lastError.toString()/String(lastError)sites in click, hover, pressKey, form, back and reset now route througherrorText(), so that stringification exists in one place.clickFailureSuggestion()reads this text to tell the model whether the element was disabled, covered, hidden or absent. All four markers sit on lines the filter keeps.Natural next caller
navigator.ts:476trims a failed attempt inline — first non-atline, capped at 220. That is a stack-strip strategy waiting to move into this list, but it changes navigator's output, so it is not in this PR.Tests
bun test tests/integration/81 pass. Unit suite passes except the 12renderCallfailures from theasLocatorlookup onmain, which #131 fixes.🤖 Generated with Claude Code