get_error_context
Extract source snippets and git diffs from error logs, stripping framework noise and redacting credentials.
Instructions
Extracts focused source code snippets and git diffs from a raw error log or stack trace, stripping framework noise (node_modules, site-packages) and redacting credentials.
• Side Effects: None. Strictly read-only; does not modify workspace files, git state, or environment variables. • Auth & Permissions: None required. Reads local filesystem within the current workspace boundary. • Rate Limits: None. Runs entirely locally on native machine code. • Return Shape: Returns a JSON object with 'sanitized_trace' (string without secrets/noise), 'source_frames' (array of objects with file, line, code_snippet), and 'git_diff' (string or null). • Failure Modes: If source files referenced in the trace do not exist locally, omits code snippets for those frames while still returning the sanitized trace. Returns an error JSON on unreadable input. • When to use: Call immediately when receiving a runtime exception, test failure, or compiler error to isolate the root cause before planning code fixes. • When NOT to use: Do NOT use to search web solutions (use search_stack_overflow), do NOT use to modify files (use apply_code_patch), and do NOT use to statically lint clean code without an error log (use analyze_code). • Prerequisites: Workspace directory must be accessible locally; git repository recommended for diff extraction.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| log | Yes | Raw error stack trace, compiler panic, or terminal stderr string to analyze (e.g. Python traceback, Node.js error, Rust panic). Must be non-empty UTF-8 text up to 1MB. Automatically sanitized of API keys, JWTs, and passwords. | |
| strategy | No | Context pruning and token budgeting strategy. Options: 'aggressive' (default: excises all framework internals and idle threads), 'conservative' (retains boundary transition frames), or 'lossless_compact' (preserves all frames, compressing only whitespace and redacting credentials). | |
| context_lines | No | Number of source code lines to retrieve above and below each detected error line. Integer between 0 and 100. Defaults to 10 lines. Larger values expand the context window but consume more LLM tokens. |