feat: add optional stack traces to list_console_messages - #2505
Merged
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Adds an opt-in includeStackTraces parameter to list_console_messages. When set, each listed message includes its resolved, source-mapped stack trace as indented frames in the text output and as a pre-formatted stackTrace string in structuredContent, matching the format used by get_console_message. Default output is unchanged. Fixes ChromeDevTools#383
ZayanKhan-12
force-pushed
the
feat/383-console-stack
branch
from
August 8, 2026 21:46
44cdd02 to
3226a6d
Compare
OrKoN
approved these changes
Aug 10, 2026
OrKoN
left a comment
Collaborator
There was a problem hiding this comment.
LGTM (this matches what we should in DevTools UI so generally could be useful to agents if there are not so many console messages).
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.
What
Adds an opt-in
includeStackTracesparameter tolist_console_messages. When set, each listed message includes its resolved (source-mapped, ignore-list-filtered) stack trace — in the text output as indented frames under the message line, and instructuredContentas a pre-formattedstackTracestring, matching the formatget_console_messagealready uses.Why
Fixes the workflow described in #383: today the list output only contains plain message text, so an LLM debugging a page has to call
get_console_messageonce per message to learn which file/function/line failed. WithincludeStackTraces: truethe model can map every error to its source in a single call.Design notes:
createStackTraceForConsoleMessage/SymbolizedError) and the existingformatStackTraceformatting, so frames are source-mapped and ignore-listed exactly like inget_console_message.Caused by:chains), and grouped repeated messages ([N times]).Before / after
Default (unchanged):
With
includeStackTraces: true:structuredContent.consoleMessages[i]gains an optional"stackTrace": "at foo (foo.ts:10:2)\nat bar (foo.ts:20:2)\n..."field.Relationship to #2060
Complements #2060 (source location for
list_console_messages, issue #903): that PR surfaces the top-frame location for every message by default, while this one exposes the full stack trace behind an explicit opt-in. The features are independent and the changes are designed to coexist with minimal conflict.Testing
npm run build— passesnpm run test:no-build— full suite passes (exit 0)npm run check-format— passesnpm run gen— regenerateddocs/tool-reference.md, CLI options, and tool-call metrics (included)New coverage:
tests/formatters/ConsoleFormatter.test.ts— snapshot tests for concisetoString/toJSONwithfetchStackTraceset (console message + uncaught error) and for the unchanged default.tests/tools/console.test.ts— integration tests asserting frames (at failingFn) appear in text andstructuredContentwhenincludeStackTraces: true, and are absent by default.Fixes #383
🤖 Generated with Claude Code