Skip to content

Parsers: Sanitize A2A and MCP debug log values only when Debug is on #1707

Closed

Description

@huang195

Problem

Two Debug log lines in the protocol parsers call model.SanitizeLogValue when Debug is off. Go evaluates the arguments of slog.Debug before the level check. The sanitizer allocates for each value that has a control rune, and almost every real text has "\n".

  • parse/a2a, the a2a-parser: part loop in the request parser: one sanitize call for each message part.
  • parse/mcp, the mcp-parser: payload line: string(body) copies the whole request body before Truncate. Each MCP request with Debug off allocates a copy the size of the body.

Fix decision

Use the guard from #1703 (commit 0cba973) at each site:

if slog.Default().Enabled(context.Background(), slog.LevelDebug) { ... }

For each site, add the two tests from #1703. The Debug-off test compares allocations for U+0085 and "é". The Debug-on test checks that the line is still logged.

The clawgenti review on #1703 found this. That PR changes only the inference parser.

Assisted-By: Claude (Anthropic AI) [email protected]

Activity

  1. self-assigned this
    on Nov 7, 2026
  2. added a commit that references this issue on Nov 7, 2026
    44cb186
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions