mojentic 0.8.4__py3-none-any.whl → 1.0.0__py3-none-any.whl

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.
Files changed (106) hide show
  1. _examples/async_dispatcher_example.py +12 -4
  2. _examples/async_llm_example.py +1 -2
  3. _examples/broker_as_tool.py +42 -17
  4. _examples/broker_examples.py +5 -7
  5. _examples/broker_image_examples.py +1 -1
  6. _examples/characterize_ollama.py +3 -3
  7. _examples/characterize_openai.py +1 -1
  8. _examples/chat_session.py +2 -2
  9. _examples/chat_session_with_tool.py +2 -2
  10. _examples/coding_file_tool.py +16 -18
  11. _examples/current_datetime_tool_example.py +2 -2
  12. _examples/embeddings.py +1 -1
  13. _examples/ephemeral_task_manager_example.py +15 -11
  14. _examples/fetch_openai_models.py +10 -3
  15. _examples/file_deduplication.py +6 -6
  16. _examples/file_tool.py +5 -5
  17. _examples/image_analysis.py +2 -3
  18. _examples/image_broker.py +1 -1
  19. _examples/image_broker_splat.py +1 -1
  20. _examples/iterative_solver.py +3 -3
  21. _examples/model_characterization.py +2 -0
  22. _examples/openai_gateway_enhanced_demo.py +15 -5
  23. _examples/raw.py +1 -1
  24. _examples/react/agents/decisioning_agent.py +173 -15
  25. _examples/react/agents/summarization_agent.py +89 -0
  26. _examples/react/agents/thinking_agent.py +84 -14
  27. _examples/react/agents/tool_call_agent.py +83 -0
  28. _examples/react/formatters.py +38 -4
  29. _examples/react/models/base.py +60 -11
  30. _examples/react/models/events.py +76 -8
  31. _examples/react.py +71 -21
  32. _examples/recursive_agent.py +2 -2
  33. _examples/simple_llm.py +3 -3
  34. _examples/simple_llm_repl.py +1 -1
  35. _examples/simple_structured.py +1 -1
  36. _examples/simple_tool.py +2 -2
  37. _examples/solver_chat_session.py +5 -11
  38. _examples/streaming.py +36 -18
  39. _examples/tell_user_example.py +4 -4
  40. _examples/tracer_demo.py +18 -20
  41. _examples/tracer_qt_viewer.py +49 -46
  42. _examples/working_memory.py +1 -1
  43. mojentic/__init__.py +3 -3
  44. mojentic/agents/__init__.py +26 -8
  45. mojentic/agents/{agent_broker.py → agent_event_adapter.py} +3 -3
  46. mojentic/agents/async_aggregator_agent_spec.py +32 -33
  47. mojentic/agents/async_llm_agent.py +9 -5
  48. mojentic/agents/async_llm_agent_spec.py +21 -22
  49. mojentic/agents/base_async_agent.py +2 -2
  50. mojentic/agents/base_llm_agent.py +6 -2
  51. mojentic/agents/iterative_problem_solver.py +11 -5
  52. mojentic/agents/simple_recursive_agent.py +11 -10
  53. mojentic/agents/simple_recursive_agent_spec.py +423 -0
  54. mojentic/async_dispatcher.py +0 -1
  55. mojentic/async_dispatcher_spec.py +1 -1
  56. mojentic/context/__init__.py +0 -2
  57. mojentic/dispatcher.py +7 -8
  58. mojentic/llm/__init__.py +5 -5
  59. mojentic/llm/gateways/__init__.py +19 -18
  60. mojentic/llm/gateways/anthropic.py +1 -0
  61. mojentic/llm/gateways/anthropic_messages_adapter.py +0 -1
  62. mojentic/llm/gateways/llm_gateway.py +1 -1
  63. mojentic/llm/gateways/ollama.py +23 -18
  64. mojentic/llm/gateways/openai.py +243 -44
  65. mojentic/llm/gateways/openai_message_adapter_spec.py +3 -3
  66. mojentic/llm/gateways/openai_model_registry.py +7 -6
  67. mojentic/llm/gateways/openai_model_registry_spec.py +1 -2
  68. mojentic/llm/gateways/openai_temperature_handling_spec.py +2 -2
  69. mojentic/llm/llm_broker.py +162 -2
  70. mojentic/llm/llm_broker_spec.py +76 -2
  71. mojentic/llm/message_composers.py +6 -3
  72. mojentic/llm/message_composers_spec.py +5 -1
  73. mojentic/llm/registry/__init__.py +0 -3
  74. mojentic/llm/registry/populate_registry_from_ollama.py +2 -2
  75. mojentic/llm/tools/__init__.py +0 -9
  76. mojentic/llm/tools/ask_user_tool.py +11 -5
  77. mojentic/llm/tools/current_datetime.py +9 -6
  78. mojentic/llm/tools/date_resolver.py +10 -4
  79. mojentic/llm/tools/date_resolver_spec.py +0 -1
  80. mojentic/llm/tools/ephemeral_task_manager/append_task_tool.py +4 -1
  81. mojentic/llm/tools/ephemeral_task_manager/ephemeral_task_list.py +1 -1
  82. mojentic/llm/tools/ephemeral_task_manager/insert_task_after_tool.py +4 -1
  83. mojentic/llm/tools/ephemeral_task_manager/prepend_task_tool.py +5 -2
  84. mojentic/llm/tools/file_manager.py +131 -28
  85. mojentic/llm/tools/file_manager_spec.py +0 -3
  86. mojentic/llm/tools/llm_tool.py +1 -1
  87. mojentic/llm/tools/llm_tool_spec.py +0 -2
  88. mojentic/llm/tools/organic_web_search.py +4 -2
  89. mojentic/llm/tools/tell_user_tool.py +6 -2
  90. mojentic/llm/tools/tool_wrapper.py +2 -2
  91. mojentic/tracer/__init__.py +1 -10
  92. mojentic/tracer/event_store.py +7 -8
  93. mojentic/tracer/event_store_spec.py +1 -2
  94. mojentic/tracer/null_tracer.py +37 -43
  95. mojentic/tracer/tracer_events.py +8 -2
  96. mojentic/tracer/tracer_events_spec.py +6 -7
  97. mojentic/tracer/tracer_system.py +37 -36
  98. mojentic/tracer/tracer_system_spec.py +21 -6
  99. mojentic/utils/__init__.py +1 -1
  100. mojentic/utils/formatting.py +1 -0
  101. {mojentic-0.8.4.dist-info → mojentic-1.0.0.dist-info}/METADATA +76 -27
  102. mojentic-1.0.0.dist-info/RECORD +149 -0
  103. mojentic-0.8.4.dist-info/RECORD +0 -146
  104. {mojentic-0.8.4.dist-info → mojentic-1.0.0.dist-info}/WHEEL +0 -0
  105. {mojentic-0.8.4.dist-info → mojentic-1.0.0.dist-info}/licenses/LICENSE.md +0 -0
  106. {mojentic-0.8.4.dist-info → mojentic-1.0.0.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,6 @@
1
1
  import os
2
2
  import re
3
3
  import glob
4
- import difflib
5
4
 
6
5
  from mojentic.llm.tools.llm_tool import LLMTool
7
6
 
@@ -93,7 +92,6 @@ class FilesystemGateway:
93
92
 
94
93
  return matching_lines
95
94
 
96
-
97
95
  def edit_file_with_diff(self, path: str, file_name: str, diff: str) -> str:
98
96
  """Edit a file by applying a diff to it."""
99
97
  resolved_path = self._resolve_path(path)
@@ -150,14 +148,14 @@ class FilesystemGateway:
150
148
  match = re.match(r'@@ -(\d+) \+(\d+) @@', line)
151
149
  if match:
152
150
  start_line = int(match.group(1))
153
- start_line_new = int(match.group(2))
151
+ int(match.group(2))
154
152
  else:
155
153
  # Skip invalid hunk header
156
154
  i += 1
157
155
  continue
158
156
  else:
159
157
  start_line = int(match.group(1))
160
- start_line_new = int(match.group(3))
158
+ int(match.group(3))
161
159
 
162
160
  # Line numbers in diff are 1-based, but our array is 0-based
163
161
  start_line -= 1
@@ -308,17 +306,29 @@ class ListFilesTool(LLMTool):
308
306
  "type": "function",
309
307
  "function": {
310
308
  "name": "list_files",
311
- "description": "List files in the specified directory (non-recursive), optionally filtered by extension. Use this when you need to see what files are available in a specific directory without including subdirectories.",
309
+ "description": (
310
+ "List files in the specified directory (non-recursive), optionally filtered by extension. "
311
+ "Use this when you need to see what files are available in a specific directory without "
312
+ "including subdirectories."
313
+ ),
312
314
  "parameters": {
313
315
  "type": "object",
314
316
  "properties": {
315
317
  "path": {
316
318
  "type": "string",
317
- "description": "The path relative to the sandbox root to list files from. For example, '.' for the root directory, 'src' for the src directory, or 'docs/images' for a nested directory."
319
+ "description": (
320
+ "The path relative to the sandbox root to list files from. For example, '.' for "
321
+ "the root directory, 'src' for the src directory, or 'docs/images' for a nested "
322
+ "directory."
323
+ )
318
324
  },
319
325
  "extension": {
320
326
  "type": "string",
321
- "description": "The file extension to filter by (e.g., '.py', '.txt', '.md'). If not provided, all files will be listed. For example, using '.py' will only list Python files in the directory."
327
+ "description": (
328
+ "The file extension to filter by (e.g., '.py', '.txt', '.md'). If not provided, "
329
+ "all files will be listed. For example, using '.py' will only list Python files "
330
+ "in the directory."
331
+ )
322
332
  }
323
333
  },
324
334
  "additionalProperties": False,
@@ -356,13 +366,20 @@ class ReadFileTool(LLMTool):
356
366
  "type": "function",
357
367
  "function": {
358
368
  "name": "read_file",
359
- "description": "Read the entire content of a file as a string. Use this when you need to access or analyze the complete contents of a file.",
369
+ "description": (
370
+ "Read the entire content of a file as a string. Use this when you need to access or "
371
+ "analyze the complete contents of a file."
372
+ ),
360
373
  "parameters": {
361
374
  "type": "object",
362
375
  "properties": {
363
376
  "path": {
364
377
  "type": "string",
365
- "description": "The full relative path including the filename of the file to read. For example, 'README.md' for a file in the root directory, 'src/main.py' for a file in the src directory, or 'docs/images/diagram.png' for a file in a nested directory."
378
+ "description": (
379
+ "The full relative path including the filename of the file to read. For example, "
380
+ "'README.md' for a file in the root directory, 'src/main.py' for a file in the "
381
+ "src directory, or 'docs/images/diagram.png' for a file in a nested directory."
382
+ )
366
383
  }
367
384
  },
368
385
  "additionalProperties": False,
@@ -399,17 +416,29 @@ class WriteFileTool(LLMTool):
399
416
  "type": "function",
400
417
  "function": {
401
418
  "name": "write_file",
402
- "description": "Write content to a file, completely overwriting any existing content. Use this when you want to replace the entire contents of a file with new content.",
419
+ "description": (
420
+ "Write content to a file, completely overwriting any existing content. Use this when you "
421
+ "want to replace the entire contents of a file with new content."
422
+ ),
403
423
  "parameters": {
404
424
  "type": "object",
405
425
  "properties": {
406
426
  "path": {
407
427
  "type": "string",
408
- "description": "The full relative path including the filename where the file should be written. For example, 'output.txt' for a file in the root directory, 'src/main.py' for a file in the src directory, or 'docs/images/diagram.png' for a file in a nested directory."
428
+ "description": (
429
+ "The full relative path including the filename where the file should be written. "
430
+ "For example, 'output.txt' for a file in the root directory, 'src/main.py' for "
431
+ "a file in the src directory, or 'docs/images/diagram.png' for a file in a "
432
+ "nested directory."
433
+ )
409
434
  },
410
435
  "content": {
411
436
  "type": "string",
412
- "description": "The content to write to the file. This will completely replace any existing content in the file. For example, 'Hello, world!' for a simple text file, or a JSON string for a configuration file."
437
+ "description": (
438
+ "The content to write to the file. This will completely replace any existing "
439
+ "content in the file. For example, 'Hello, world!' for a simple text file, or a "
440
+ "JSON string for a configuration file."
441
+ )
413
442
  }
414
443
  },
415
444
  "additionalProperties": False,
@@ -441,13 +470,22 @@ class ListAllFilesTool(LLMTool):
441
470
  "type": "function",
442
471
  "function": {
443
472
  "name": "list_all_files",
444
- "description": "List all files recursively in the specified directory, including files in subdirectories. Use this when you need a complete inventory of all files in a directory and its subdirectories.",
473
+ "description": (
474
+ "List all files recursively in the specified directory, including files in "
475
+ "subdirectories. Use this when you need a complete inventory of all files in a "
476
+ "directory and its subdirectories."
477
+ ),
445
478
  "parameters": {
446
479
  "type": "object",
447
480
  "properties": {
448
481
  "path": {
449
482
  "type": "string",
450
- "description": "The path relative to the sandbox root to list files from recursively. For example, '.' for the root directory and all subdirectories, 'src' for the src directory and all its subdirectories, or 'docs/images' for a nested directory and its subdirectories."
483
+ "description": (
484
+ "The path relative to the sandbox root to list files from recursively. For "
485
+ "example, '.' for the root directory and all subdirectories, 'src' for the src "
486
+ "directory and all its subdirectories, or 'docs/images' for a nested directory "
487
+ "and its subdirectories."
488
+ )
451
489
  }
452
490
  },
453
491
  "additionalProperties": False,
@@ -479,17 +517,30 @@ class FindFilesByGlobTool(LLMTool):
479
517
  "type": "function",
480
518
  "function": {
481
519
  "name": "find_files_by_glob",
482
- "description": "Find files matching a glob pattern in the specified directory. Use this when you need to locate files with specific patterns in their names or paths (e.g., all Python files with '*.py' or all text files in any subdirectory with '**/*.txt').",
520
+ "description": (
521
+ "Find files matching a glob pattern in the specified directory. Use this when you need to "
522
+ "locate files with specific patterns in their names or paths (e.g., all Python files with "
523
+ "'*.py' or all text files in any subdirectory with '**/*.txt')."
524
+ ),
483
525
  "parameters": {
484
526
  "type": "object",
485
527
  "properties": {
486
528
  "path": {
487
529
  "type": "string",
488
- "description": "The path relative to the sandbox root to search in. For example, '.' for the root directory, 'src' for the src directory, or 'docs/images' for a nested directory."
530
+ "description": (
531
+ "The path relative to the sandbox root to search for files from. For example, "
532
+ "'.' for the root directory, 'src' for the src directory, or 'docs/images' for a "
533
+ "nested directory."
534
+ )
489
535
  },
490
536
  "pattern": {
491
537
  "type": "string",
492
- "description": "The glob pattern to match files against. Examples: '*.py' for all Python files in the specified directory, '**/*.txt' for all text files in the specified directory and any subdirectory, or '**/*test*.py' for all Python files with 'test' in their name in the specified directory and any subdirectory."
538
+ "description": (
539
+ "The glob pattern to match files against. Examples: '*.py' for all Python files in "
540
+ "the specified directory, '**/*.txt' for all text files in the specified directory "
541
+ "and any subdirectory, or '**/*test*.py' for all Python files with 'test' in "
542
+ "their name in the specified directory and any subdirectory."
543
+ )
493
544
  }
494
545
  },
495
546
  "additionalProperties": False,
@@ -523,17 +574,30 @@ class FindFilesContainingTool(LLMTool):
523
574
  "type": "function",
524
575
  "function": {
525
576
  "name": "find_files_containing",
526
- "description": "Find files containing text matching a regex pattern in the specified directory. Use this when you need to search for specific content across multiple files, such as finding all files that contain a particular function name or text string.",
577
+ "description": (
578
+ "Find files containing text matching a regex pattern in the specified directory. Use "
579
+ "this when you need to search for specific content across multiple files, such as "
580
+ "finding all files that contain a particular function name or text string."
581
+ ),
527
582
  "parameters": {
528
583
  "type": "object",
529
584
  "properties": {
530
585
  "path": {
531
586
  "type": "string",
532
- "description": "The path relative to the sandbox root to search in. For example, '.' for the root directory, 'src' for the src directory, or 'docs/images' for a nested directory."
587
+ "description": (
588
+ "The path relative to the sandbox root to search in. For example, '.' for the "
589
+ "root directory, 'src' for the src directory, or 'docs/images' for a nested "
590
+ "directory."
591
+ )
533
592
  },
534
593
  "pattern": {
535
594
  "type": "string",
536
- "description": "The regex pattern to search for in files. Examples: 'function\\s+main' to find files containing a main function, 'import\\s+os' to find files importing the os module, or 'TODO|FIXME' to find files containing TODO or FIXME comments. The pattern uses Python's re module syntax."
595
+ "description": (
596
+ "The regex pattern to search for in files. Examples: 'function\\s+main' to find "
597
+ "files containing a main function, 'import\\s+os' to find files importing the os "
598
+ "module, or 'TODO|FIXME' to find files containing TODO or FIXME comments. The "
599
+ "pattern uses Python's re module syntax."
600
+ )
537
601
  }
538
602
  },
539
603
  "additionalProperties": False,
@@ -573,17 +637,31 @@ class FindLinesMatchingTool(LLMTool):
573
637
  "type": "function",
574
638
  "function": {
575
639
  "name": "find_lines_matching",
576
- "description": "Find all lines in a file matching a regex pattern, returning both line numbers and content. Use this when you need to locate specific patterns within a single file and need to know exactly where they appear.",
640
+ "description": (
641
+ "Find all lines in a file matching a regex pattern, returning both line numbers and "
642
+ "content. Use this when you need to locate specific patterns within a single file and "
643
+ "need to know exactly where they appear."
644
+ ),
577
645
  "parameters": {
578
646
  "type": "object",
579
647
  "properties": {
580
648
  "path": {
581
649
  "type": "string",
582
- "description": "The full relative path including the filename of the file to search in. For example, 'README.md' for a file in the root directory, 'src/main.py' for a file in the src directory, or 'docs/images/diagram.png' for a file in a nested directory."
650
+ "description": (
651
+ "The full relative path including the filename of the file to search. For "
652
+ "example, 'README.md' for a file in the root directory, 'src/main.py' for a file "
653
+ "in the src directory, or 'docs/images/diagram.png' for a file in a nested "
654
+ "directory."
655
+ )
583
656
  },
584
657
  "pattern": {
585
658
  "type": "string",
586
- "description": "The regex pattern to match lines against. Examples: 'def\\s+\\w+' to find all function definitions, 'class\\s+\\w+' to find all class definitions, or 'TODO|FIXME' to find all TODO or FIXME comments. The pattern uses Python's re module syntax."
659
+ "description": (
660
+ "The regex pattern to match lines against. Examples: 'def\\s+\\w+' to find all "
661
+ "function definitions, 'class\\s+\\w+' to find all class definitions, or "
662
+ "'TODO|FIXME' to find all TODO or FIXME comments. The pattern uses Python's re "
663
+ "module syntax."
664
+ )
587
665
  }
588
666
  },
589
667
  "additionalProperties": False,
@@ -621,17 +699,33 @@ class EditFileWithDiffTool(LLMTool):
621
699
  "type": "function",
622
700
  "function": {
623
701
  "name": "edit_file_with_diff",
624
- "description": "Edit a file by applying a diff to it. Use this for making selective changes to parts of a file while preserving the rest of the content, unlike write_file which completely replaces the file. The diff should be in a unified diff format with lines prefixed by '+' (add), '-' (remove), or ' ' (context).",
702
+ "description": (
703
+ "Edit a file by applying a diff to it. Use this for making selective changes to parts "
704
+ "of a file while preserving the rest of the content, unlike write_file which completely "
705
+ "replaces the file. The diff should be in a unified diff format with lines prefixed by "
706
+ "'+' (add), '-' (remove), or ' ' (context)."
707
+ ),
625
708
  "parameters": {
626
709
  "type": "object",
627
710
  "properties": {
628
711
  "path": {
629
712
  "type": "string",
630
- "description": "The full relative path including the filename of the file to edit. For example, 'README.md' for a file in the root directory, 'src/main.py' for a file in the src directory, or 'docs/images/diagram.png' for a file in a nested directory."
713
+ "description": (
714
+ "The full relative path including the filename of the file to edit. For example, "
715
+ "'README.md' for a file in the root directory, 'src/main.py' for a file in the "
716
+ "src directory, or 'docs/images/diagram.png' for a file in a nested directory."
717
+ )
631
718
  },
632
719
  "diff": {
633
720
  "type": "string",
634
- "description": "The diff to apply to the file in unified diff format. Lines to add should be prefixed with '+', lines to remove with '-', and context lines with ' ' (space). Example:\n\n```\n This is a context line (unchanged)\n-This line will be removed\n+This line will be added\n This is another context line\n```\n\nThe diff should include enough context lines to uniquely identify the section of the file to modify."
721
+ "description": (
722
+ "The diff to apply to the file in unified diff format. Lines to add should be "
723
+ "prefixed with '+', lines to remove with '-', and context lines with ' ' (space). "
724
+ "Example:\n\n```\n This is a context line (unchanged)\n-This line will be "
725
+ "removed\n+This line will be added\n This is another context line\n```\n\n"
726
+ "The diff should include enough context lines to uniquely identify the section "
727
+ "of the file to modify."
728
+ )
635
729
  }
636
730
  },
637
731
  "additionalProperties": False,
@@ -669,13 +763,22 @@ class CreateDirectoryTool(LLMTool):
669
763
  "type": "function",
670
764
  "function": {
671
765
  "name": "create_directory",
672
- "description": "Create a new directory at the specified path. If the directory already exists, this operation will succeed without error. Use this when you need to create a directory structure before writing files to it.",
766
+ "description": (
767
+ "Create a new directory at the specified path. If the directory already exists, this "
768
+ "operation will succeed without error. Use this when you need to create a directory "
769
+ "structure before writing files to it."
770
+ ),
673
771
  "parameters": {
674
772
  "type": "object",
675
773
  "properties": {
676
774
  "path": {
677
775
  "type": "string",
678
- "description": "The relative path where the directory should be created. For example, 'new_folder' for a directory in the root, 'src/new_folder' for a directory in the src directory, or 'docs/images/new_folder' for a nested directory. Parent directories will be created automatically if they don't exist."
776
+ "description": (
777
+ "The relative path where the directory should be created. For example, "
778
+ "'new_folder' for a directory in the root, 'src/new_folder' for a directory in "
779
+ "the src directory, or 'docs/images/new_folder' for a nested directory. Parent "
780
+ "directories will be created automatically if they don't exist."
781
+ )
679
782
  }
680
783
  },
681
784
  "additionalProperties": False,
@@ -1,9 +1,6 @@
1
1
  import os
2
- import re
3
- import glob
4
2
  import tempfile
5
3
  import shutil
6
- from unittest.mock import Mock, patch
7
4
 
8
5
  import pytest
9
6
 
@@ -1,5 +1,5 @@
1
1
  import json
2
- from typing import Any, Dict, Optional
2
+ from typing import Optional
3
3
 
4
4
  from mojentic.tracer.tracer_system import TracerSystem
5
5
  from mojentic.llm.gateways.models import TextContent
@@ -1,9 +1,7 @@
1
- import json
2
1
  from unittest.mock import Mock
3
2
 
4
3
  import pytest
5
4
 
6
- from mojentic.llm.gateways.models import TextContent
7
5
  from mojentic.llm.tools.llm_tool import LLMTool
8
6
 
9
7
 
@@ -21,8 +21,10 @@ class OrganicWebSearchTool(LLMTool):
21
21
  "type": "function",
22
22
  "function": {
23
23
  "name": "organic_web_search",
24
- "description":
25
- "Search the Internet for information matching the given query and return the organic search results.",
24
+ "description": (
25
+ "Search the Internet for information matching the given query "
26
+ "and return the organic search results."
27
+ ),
26
28
  "parameters": {
27
29
  "type": "object",
28
30
  "properties": {
@@ -12,7 +12,11 @@ class TellUserTool(LLMTool):
12
12
  "type": "function",
13
13
  "function": {
14
14
  "name": "tell_user",
15
- "description": "Display a message to the user without expecting a response. Use this to send important intermediate information to the user as you work on completing their request.",
15
+ "description": (
16
+ "Display a message to the user without expecting a response. Use this to send "
17
+ "important intermediate information to the user as you work on completing their "
18
+ "request."
19
+ ),
16
20
  "parameters": {
17
21
  "type": "object",
18
22
  "properties": {
@@ -24,4 +28,4 @@ class TellUserTool(LLMTool):
24
28
  "required": ["message"]
25
29
  },
26
30
  },
27
- }
31
+ }
@@ -1,10 +1,10 @@
1
1
  """
2
2
  Not sure about this module right now. There are a couple ways to do this.
3
3
  """
4
- from typing import Any, TYPE_CHECKING
4
+ from typing import TYPE_CHECKING
5
5
 
6
6
  from mojentic.llm.tools.llm_tool import LLMTool
7
- from mojentic.llm.gateways.models import LLMMessage, MessageRole
7
+ from mojentic.llm.gateways.models import LLMMessage
8
8
 
9
9
  # Use TYPE_CHECKING to avoid circular imports
10
10
  if TYPE_CHECKING:
@@ -4,18 +4,9 @@ Mojentic tracer module for tracking system operations.
4
4
  """
5
5
 
6
6
  # Core tracer components
7
- from .tracer_system import TracerSystem
8
7
  from .null_tracer import NullTracer
9
- from .event_store import EventStore
10
8
 
11
9
  # Tracer event types
12
- from .tracer_events import (
13
- TracerEvent,
14
- LLMCallTracerEvent,
15
- LLMResponseTracerEvent,
16
- ToolCallTracerEvent,
17
- AgentInteractionTracerEvent
18
- )
19
10
 
20
11
  # Create a singleton NullTracer instance for use throughout the application
21
- null_tracer = NullTracer()
12
+ null_tracer = NullTracer()
@@ -1,6 +1,4 @@
1
- from typing import Any, Callable, Dict, List, Optional, Type, Union
2
- import time
3
- from datetime import datetime
1
+ from typing import Callable, List, Optional, Type
4
2
 
5
3
  from mojentic.event import Event
6
4
  from mojentic.tracer.tracer_events import TracerEvent
@@ -38,11 +36,12 @@ class EventStore:
38
36
  if self.on_store_callback is not None:
39
37
  self.on_store_callback(event)
40
38
 
41
- def get_events(self,
42
- event_type: Optional[Type[Event]] = None,
43
- start_time: Optional[float] = None,
44
- end_time: Optional[float] = None,
45
- filter_func: Optional[Callable[[Event], bool]] = None) -> List[Event]:
39
+ def get_events(
40
+ self,
41
+ event_type: Optional[Type[Event]] = None,
42
+ start_time: Optional[float] = None,
43
+ end_time: Optional[float] = None,
44
+ filter_func: Optional[Callable[[Event], bool]] = None) -> List[Event]:
46
45
  """
47
46
  Get events from the store, optionally filtered by type, time range, and custom filter function.
48
47
 
@@ -1,8 +1,7 @@
1
1
  import time
2
- from typing import List
3
2
 
4
3
  from mojentic import Event
5
- from mojentic.tracer.tracer_events import TracerEvent, LLMCallTracerEvent, AgentInteractionTracerEvent
4
+ from mojentic.tracer.tracer_events import TracerEvent
6
5
  from mojentic.tracer.event_store import EventStore
7
6
 
8
7
 
@@ -32,15 +32,14 @@ class NullTracer:
32
32
  The tracer event to record (will be ignored).
33
33
  """
34
34
  # Do nothing
35
- pass
36
-
37
- def record_llm_call(self,
38
- model: str,
39
- messages: List[Dict],
40
- temperature: float = 1.0,
41
- tools: Optional[List[Dict]] = None,
42
- source: Any = None,
43
- correlation_id: str = None) -> None:
35
+
36
+ def record_llm_call(self,
37
+ model: str,
38
+ messages: List[Dict],
39
+ temperature: float = 1.0,
40
+ tools: Optional[List[Dict]] = None,
41
+ source: Any = None,
42
+ correlation_id: str = None) -> None:
44
43
  """
45
44
  Do nothing implementation of record_llm_call.
46
45
 
@@ -60,15 +59,14 @@ class NullTracer:
60
59
  UUID string that is copied from cause-to-affect for tracing events.
61
60
  """
62
61
  # Do nothing
63
- pass
64
62
 
65
- def record_llm_response(self,
66
- model: str,
67
- content: str,
68
- tool_calls: Optional[List[Dict]] = None,
69
- call_duration_ms: Optional[float] = None,
70
- source: Any = None,
71
- correlation_id: str = None) -> None:
63
+ def record_llm_response(self,
64
+ model: str,
65
+ content: str,
66
+ tool_calls: Optional[List[Dict]] = None,
67
+ call_duration_ms: Optional[float] = None,
68
+ source: Any = None,
69
+ correlation_id: str = None) -> None:
72
70
  """
73
71
  Do nothing implementation of record_llm_response.
74
72
 
@@ -88,16 +86,15 @@ class NullTracer:
88
86
  UUID string that is copied from cause-to-affect for tracing events.
89
87
  """
90
88
  # Do nothing
91
- pass
92
89
 
93
90
  def record_tool_call(self,
94
- tool_name: str,
95
- arguments: Dict[str, Any],
96
- result: Any,
97
- caller: Optional[str] = None,
98
- call_duration_ms: Optional[float] = None,
99
- source: Any = None,
100
- correlation_id: str = None) -> None:
91
+ tool_name: str,
92
+ arguments: Dict[str, Any],
93
+ result: Any,
94
+ caller: Optional[str] = None,
95
+ call_duration_ms: Optional[float] = None,
96
+ source: Any = None,
97
+ correlation_id: str = None) -> None:
101
98
  """
102
99
  Do nothing implementation of record_tool_call.
103
100
 
@@ -119,15 +116,15 @@ class NullTracer:
119
116
  UUID string that is copied from cause-to-affect for tracing events.
120
117
  """
121
118
  # Do nothing
122
- pass
123
-
124
- def record_agent_interaction(self,
125
- from_agent: str,
126
- to_agent: str,
127
- event_type: str,
128
- event_id: Optional[str] = None,
129
- source: Any = None,
130
- correlation_id: str = None) -> None:
119
+
120
+ def record_agent_interaction(
121
+ self,
122
+ from_agent: str,
123
+ to_agent: str,
124
+ event_type: str,
125
+ event_id: Optional[str] = None,
126
+ source: Any = None,
127
+ correlation_id: str = None) -> None:
131
128
  """
132
129
  Do nothing implementation of record_agent_interaction.
133
130
 
@@ -147,13 +144,13 @@ class NullTracer:
147
144
  UUID string that is copied from cause-to-affect for tracing events.
148
145
  """
149
146
  # Do nothing
150
- pass
151
147
 
152
- def get_events(self,
153
- event_type: Optional[Type[TracerEvent]] = None,
154
- start_time: Optional[float] = None,
155
- end_time: Optional[float] = None,
156
- filter_func: Optional[Callable[[TracerEvent], bool]] = None) -> List[TracerEvent]:
148
+ def get_events(
149
+ self,
150
+ event_type: Optional[Type[TracerEvent]] = None,
151
+ start_time: Optional[float] = None,
152
+ end_time: Optional[float] = None,
153
+ filter_func: Optional[Callable[[TracerEvent], bool]] = None) -> List[TracerEvent]:
157
154
  """
158
155
  Return an empty list for any get_events request.
159
156
 
@@ -195,12 +192,9 @@ class NullTracer:
195
192
 
196
193
  def clear(self) -> None:
197
194
  """Do nothing implementation of clear method."""
198
- pass
199
195
 
200
196
  def enable(self) -> None:
201
197
  """No-op method for interface compatibility."""
202
- pass
203
198
 
204
199
  def disable(self) -> None:
205
200
  """No-op method for interface compatibility."""
206
- pass
@@ -1,7 +1,7 @@
1
1
  """
2
2
  Defines tracer event types for tracking system interactions.
3
3
  """
4
- from typing import Any, Dict, List, Optional, Type
4
+ from typing import Any, Dict, List, Optional
5
5
  from datetime import datetime
6
6
  import uuid
7
7
 
@@ -18,7 +18,13 @@ class TracerEvent(Event):
18
18
  They are distinct from regular events which are used for agent communication.
19
19
  """
20
20
  timestamp: float = Field(..., description="Timestamp when the event occurred")
21
- correlation_id: str = Field(default_factory=lambda: str(uuid.uuid4()), description="UUID string that is copied from cause-to-affect for tracing events")
21
+ correlation_id: str = Field(
22
+ default_factory=lambda: str(uuid.uuid4()),
23
+ description=(
24
+ "UUID string that is copied from cause-to-affect "
25
+ "for tracing events"
26
+ )
27
+ )
22
28
 
23
29
  def printable_summary(self) -> str:
24
30
  """