autobyteus 1.1.4__py3-none-any.whl → 1.1.5__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 (167) hide show
  1. autobyteus/agent/context/__init__.py +4 -2
  2. autobyteus/agent/context/agent_config.py +0 -4
  3. autobyteus/agent/context/agent_context_registry.py +73 -0
  4. autobyteus/agent/events/notifiers.py +4 -0
  5. autobyteus/agent/handlers/inter_agent_message_event_handler.py +7 -2
  6. autobyteus/agent/handlers/llm_complete_response_received_event_handler.py +19 -19
  7. autobyteus/agent/handlers/user_input_message_event_handler.py +15 -0
  8. autobyteus/agent/message/send_message_to.py +29 -23
  9. autobyteus/agent/runtime/agent_runtime.py +10 -2
  10. autobyteus/agent/sender_type.py +15 -0
  11. autobyteus/agent/streaming/agent_event_stream.py +6 -0
  12. autobyteus/agent/streaming/stream_event_payloads.py +12 -0
  13. autobyteus/agent/streaming/stream_events.py +3 -0
  14. autobyteus/agent/system_prompt_processor/tool_manifest_injector_processor.py +7 -4
  15. autobyteus/agent_team/__init__.py +1 -0
  16. autobyteus/agent_team/agent_team.py +93 -0
  17. autobyteus/agent_team/agent_team_builder.py +184 -0
  18. autobyteus/agent_team/base_agent_team.py +86 -0
  19. autobyteus/agent_team/bootstrap_steps/__init__.py +24 -0
  20. autobyteus/agent_team/bootstrap_steps/agent_configuration_preparation_step.py +73 -0
  21. autobyteus/agent_team/bootstrap_steps/agent_team_bootstrapper.py +54 -0
  22. autobyteus/agent_team/bootstrap_steps/agent_team_runtime_queue_initialization_step.py +25 -0
  23. autobyteus/agent_team/bootstrap_steps/base_agent_team_bootstrap_step.py +23 -0
  24. autobyteus/agent_team/bootstrap_steps/coordinator_initialization_step.py +41 -0
  25. autobyteus/agent_team/bootstrap_steps/coordinator_prompt_preparation_step.py +85 -0
  26. autobyteus/agent_team/bootstrap_steps/task_notifier_initialization_step.py +51 -0
  27. autobyteus/agent_team/bootstrap_steps/team_context_initialization_step.py +45 -0
  28. autobyteus/agent_team/context/__init__.py +17 -0
  29. autobyteus/agent_team/context/agent_team_config.py +33 -0
  30. autobyteus/agent_team/context/agent_team_context.py +61 -0
  31. autobyteus/agent_team/context/agent_team_runtime_state.py +56 -0
  32. autobyteus/agent_team/context/team_manager.py +147 -0
  33. autobyteus/agent_team/context/team_node_config.py +76 -0
  34. autobyteus/agent_team/events/__init__.py +29 -0
  35. autobyteus/agent_team/events/agent_team_event_dispatcher.py +39 -0
  36. autobyteus/agent_team/events/agent_team_events.py +53 -0
  37. autobyteus/agent_team/events/agent_team_input_event_queue_manager.py +21 -0
  38. autobyteus/agent_team/exceptions.py +8 -0
  39. autobyteus/agent_team/factory/__init__.py +9 -0
  40. autobyteus/agent_team/factory/agent_team_factory.py +99 -0
  41. autobyteus/agent_team/handlers/__init__.py +19 -0
  42. autobyteus/agent_team/handlers/agent_team_event_handler_registry.py +23 -0
  43. autobyteus/agent_team/handlers/base_agent_team_event_handler.py +16 -0
  44. autobyteus/agent_team/handlers/inter_agent_message_request_event_handler.py +61 -0
  45. autobyteus/agent_team/handlers/lifecycle_agent_team_event_handler.py +27 -0
  46. autobyteus/agent_team/handlers/process_user_message_event_handler.py +46 -0
  47. autobyteus/agent_team/handlers/tool_approval_team_event_handler.py +48 -0
  48. autobyteus/agent_team/phases/__init__.py +11 -0
  49. autobyteus/agent_team/phases/agent_team_operational_phase.py +19 -0
  50. autobyteus/agent_team/phases/agent_team_phase_manager.py +48 -0
  51. autobyteus/agent_team/runtime/__init__.py +13 -0
  52. autobyteus/agent_team/runtime/agent_team_runtime.py +82 -0
  53. autobyteus/agent_team/runtime/agent_team_worker.py +117 -0
  54. autobyteus/agent_team/shutdown_steps/__init__.py +17 -0
  55. autobyteus/agent_team/shutdown_steps/agent_team_shutdown_orchestrator.py +35 -0
  56. autobyteus/agent_team/shutdown_steps/agent_team_shutdown_step.py +42 -0
  57. autobyteus/agent_team/shutdown_steps/base_agent_team_shutdown_step.py +16 -0
  58. autobyteus/agent_team/shutdown_steps/bridge_cleanup_step.py +28 -0
  59. autobyteus/agent_team/shutdown_steps/sub_team_shutdown_step.py +41 -0
  60. autobyteus/agent_team/streaming/__init__.py +26 -0
  61. autobyteus/agent_team/streaming/agent_event_bridge.py +48 -0
  62. autobyteus/agent_team/streaming/agent_event_multiplexer.py +70 -0
  63. autobyteus/agent_team/streaming/agent_team_event_notifier.py +64 -0
  64. autobyteus/agent_team/streaming/agent_team_event_stream.py +33 -0
  65. autobyteus/agent_team/streaming/agent_team_stream_event_payloads.py +32 -0
  66. autobyteus/agent_team/streaming/agent_team_stream_events.py +56 -0
  67. autobyteus/agent_team/streaming/team_event_bridge.py +50 -0
  68. autobyteus/agent_team/task_notification/__init__.py +11 -0
  69. autobyteus/agent_team/task_notification/system_event_driven_agent_task_notifier.py +164 -0
  70. autobyteus/agent_team/task_notification/task_notification_mode.py +24 -0
  71. autobyteus/agent_team/utils/__init__.py +9 -0
  72. autobyteus/agent_team/utils/wait_for_idle.py +46 -0
  73. autobyteus/cli/agent_team_tui/__init__.py +4 -0
  74. autobyteus/cli/agent_team_tui/app.py +210 -0
  75. autobyteus/cli/agent_team_tui/state.py +180 -0
  76. autobyteus/cli/agent_team_tui/widgets/__init__.py +6 -0
  77. autobyteus/cli/agent_team_tui/widgets/agent_list_sidebar.py +149 -0
  78. autobyteus/cli/agent_team_tui/widgets/focus_pane.py +320 -0
  79. autobyteus/cli/agent_team_tui/widgets/logo.py +20 -0
  80. autobyteus/cli/agent_team_tui/widgets/renderables.py +77 -0
  81. autobyteus/cli/agent_team_tui/widgets/shared.py +60 -0
  82. autobyteus/cli/agent_team_tui/widgets/status_bar.py +14 -0
  83. autobyteus/cli/agent_team_tui/widgets/task_board_panel.py +82 -0
  84. autobyteus/events/event_types.py +7 -2
  85. autobyteus/llm/api/autobyteus_llm.py +11 -12
  86. autobyteus/llm/api/lmstudio_llm.py +10 -13
  87. autobyteus/llm/api/ollama_llm.py +8 -13
  88. autobyteus/llm/autobyteus_provider.py +73 -46
  89. autobyteus/llm/llm_factory.py +102 -140
  90. autobyteus/llm/lmstudio_provider.py +63 -48
  91. autobyteus/llm/models.py +83 -53
  92. autobyteus/llm/ollama_provider.py +69 -61
  93. autobyteus/llm/ollama_provider_resolver.py +1 -0
  94. autobyteus/llm/providers.py +13 -13
  95. autobyteus/llm/runtimes.py +11 -0
  96. autobyteus/task_management/__init__.py +43 -0
  97. autobyteus/task_management/base_task_board.py +68 -0
  98. autobyteus/task_management/converters/__init__.py +11 -0
  99. autobyteus/task_management/converters/task_board_converter.py +64 -0
  100. autobyteus/task_management/converters/task_plan_converter.py +48 -0
  101. autobyteus/task_management/deliverable.py +16 -0
  102. autobyteus/task_management/deliverables/__init__.py +8 -0
  103. autobyteus/task_management/deliverables/file_deliverable.py +15 -0
  104. autobyteus/task_management/events.py +27 -0
  105. autobyteus/task_management/in_memory_task_board.py +126 -0
  106. autobyteus/task_management/schemas/__init__.py +15 -0
  107. autobyteus/task_management/schemas/deliverable_schema.py +13 -0
  108. autobyteus/task_management/schemas/plan_definition.py +35 -0
  109. autobyteus/task_management/schemas/task_status_report.py +27 -0
  110. autobyteus/task_management/task_plan.py +110 -0
  111. autobyteus/task_management/tools/__init__.py +14 -0
  112. autobyteus/task_management/tools/get_task_board_status.py +68 -0
  113. autobyteus/task_management/tools/publish_task_plan.py +113 -0
  114. autobyteus/task_management/tools/update_task_status.py +135 -0
  115. autobyteus/tools/bash/bash_executor.py +59 -14
  116. autobyteus/tools/mcp/config_service.py +63 -58
  117. autobyteus/tools/mcp/server/http_managed_mcp_server.py +14 -2
  118. autobyteus/tools/mcp/server/stdio_managed_mcp_server.py +14 -2
  119. autobyteus/tools/mcp/server_instance_manager.py +30 -4
  120. autobyteus/tools/mcp/tool_registrar.py +103 -50
  121. autobyteus/tools/parameter_schema.py +17 -11
  122. autobyteus/tools/registry/tool_definition.py +24 -29
  123. autobyteus/tools/tool_category.py +1 -0
  124. autobyteus/tools/usage/formatters/default_json_example_formatter.py +78 -3
  125. autobyteus/tools/usage/formatters/default_xml_example_formatter.py +23 -3
  126. autobyteus/tools/usage/formatters/gemini_json_example_formatter.py +6 -0
  127. autobyteus/tools/usage/formatters/google_json_example_formatter.py +7 -0
  128. autobyteus/tools/usage/formatters/openai_json_example_formatter.py +6 -4
  129. autobyteus/tools/usage/parsers/gemini_json_tool_usage_parser.py +23 -7
  130. autobyteus/tools/usage/parsers/provider_aware_tool_usage_parser.py +14 -25
  131. autobyteus/tools/usage/providers/__init__.py +2 -12
  132. autobyteus/tools/usage/providers/tool_manifest_provider.py +36 -29
  133. autobyteus/tools/usage/registries/__init__.py +7 -12
  134. autobyteus/tools/usage/registries/tool_formatter_pair.py +15 -0
  135. autobyteus/tools/usage/registries/tool_formatting_registry.py +58 -0
  136. autobyteus/tools/usage/registries/tool_usage_parser_registry.py +55 -0
  137. {autobyteus-1.1.4.dist-info → autobyteus-1.1.5.dist-info}/METADATA +3 -3
  138. {autobyteus-1.1.4.dist-info → autobyteus-1.1.5.dist-info}/RECORD +146 -72
  139. examples/agent_team/__init__.py +1 -0
  140. examples/run_browser_agent.py +17 -15
  141. examples/run_google_slides_agent.py +17 -16
  142. examples/run_poem_writer.py +22 -12
  143. examples/run_sqlite_agent.py +17 -15
  144. autobyteus/tools/mcp/call_handlers/__init__.py +0 -16
  145. autobyteus/tools/mcp/call_handlers/base_handler.py +0 -40
  146. autobyteus/tools/mcp/call_handlers/stdio_handler.py +0 -76
  147. autobyteus/tools/mcp/call_handlers/streamable_http_handler.py +0 -55
  148. autobyteus/tools/usage/providers/json_example_provider.py +0 -32
  149. autobyteus/tools/usage/providers/json_schema_provider.py +0 -35
  150. autobyteus/tools/usage/providers/json_tool_usage_parser_provider.py +0 -28
  151. autobyteus/tools/usage/providers/xml_example_provider.py +0 -28
  152. autobyteus/tools/usage/providers/xml_schema_provider.py +0 -29
  153. autobyteus/tools/usage/providers/xml_tool_usage_parser_provider.py +0 -26
  154. autobyteus/tools/usage/registries/json_example_formatter_registry.py +0 -51
  155. autobyteus/tools/usage/registries/json_schema_formatter_registry.py +0 -51
  156. autobyteus/tools/usage/registries/json_tool_usage_parser_registry.py +0 -42
  157. autobyteus/tools/usage/registries/xml_example_formatter_registry.py +0 -30
  158. autobyteus/tools/usage/registries/xml_schema_formatter_registry.py +0 -33
  159. autobyteus/tools/usage/registries/xml_tool_usage_parser_registry.py +0 -30
  160. examples/workflow/__init__.py +0 -1
  161. examples/workflow/run_basic_research_workflow.py +0 -189
  162. examples/workflow/run_code_review_workflow.py +0 -269
  163. examples/workflow/run_debate_workflow.py +0 -212
  164. examples/workflow/run_workflow_with_tui.py +0 -153
  165. {autobyteus-1.1.4.dist-info → autobyteus-1.1.5.dist-info}/WHEEL +0 -0
  166. {autobyteus-1.1.4.dist-info → autobyteus-1.1.5.dist-info}/licenses/LICENSE +0 -0
  167. {autobyteus-1.1.4.dist-info → autobyteus-1.1.5.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,7 @@
1
1
  # file: autobyteus/autobyteus/tools/usage/parsers/gemini_json_tool_usage_parser.py
2
2
  import json
3
3
  import logging
4
- from typing import TYPE_CHECKING, List
4
+ from typing import TYPE_CHECKING, List, Dict
5
5
 
6
6
  from autobyteus.agent.tool_invocation import ToolInvocation
7
7
  from .base_parser import BaseToolUsageParser
@@ -17,7 +17,8 @@ class GeminiJsonToolUsageParser(BaseToolUsageParser):
17
17
  """
18
18
  Parses LLM responses for tool usage commands formatted in the Google Gemini style.
19
19
  It expects a JSON object with "name" and "args" keys. It robustly extracts
20
- all potential JSON objects from the response.
20
+ all potential JSON objects from the response and can handle both a single
21
+ tool call object or a list of tool call objects.
21
22
  """
22
23
  def get_name(self) -> str:
23
24
  return "gemini_json_tool_usage_parser"
@@ -32,11 +33,26 @@ class GeminiJsonToolUsageParser(BaseToolUsageParser):
32
33
  for blob in json_blobs:
33
34
  try:
34
35
  data = json.loads(blob)
36
+
37
+ tool_call_list: List[Dict] = []
38
+ if isinstance(data, list):
39
+ # The blob is a list of tool calls, e.g., [{"name": ..., "args": ...}]
40
+ tool_call_list = data
41
+ elif isinstance(data, dict) and "name" in data and "args" in data:
42
+ # The blob is a single tool call object, e.g., {"name": ..., "args": ...}
43
+ tool_call_list = [data]
44
+ else:
45
+ # Not a recognized format, skip this blob.
46
+ logger.debug(f"JSON blob is not in a recognized Gemini tool call format: {blob[:200]}")
47
+ continue
35
48
 
36
- # This parser specifically looks for the {"name": ..., "args": ...} structure.
37
- if isinstance(data, dict) and "name" in data and "args" in data:
38
- tool_name = data.get("name")
39
- arguments = data.get("args")
49
+ for call_data in tool_call_list:
50
+ if not (isinstance(call_data, dict) and "name" in call_data and "args" in call_data):
51
+ logger.debug(f"Skipping malformed item in Gemini tool call list: {call_data}")
52
+ continue
53
+
54
+ tool_name = call_data.get("name")
55
+ arguments = call_data.get("args")
40
56
 
41
57
  if tool_name and isinstance(tool_name, str) and isinstance(arguments, dict):
42
58
  # Pass id=None to trigger deterministic ID generation in ToolInvocation
@@ -44,7 +60,7 @@ class GeminiJsonToolUsageParser(BaseToolUsageParser):
44
60
  invocations.append(tool_invocation)
45
61
  logger.info(f"Successfully parsed Gemini JSON tool invocation for '{tool_name}'.")
46
62
  else:
47
- logger.debug(f"Skipping malformed Gemini tool call data: {data}")
63
+ logger.debug(f"Skipping malformed Gemini tool call data: {call_data}")
48
64
 
49
65
  except json.JSONDecodeError:
50
66
  logger.debug(f"Could not parse extracted text as JSON in {self.get_name()}. Blob: {blob[:200]}")
@@ -1,34 +1,34 @@
1
1
  # file: autobyteus/autobyteus/tools/usage/parsers/provider_aware_tool_usage_parser.py
2
2
  import logging
3
- from typing import TYPE_CHECKING, Optional, List
3
+ from typing import TYPE_CHECKING, List
4
4
 
5
5
  from .exceptions import ToolUsageParseException
6
6
 
7
+ # The import of ToolUsageParserRegistry is deferred to break the circular dependency.
8
+ # It is imported at the top level only for static type analysis.
7
9
  if TYPE_CHECKING:
8
10
  from autobyteus.agent.context import AgentContext
9
11
  from autobyteus.llm.utils.response_types import CompleteResponse
10
12
  from autobyteus.agent.tool_invocation import ToolInvocation
11
- from autobyteus.tools.usage.providers import XmlToolUsageParserProvider, JsonToolUsageParserProvider
13
+ from autobyteus.tools.usage.registries.tool_usage_parser_registry import ToolUsageParserRegistry
12
14
 
13
15
  logger = logging.getLogger(__name__)
14
16
 
15
17
  class ProviderAwareToolUsageParser:
16
18
  """
17
19
  A high-level orchestrator that selects and uses the correct tool usage parser
18
- (e.g., for XML, OpenAI JSON, Gemini JSON) based on the agent's configuration.
19
-
20
- This class encapsulates the logic for choosing a parser, making it easy for
21
- other components to simply request a parse without knowing the underlying details.
20
+ based on the agent's LLM provider by consulting the central ToolUsageParserRegistry.
22
21
  """
23
22
  def __init__(self):
24
- self._xml_parser_provider: Optional['XmlToolUsageParserProvider'] = None
25
- self._json_parser_provider: Optional['JsonToolUsageParserProvider'] = None
23
+ # Local import to break the circular dependency at module load time.
24
+ from autobyteus.tools.usage.registries.tool_usage_parser_registry import ToolUsageParserRegistry
25
+ self._parser_registry: 'ToolUsageParserRegistry' = ToolUsageParserRegistry()
26
26
  logger.debug("ProviderAwareToolUsageParser initialized.")
27
27
 
28
28
  def parse(self, response: 'CompleteResponse', context: 'AgentContext') -> List['ToolInvocation']:
29
29
  """
30
- Selects the correct underlying parser, parses the response, and returns
31
- a list of tool invocations.
30
+ Selects the correct underlying parser from the registry, parses the response,
31
+ and returns a list of tool invocations.
32
32
 
33
33
  Args:
34
34
  response: The CompleteResponse object from the LLM.
@@ -38,27 +38,16 @@ class ProviderAwareToolUsageParser:
38
38
  A list of ToolInvocation objects. Returns an empty list if no
39
39
  valid tool calls are found.
40
40
  """
41
- from autobyteus.tools.usage.providers import XmlToolUsageParserProvider, JsonToolUsageParserProvider
42
-
43
41
  llm_provider = None
44
42
  if context.llm_instance and context.llm_instance.model:
45
43
  llm_provider = context.llm_instance.model.provider
46
44
  else:
47
45
  logger.warning(f"Agent '{context.agent_id}': LLM instance or model not available. Cannot determine provider for tool response parsing.")
48
46
 
49
- if context.config.use_xml_tool_format:
50
- if self._xml_parser_provider is None:
51
- self._xml_parser_provider = XmlToolUsageParserProvider()
52
- parser_provider = self._xml_parser_provider
53
- format_name = "XML"
54
- else:
55
- if self._json_parser_provider is None:
56
- self._json_parser_provider = JsonToolUsageParserProvider()
57
- parser_provider = self._json_parser_provider
58
- format_name = "JSON"
59
-
60
- parser = parser_provider.provide(llm_provider)
61
- logger.debug(f"ProviderAwareToolUsageParser selected delegate parser '{parser.get_name()}' for format '{format_name}' and LLM provider '{llm_provider.name if llm_provider else 'Unknown'}'.")
47
+ # Get the correct parser directly from the new central registry.
48
+ parser = self._parser_registry.get_parser(llm_provider)
49
+
50
+ logger.debug(f"ProviderAwareToolUsageParser selected delegate parser '{parser.get_name()}' for LLM provider '{llm_provider.name if llm_provider else 'Unknown'}'.")
62
51
 
63
52
  try:
64
53
  return parser.parse(response)
@@ -3,20 +3,10 @@
3
3
  This package contains providers that orchestrate the generation of
4
4
  tool usage information and the parsing of tool usage responses.
5
5
  """
6
- from .xml_schema_provider import XmlSchemaProvider
7
- from .json_schema_provider import JsonSchemaProvider
8
- from .xml_example_provider import XmlExampleProvider
9
- from .json_example_provider import JsonExampleProvider
10
- from .xml_tool_usage_parser_provider import XmlToolUsageParserProvider
11
- from .json_tool_usage_parser_provider import JsonToolUsageParserProvider
6
+ # The individual parser providers have been removed in favor of a consolidated registry.
7
+ # We only need to export the main manifest provider.
12
8
  from .tool_manifest_provider import ToolManifestProvider
13
9
 
14
10
  __all__ = [
15
- "XmlSchemaProvider",
16
- "JsonSchemaProvider",
17
- "XmlExampleProvider",
18
- "JsonExampleProvider",
19
- "XmlToolUsageParserProvider",
20
- "JsonToolUsageParserProvider",
21
11
  "ToolManifestProvider",
22
12
  ]
@@ -3,6 +3,10 @@ import logging
3
3
  import json
4
4
  from typing import TYPE_CHECKING, List, Optional
5
5
 
6
+ from autobyteus.llm.providers import LLMProvider
7
+ from autobyteus.tools.usage.registries.tool_formatting_registry import ToolFormattingRegistry
8
+ from autobyteus.tools.usage.formatters import DefaultXmlSchemaFormatter
9
+
6
10
  if TYPE_CHECKING:
7
11
  from autobyteus.tools.registry import ToolDefinition
8
12
 
@@ -12,57 +16,60 @@ class ToolManifestProvider:
12
16
  """
13
17
  Generates a complete tool manifest string, which includes the schema
14
18
  and an example for each provided tool. This is suitable for injection
15
- into a system prompt.
19
+ into a system prompt. It uses the central ToolFormattingRegistry to get
20
+ the correct formatters for the specified provider.
16
21
  """
17
22
  SCHEMA_HEADER = "## Tool Definition:"
18
23
  EXAMPLE_HEADER = "## Example Usage:"
19
- JSON_EXAMPLE_HEADER = "To use this tool, you MUST output a JSON object in the following format:"
24
+ # UPDATED: Changed the header to be more descriptive as requested.
25
+ JSON_EXAMPLE_HEADER = "Example: To use this tool, you could provide the following JSON object as a tool call:"
26
+
27
+ def __init__(self):
28
+ self._formatting_registry = ToolFormattingRegistry()
29
+ logger.debug("ToolManifestProvider initialized.")
20
30
 
21
31
  def provide(self,
22
32
  tool_definitions: List['ToolDefinition'],
23
- use_xml: bool,
24
- provider: Optional[str] = None) -> str:
33
+ provider: Optional[LLMProvider] = None) -> str:
25
34
  """
26
35
  Generates the manifest string for a list of tools.
27
36
 
28
37
  Args:
29
38
  tool_definitions: A list of ToolDefinition objects.
30
- use_xml: If True, generate in XML format. Otherwise, use JSON.
31
- provider: The LLM provider name, for provider-specific formatting.
39
+ provider: The LLM provider, for provider-specific formatting.
32
40
 
33
41
  Returns:
34
42
  A single string containing the formatted manifest.
35
43
  """
36
44
  tool_blocks = []
37
45
 
46
+ # Get the correct formatting pair from the registry using only the provider.
47
+ formatter_pair = self._formatting_registry.get_formatter_pair(provider)
48
+ schema_formatter = formatter_pair.schema_formatter
49
+ example_formatter = formatter_pair.example_formatter
50
+
51
+ # Determine if the chosen formatter is XML-based. This determines the final assembly format.
52
+ is_xml_format = isinstance(schema_formatter, DefaultXmlSchemaFormatter)
53
+
38
54
  for td in tool_definitions:
39
55
  try:
40
- if use_xml:
41
- schema = td.get_usage_xml(provider=provider)
42
- example = td.get_usage_xml_example(provider=provider)
43
- if schema and example:
56
+ schema = schema_formatter.provide(td)
57
+ example = example_formatter.provide(td)
58
+
59
+ if schema and example:
60
+ if is_xml_format:
44
61
  tool_blocks.append(f"{self.SCHEMA_HEADER}\n{schema}\n\n{self.EXAMPLE_HEADER}\n{example}")
45
- else:
46
- logger.warning(f"Could not generate schema or example for XML tool '{td.name}'.")
47
- else: # JSON format
48
- schema = td.get_usage_json(provider=provider)
49
- example = td.get_usage_json_example(provider=provider)
50
- if schema and example:
51
- # Per user feedback, wrap schema in a 'tool' key.
52
- schema_wrapped = {"tool": schema}
53
- schema_str = json.dumps(schema_wrapped, indent=2)
54
-
55
- # Example is already formatted correctly by the example formatter.
62
+ else: # JSON format
63
+ # UPDATED: Removed the redundant {"tool": schema} wrapper.
64
+ schema_str = json.dumps(schema, indent=2)
56
65
  example_str = json.dumps(example, indent=2)
57
-
58
66
  tool_blocks.append(f"{self.SCHEMA_HEADER}\n{schema_str}\n\n{self.JSON_EXAMPLE_HEADER}\n{example_str}")
59
- else:
60
- logger.warning(f"Could not generate schema or example for JSON tool '{td.name}'.")
67
+ else:
68
+ logger.warning(f"Could not generate schema or example for tool '{td.name}' using format {'XML' if is_xml_format else 'JSON'}.")
61
69
 
62
70
  except Exception as e:
63
71
  logger.error(f"Failed to generate manifest block for tool '{td.name}': {e}", exc_info=True)
64
-
65
- if use_xml:
66
- return "\n\n---\n\n".join(tool_blocks)
67
- else:
68
- return "[\n" + ",\n".join(tool_blocks) + "\n]"
72
+
73
+ # UPDATED: Unify the return for all formats to provide a consistent structure
74
+ # without the incorrect '[]' wrapper for JSON.
75
+ return "\n\n---\n\n".join(tool_blocks)
@@ -3,18 +3,13 @@
3
3
  This package contains registries for schema/example formatters and parsers,
4
4
  allowing for easy retrieval of the correct component based on the LLM provider.
5
5
  """
6
- from .json_schema_formatter_registry import JsonSchemaFormatterRegistry
7
- from .xml_schema_formatter_registry import XmlSchemaFormatterRegistry
8
- from .json_example_formatter_registry import JsonExampleFormatterRegistry
9
- from .xml_example_formatter_registry import XmlExampleFormatterRegistry
10
- from .xml_tool_usage_parser_registry import XmlToolUsageParserRegistry
11
- from .json_tool_usage_parser_registry import JsonToolUsageParserRegistry
6
+ # Import the new consolidated components
7
+ from .tool_formatter_pair import ToolFormatterPair
8
+ from .tool_formatting_registry import ToolFormattingRegistry
9
+ from .tool_usage_parser_registry import ToolUsageParserRegistry
12
10
 
13
11
  __all__ = [
14
- "JsonSchemaFormatterRegistry",
15
- "XmlSchemaFormatterRegistry",
16
- "JsonExampleFormatterRegistry",
17
- "XmlExampleFormatterRegistry",
18
- "XmlToolUsageParserRegistry",
19
- "JsonToolUsageParserRegistry",
12
+ "ToolFormatterPair",
13
+ "ToolFormattingRegistry",
14
+ "ToolUsageParserRegistry",
20
15
  ]
@@ -0,0 +1,15 @@
1
+ # file: autobyteus/autobyteus/tools/usage/registries/tool_formatter_pair.py
2
+ from dataclasses import dataclass
3
+ from typing import TYPE_CHECKING
4
+
5
+ if TYPE_CHECKING:
6
+ from autobyteus.tools.usage.formatters import BaseSchemaFormatter, BaseExampleFormatter
7
+
8
+ @dataclass(frozen=True)
9
+ class ToolFormatterPair:
10
+ """
11
+ A container that pairs a tool's schema formatter with its corresponding example formatter.
12
+ This provides a complete set of formatters for a given provider's tool usage style.
13
+ """
14
+ schema_formatter: 'BaseSchemaFormatter'
15
+ example_formatter: 'BaseExampleFormatter'
@@ -0,0 +1,58 @@
1
+ # file: autobyteus/autobyteus/tools/usage/registries/tool_formatting_registry.py
2
+ import logging
3
+ from typing import Dict, Optional
4
+
5
+ from autobyteus.llm.providers import LLMProvider
6
+ from autobyteus.utils.singleton import SingletonMeta
7
+ from .tool_formatter_pair import ToolFormatterPair
8
+
9
+ # Import all necessary formatters
10
+ from autobyteus.tools.usage.formatters import (
11
+ DefaultJsonSchemaFormatter, OpenAiJsonSchemaFormatter, AnthropicJsonSchemaFormatter, GeminiJsonSchemaFormatter,
12
+ DefaultJsonExampleFormatter, OpenAiJsonExampleFormatter, AnthropicJsonExampleFormatter, GeminiJsonExampleFormatter,
13
+ DefaultXmlSchemaFormatter, DefaultXmlExampleFormatter
14
+ )
15
+
16
+ logger = logging.getLogger(__name__)
17
+
18
+ class ToolFormattingRegistry(metaclass=SingletonMeta):
19
+ """
20
+ A consolidated registry that maps an LLMProvider directly to its required
21
+ ToolFormatterPair, which contains both schema and example formatters.
22
+ """
23
+
24
+ def __init__(self):
25
+ # A single, direct mapping from provider to its correct formatter pair.
26
+ self._pairs: Dict[LLMProvider, ToolFormatterPair] = {
27
+ # JSON-based providers
28
+ LLMProvider.OPENAI: ToolFormatterPair(OpenAiJsonSchemaFormatter(), OpenAiJsonExampleFormatter()),
29
+ LLMProvider.MISTRAL: ToolFormatterPair(OpenAiJsonSchemaFormatter(), OpenAiJsonExampleFormatter()),
30
+ LLMProvider.DEEPSEEK: ToolFormatterPair(OpenAiJsonSchemaFormatter(), OpenAiJsonExampleFormatter()),
31
+ LLMProvider.GROK: ToolFormatterPair(OpenAiJsonSchemaFormatter(), OpenAiJsonExampleFormatter()),
32
+ LLMProvider.GEMINI: ToolFormatterPair(GeminiJsonSchemaFormatter(), GeminiJsonExampleFormatter()),
33
+
34
+ # XML-based providers
35
+ LLMProvider.ANTHROPIC: ToolFormatterPair(DefaultXmlSchemaFormatter(), DefaultXmlExampleFormatter()),
36
+ }
37
+ # A default pair for any provider not explicitly listed (defaults to JSON)
38
+ self._default_pair = ToolFormatterPair(DefaultJsonSchemaFormatter(), DefaultJsonExampleFormatter())
39
+
40
+ logger.info("ToolFormattingRegistry initialized with direct provider-to-formatter mappings.")
41
+
42
+ def get_formatter_pair(self, provider: Optional[LLMProvider]) -> ToolFormatterPair:
43
+ """
44
+ Retrieves the appropriate formatting pair for a given provider.
45
+
46
+ Args:
47
+ provider: The LLMProvider enum member.
48
+
49
+ Returns:
50
+ The corresponding ToolFormatterPair instance.
51
+ """
52
+ if provider and provider in self._pairs:
53
+ pair = self._pairs[provider]
54
+ logger.debug(f"Found specific formatter pair for provider {provider.name}: {pair}")
55
+ return pair
56
+
57
+ logger.debug(f"No specific formatter pair for provider {provider.name if provider else 'Unknown'}. Returning default pair.")
58
+ return self._default_pair
@@ -0,0 +1,55 @@
1
+ # file: autobyteus/autobyteus/tools/usage/registries/tool_usage_parser_registry.py
2
+ import logging
3
+ from typing import Dict, Optional
4
+
5
+ from autobyteus.llm.providers import LLMProvider
6
+ from autobyteus.utils.singleton import SingletonMeta
7
+ from autobyteus.tools.usage.parsers import (
8
+ BaseToolUsageParser,
9
+ DefaultJsonToolUsageParser,
10
+ OpenAiJsonToolUsageParser,
11
+ GeminiJsonToolUsageParser,
12
+ DefaultXmlToolUsageParser
13
+ )
14
+
15
+ logger = logging.getLogger(__name__)
16
+
17
+ class ToolUsageParserRegistry(metaclass=SingletonMeta):
18
+ """
19
+ A consolidated registry that maps an LLMProvider directly to its required
20
+ tool usage parser, encapsulating the logic of which provider uses which format.
21
+ """
22
+
23
+ def __init__(self):
24
+ self._parsers: Dict[LLMProvider, BaseToolUsageParser] = {
25
+ # JSON-based providers
26
+ LLMProvider.OPENAI: OpenAiJsonToolUsageParser(),
27
+ LLMProvider.MISTRAL: OpenAiJsonToolUsageParser(),
28
+ LLMProvider.DEEPSEEK: OpenAiJsonToolUsageParser(),
29
+ LLMProvider.GROK: OpenAiJsonToolUsageParser(),
30
+ LLMProvider.GEMINI: GeminiJsonToolUsageParser(),
31
+
32
+ # XML-based providers
33
+ LLMProvider.ANTHROPIC: DefaultXmlToolUsageParser(),
34
+ }
35
+ # A default parser for any provider not explicitly listed (defaults to JSON)
36
+ self._default_parser = DefaultJsonToolUsageParser()
37
+ logger.info("ToolUsageParserRegistry initialized with direct provider-to-parser mappings.")
38
+
39
+ def get_parser(self, provider: Optional[LLMProvider]) -> BaseToolUsageParser:
40
+ """
41
+ Retrieves the appropriate tool usage parser for a given provider.
42
+
43
+ Args:
44
+ provider: The LLMProvider enum member.
45
+
46
+ Returns:
47
+ The corresponding BaseToolUsageParser instance.
48
+ """
49
+ if provider and provider in self._parsers:
50
+ parser = self._parsers[provider]
51
+ logger.debug(f"Found specific tool usage parser for provider {provider.name}: {parser.get_name()}")
52
+ return parser
53
+
54
+ logger.debug(f"No specific tool usage parser for provider {provider.name if provider else 'Unknown'}. Returning default parser.")
55
+ return self._default_parser
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: autobyteus
3
- Version: 1.1.4
3
+ Version: 1.1.5
4
4
  Summary: Multi-Agent framework
5
5
  Home-page: https://github.com/AutoByteus/autobyteus
6
6
  Author: Ryan Zheng
@@ -16,11 +16,11 @@ Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
17
  Requires-Dist: aiohttp
18
18
  Requires-Dist: anthropic==0.37.1
19
- Requires-Dist: autobyteus-llm-client==1.1.1
19
+ Requires-Dist: autobyteus-llm-client==1.1.2
20
20
  Requires-Dist: beautifulsoup4>=4.12.2
21
21
  Requires-Dist: boto3
22
22
  Requires-Dist: botocore
23
- Requires-Dist: brui-core==1.0.8
23
+ Requires-Dist: brui-core==1.0.9
24
24
  Requires-Dist: certifi==2025.4.26
25
25
  Requires-Dist: google-api-python-client
26
26
  Requires-Dist: google-generativeai