@@ -308,7 +308,8 @@ func (e *ClaudeEngine) parseClaudeJSONLog(logContent string, verbose bool) LogMe
308308 if messageMap , ok := message .(map [string ]any ); ok {
309309 if content , exists := messageMap ["content" ]; exists {
310310 if contentArray , ok := content .([]any ); ok {
311- e .parseToolCalls (contentArray , toolCallMap )
311+ // Sequence return value intentionally discarded; only toolCallMap is needed here.
312+ e .parseToolCallsWithSequence (contentArray , toolCallMap )
312313 }
313314 }
314315 }
@@ -429,86 +430,6 @@ func (e *ClaudeEngine) parseToolCallsWithSequence(contentArray []any, toolCallMa
429430 return sequence
430431}
431432
432- // parseToolCalls extracts tool call information from Claude log content array without sequence tracking
433- func (e * ClaudeEngine ) parseToolCalls (contentArray []any , toolCallMap map [string ]* ToolCallInfo ) {
434- for _ , contentItem := range contentArray {
435- if contentMap , ok := contentItem .(map [string ]any ); ok {
436- if contentType , exists := contentMap ["type" ]; exists {
437- if typeStr , ok := contentType .(string ); ok {
438- switch typeStr {
439- case "tool_use" :
440- // Extract tool name
441- if toolName , exists := contentMap ["name" ]; exists {
442- if nameStr , ok := toolName .(string ); ok {
443- // Prettify tool name
444- prettifiedName := PrettifyToolName (nameStr )
445-
446- // Special handling for bash - each invocation is unique
447- if nameStr == "Bash" {
448- if input , exists := contentMap ["input" ]; exists {
449- if inputMap , ok := input .(map [string ]any ); ok {
450- if command , exists := inputMap ["command" ]; exists {
451- if commandStr , ok := command .(string ); ok {
452- // Create unique bash entry with command info, avoiding colons
453- uniqueBashName := "bash_" + ShortenCommand (commandStr )
454- prettifiedName = uniqueBashName
455- }
456- }
457- }
458- }
459- }
460-
461- // Calculate input size from the input field
462- inputSize := 0
463- if input , exists := contentMap ["input" ]; exists {
464- inputSize = e .estimateInputSize (input )
465- }
466-
467- // Initialize or update tool call info
468- if toolInfo , exists := toolCallMap [prettifiedName ]; exists {
469- toolInfo .CallCount ++
470- if inputSize > toolInfo .MaxInputSize {
471- toolInfo .MaxInputSize = inputSize
472- }
473- } else {
474- toolCallMap [prettifiedName ] = & ToolCallInfo {
475- Name : prettifiedName ,
476- CallCount : 1 ,
477- MaxInputSize : inputSize ,
478- MaxOutputSize : 0 , // Will be updated when we find tool results
479- MaxDuration : 0 , // Will be updated when we find execution timing
480- }
481- }
482- }
483- }
484- case "tool_result" :
485- // Extract output size for tool results
486- if content , exists := contentMap ["content" ]; exists {
487- if contentStr , ok := content .(string ); ok {
488- // Estimate token count (rough approximation: 1 token = ~4 characters)
489- outputSize := len (contentStr ) / 4
490-
491- // Find corresponding tool call to update max output size
492- if toolUseID , exists := contentMap ["tool_use_id" ]; exists {
493- if _ , ok := toolUseID .(string ); ok {
494- // This is simplified - in a full implementation we'd track tool_use_id to tool name mapping
495- // For now, we'll update the max output size for all tools (conservative estimate)
496- for _ , toolInfo := range toolCallMap {
497- if outputSize > toolInfo .MaxOutputSize {
498- toolInfo .MaxOutputSize = outputSize
499- }
500- }
501- }
502- }
503- }
504- }
505- }
506- }
507- }
508- }
509- }
510- }
511-
512433// estimateInputSize estimates the input size in tokens from a tool input object
513434func (e * ClaudeEngine ) estimateInputSize (input any ) int {
514435 // Convert input to JSON string to get approximate size
0 commit comments