dbgWriteMessage records a chmctx.Message readably: content and tool calls each get a labeled section. No-op when logging is off, so callers needn't guard.
(category string, msg chmctx.Message)
| 148 | // dbgWriteMessage records a chmctx.Message readably: content and tool calls |
| 149 | // each get a labeled section. No-op when logging is off, so callers needn't guard. |
| 150 | func dbgWriteMessage(category string, msg chmctx.Message) { |
| 151 | if !dbgEnabled() { |
| 152 | return |
| 153 | } |
| 154 | var b strings.Builder |
| 155 | if msg.Content != "" { |
| 156 | b.WriteString("CONTENT:\n") |
| 157 | b.WriteString(msg.Content) |
| 158 | b.WriteString("\n") |
| 159 | } |
| 160 | for _, tc := range msg.ToolCalls { |
| 161 | args, _ := json.Marshal(tc.Arguments) |
| 162 | fmt.Fprintf(&b, "TOOL_CALL %s id=%s args=%s\n", tc.Name, tc.ID, args) |
| 163 | } |
| 164 | if msg.ToolCallID != "" { |
| 165 | fmt.Fprintf(&b, "tool=%s id=%s\n", msg.ToolName, msg.ToolCallID) |
| 166 | } |
| 167 | dbgWritef(category, "%s", strings.TrimRight(b.String(), "\n")) |
| 168 | } |
no test coverage detected