Add wire Debug Level for LLM Request/Response Logging#2020
Merged
ksylvan merged 3 commits intodanielmiessler:mainfrom Feb 22, 2026
Merged
Add wire Debug Level for LLM Request/Response Logging#2020ksylvan merged 3 commits intodanielmiessler:mainfrom
wire Debug Level for LLM Request/Response Logging#2020ksylvan merged 3 commits intodanielmiessler:mainfrom
Conversation
…logging ## CHANGES - Add `Wire` log level constant to debug level enum - Expose `GetLevel()` function for safe concurrent level reads - Log outbound message roles and content at wire debug level - Log inbound stream updates and token usage at wire level - Log non-streaming LLM responses at wire debug level - Update `--debug` flag description to include new level 4 - Update `set_debug_level` locale strings across all 10 languages
## CHANGES - Add debug level 4 (`wire`) to `--debug` flag options - Update zsh completion to include new `4` debug level value - Update bash completion to include `4` in `compgen -W` word list - Update fish completion description and arguments with level 4
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.
Add
wireDebug Level for LLM Request/Response LoggingCloses #2018
Summary
This PR introduces a new debug level,
wire(level 4), that logs the full HTTP-style request/response exchanges between Fabric and LLM backends. This is the most verbose logging tier and sits above the existingtracelevel. The change spans the logging package, the core chatter logic, the CLI flag definition, and all supported i18n locale files.Files Changed
internal/log/log.goWireconstant, updatedLevelFromInt, addedGetLevel()accessorinternal/log/log_test.goLevelFromIntcovering all levels including the newWirelevelinternal/core/chatter.goWire-level debug logging at three key points in the LLM communication lifecycleinternal/cli/flags.go--debugflag description to document level 4internal/i18n/locales/*.jsonset_debug_leveldescription string across all 10 locale filesCode Changes
internal/log/log.go— NewWireLevel andGetLevel()AccessorThe
LevelFromIntfunction was updated to handle the new level precisely:Previously
i >= 3returnedTrace, meaning there was no way to distinguish between 3 and any higher integer. This is now fixed with an exact match for3and a catch-all>= 4forWire.A new thread-safe
GetLevel()function was added:This avoids callers needing to reach into unexported state and ensures proper read-lock semantics.
internal/core/chatter.go— Wire-Level Logging at LLM BoundariesThree logging points were added to capture the full conversation at the wire level:
internal/log/log_test.go— New Test FileA table-driven unit test covers all levels including edge cases:
{in: -1, want: Off}, {in: 0, want: Off}, {in: 4, want: Wire}, {in: 9, want: Wire}, // any value >= 4 maps to WireReason for Changes
Debugging LLM integration issues (e.g., malformed prompts, unexpected model responses, token usage discrepancies) previously required adding temporary ad-hoc logging or attaching a network proxy. The
wirelevel formalises this as a first-class debug capability, making it straightforward to capture the exact data being exchanged with model backends without modifying application code.Impact of Changes
>= 4guard ensures zero overhead unlesswirelogging is explicitly enabled.LevelFromIntfix for thei >= 3edge case is a subtle but correct behaviour change: previously, passing--debug 4(or any value above 3) would have silently returnedTrace. Now it correctly returnsWire. Any existing automation or scripts that passed--debug 4expectingTracebehaviour will now receiveWireverbosity instead — this is the intended and more correct behaviour.GetLevel()accessor is additive and non-breaking.Test Plan
go test ./internal/log/...— the newTestLevelFromInttest should pass covering all level mappings.--debug 4and confirmFABRIC->LLMandLLM->FABRIClines appear on stderr.--debug 3and confirm no wire-level output is produced.UpdateChan, synchronous via directSend).--helpoutput and locale-specific help strings reflect4=wire.Additional Notes
wireterm is borrowed from network-layer logging conventions (e.g., "wire format"), making the intent self-documenting for engineers familiar with distributed systems debugging.4=wirelabel in the i18n locale files is intentionally left untranslated (wire) across all languages, consistent with how technical debug terms are typically handled in developer tooling.