nullabot 1.0.2__tar.gz → 1.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nullabot
3
- Version: 1.0.2
3
+ Version: 1.0.3
4
4
  Summary: 24/7 AI agents that think, design, and code - controlled via Telegram
5
5
  Project-URL: Homepage, https://github.com/ebokoo/nullabot
6
6
  Project-URL: Repository, https://github.com/ebokoo/nullabot
@@ -342,18 +342,35 @@ IMPORTANT:
342
342
  # Parse JSON response to extract tokens
343
343
  try:
344
344
  data = json.loads(output)
345
- result_text = data.get("result", output)
346
345
 
347
- # Extract token usage from response
348
- input_tokens = data.get("input_tokens", 0)
349
- output_tokens = data.get("output_tokens", 0)
346
+ # Get result text - try multiple fields
347
+ result_text = data.get("result") or data.get("content") or ""
350
348
 
351
- # Also check nested usage object
349
+ # If no result text but we have the raw output, use a summary
350
+ if not result_text and data.get("subtype") == "error_max_turns":
351
+ result_text = "Reached max turns limit. Work saved."
352
+ elif not result_text:
353
+ result_text = output # Fallback to raw output
354
+
355
+ # Extract token usage from nested usage object
352
356
  usage = data.get("usage", {})
353
- if not input_tokens:
354
- input_tokens = usage.get("input_tokens", 0)
355
- if not output_tokens:
356
- output_tokens = usage.get("output_tokens", 0)
357
+
358
+ # Input includes regular + cache tokens
359
+ input_tokens = (
360
+ usage.get("input_tokens", 0) +
361
+ usage.get("cache_read_input_tokens", 0) +
362
+ usage.get("cache_creation_input_tokens", 0)
363
+ )
364
+ output_tokens = usage.get("output_tokens", 0)
365
+
366
+ # Also check modelUsage for more detailed breakdown
367
+ model_usage = data.get("modelUsage", {})
368
+ if model_usage and not input_tokens:
369
+ for model, mu in model_usage.items():
370
+ input_tokens += mu.get("inputTokens", 0)
371
+ input_tokens += mu.get("cacheReadInputTokens", 0)
372
+ input_tokens += mu.get("cacheCreationInputTokens", 0)
373
+ output_tokens += mu.get("outputTokens", 0)
357
374
 
358
375
  return result_text, True, input_tokens, output_tokens
359
376
  except json.JSONDecodeError:
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nullabot"
3
- version = "1.0.2"
3
+ version = "1.0.3"
4
4
  description = "24/7 AI agents that think, design, and code - controlled via Telegram"
5
5
  readme = "README.md"
6
6
  license = "MIT"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes