sinan-agentic-core 0.16.1__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 (59) hide show
  1. sinan_agentic_core/__init__.py +186 -0
  2. sinan_agentic_core/core/__init__.py +47 -0
  3. sinan_agentic_core/core/base_runner.py +1350 -0
  4. sinan_agentic_core/core/capabilities/__init__.py +6 -0
  5. sinan_agentic_core/core/capabilities/base.py +234 -0
  6. sinan_agentic_core/core/capabilities/steering.py +158 -0
  7. sinan_agentic_core/core/errors.py +105 -0
  8. sinan_agentic_core/core/model_retry.py +148 -0
  9. sinan_agentic_core/core/model_settings.py +118 -0
  10. sinan_agentic_core/core/output_recovery.py +299 -0
  11. sinan_agentic_core/core/reasoning.py +81 -0
  12. sinan_agentic_core/core/run_config.py +171 -0
  13. sinan_agentic_core/core/run_errors.py +228 -0
  14. sinan_agentic_core/core/stream_preview.py +43 -0
  15. sinan_agentic_core/core/tool_error_recovery.py +563 -0
  16. sinan_agentic_core/core/tool_output_trim.py +111 -0
  17. sinan_agentic_core/core/tool_tracer.py +145 -0
  18. sinan_agentic_core/core/turn_budget.py +330 -0
  19. sinan_agentic_core/core/turn_budget_tool.py +34 -0
  20. sinan_agentic_core/core/usage.py +127 -0
  21. sinan_agentic_core/instructions/__init__.py +9 -0
  22. sinan_agentic_core/instructions/builder.py +219 -0
  23. sinan_agentic_core/llm/__init__.py +28 -0
  24. sinan_agentic_core/llm/config.py +85 -0
  25. sinan_agentic_core/llm/factory.py +99 -0
  26. sinan_agentic_core/llm/yaml_loader.py +99 -0
  27. sinan_agentic_core/mcp/__init__.py +49 -0
  28. sinan_agentic_core/mcp/context_protocol.py +69 -0
  29. sinan_agentic_core/mcp/server_builder.py +255 -0
  30. sinan_agentic_core/mcp/tool_adapter.py +473 -0
  31. sinan_agentic_core/mcp/yaml_schema.py +104 -0
  32. sinan_agentic_core/models/__init__.py +10 -0
  33. sinan_agentic_core/models/context.py +167 -0
  34. sinan_agentic_core/models/outputs/__init__.py +144 -0
  35. sinan_agentic_core/orchestrator.py +88 -0
  36. sinan_agentic_core/py.typed +0 -0
  37. sinan_agentic_core/registry/__init__.py +63 -0
  38. sinan_agentic_core/registry/agent_catalog.py +536 -0
  39. sinan_agentic_core/registry/agent_factory.py +132 -0
  40. sinan_agentic_core/registry/agent_registry.py +164 -0
  41. sinan_agentic_core/registry/capability_registry.py +175 -0
  42. sinan_agentic_core/registry/guardrail_registry.py +302 -0
  43. sinan_agentic_core/registry/tool_catalog.py +230 -0
  44. sinan_agentic_core/registry/tool_registry.py +173 -0
  45. sinan_agentic_core/services/__init__.py +46 -0
  46. sinan_agentic_core/services/chat.py +468 -0
  47. sinan_agentic_core/services/events.py +254 -0
  48. sinan_agentic_core/services/hooks.py +102 -0
  49. sinan_agentic_core/session/__init__.py +10 -0
  50. sinan_agentic_core/session/agent_session.py +352 -0
  51. sinan_agentic_core/session/sqlite_store.py +409 -0
  52. sinan_agentic_core/utils/__init__.py +15 -0
  53. sinan_agentic_core/utils/tool_helpers.py +41 -0
  54. sinan_agentic_core/utils/turn_budget_context.py +29 -0
  55. sinan_agentic_core-0.16.1.dist-info/METADATA +1649 -0
  56. sinan_agentic_core-0.16.1.dist-info/RECORD +59 -0
  57. sinan_agentic_core-0.16.1.dist-info/WHEEL +5 -0
  58. sinan_agentic_core-0.16.1.dist-info/licenses/LICENSE +21 -0
  59. sinan_agentic_core-0.16.1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,186 @@
1
+ """Sinan - Generic agent orchestration framework.
2
+
3
+ This package provides a reusable framework for building multi-agent systems
4
+ using the OpenAI Agents SDK with code orchestration.
5
+
6
+ Core Components:
7
+ - AgentSession: Manages conversation history
8
+ - AgentContext: Stores workflow state and data
9
+ - AgentRegistry: Declarative agent definitions
10
+ - ToolRegistry: Declarative tool definitions
11
+ - AgentOrchestrator: Workflow orchestration logic
12
+
13
+ Quick Start:
14
+ from sinan_agentic_core import (
15
+ AgentSession,
16
+ AgentContext,
17
+ AgentOrchestrator,
18
+ register_agent,
19
+ register_tool,
20
+ AgentDefinition
21
+ )
22
+
23
+ # Define your agent
24
+ my_agent = AgentDefinition(
25
+ name="my_agent",
26
+ description="Does something",
27
+ instructions="You are a helpful assistant...",
28
+ tools=["my_tool"]
29
+ )
30
+ register_agent(my_agent)
31
+
32
+ # Run orchestrator
33
+ orchestrator = AgentOrchestrator()
34
+ result = await orchestrator.run(
35
+ user_query="Do something",
36
+ context_data={"database_connector": db}
37
+ )
38
+ """
39
+
40
+ from .core import (
41
+ BaseAgentRunner,
42
+ Capability,
43
+ ModelRetryConfig,
44
+ RetryBackoffConfig,
45
+ RetryTrigger,
46
+ RunErrorKind,
47
+ ToolErrorRecovery,
48
+ ToolOutputTrimConfig,
49
+ ToolTracer,
50
+ TurnBudget,
51
+ TurnBudgetConfig,
52
+ build_error_handlers,
53
+ build_run_config,
54
+ classify_run_error,
55
+ recover_invalid_final_output,
56
+ )
57
+ from .instructions import InstructionBuilder
58
+ from .llm import (
59
+ AzureOpenAIProviderConfig,
60
+ LLMProviderConfig,
61
+ OpenAIProviderConfig,
62
+ configure_llm_provider,
63
+ load_llm_provider_config,
64
+ parse_llm_provider_config,
65
+ resolve_openai_client,
66
+ )
67
+ from .models.context import AgentContext
68
+ from .models.outputs import ChatResponse, ToolOutput
69
+ from .orchestrator import AgentOrchestrator
70
+ from .registry import (
71
+ AgentCatalog,
72
+ AgentDefinition,
73
+ AgentRegistry,
74
+ AgentYamlEntry,
75
+ CapabilityFactory,
76
+ CapabilityNotFoundError,
77
+ CapabilityRef,
78
+ CapabilityRegistry,
79
+ GuardrailCategory,
80
+ GuardrailDefinition,
81
+ GuardrailRegistry,
82
+ ResolvedGuardrails,
83
+ ToolCatalog,
84
+ ToolDefinition,
85
+ ToolRegistry,
86
+ ToolYamlEntry,
87
+ create_agent_from_registry,
88
+ get_agent_registry,
89
+ get_capability_registry,
90
+ get_guardrail_registry,
91
+ get_tool_registry,
92
+ load_agent_catalog,
93
+ load_tool_catalog,
94
+ register_agent,
95
+ register_capability,
96
+ register_guardrail,
97
+ register_tool,
98
+ )
99
+ from .services import (
100
+ StreamingRunHooks,
101
+ chat,
102
+ chat_streamed,
103
+ chat_with_hooks,
104
+ )
105
+ from .session import AgentSession, ConversationHistory, SQLiteSessionStore
106
+ from .utils import tool_error, tool_response, unwrap_context
107
+
108
+ # MCP support (optional — requires 'sinan_agentic_core[mcp]')
109
+ # Lazy import to avoid requiring FastMCP for non-MCP users.
110
+ # Usage: from sinan_agentic_core.mcp import build_mcp_server, MCPContextFactory
111
+
112
+ __all__ = [
113
+ # Core
114
+ "BaseAgentRunner",
115
+ "build_error_handlers",
116
+ "build_run_config",
117
+ "Capability",
118
+ "classify_run_error",
119
+ "ModelRetryConfig",
120
+ "recover_invalid_final_output",
121
+ "RetryBackoffConfig",
122
+ "RetryTrigger",
123
+ "RunErrorKind",
124
+ "ToolErrorRecovery",
125
+ "ToolOutputTrimConfig",
126
+ "ToolTracer",
127
+ "TurnBudget",
128
+ "TurnBudgetConfig",
129
+ # Instructions
130
+ "InstructionBuilder",
131
+ # LLM providers
132
+ "AzureOpenAIProviderConfig",
133
+ "LLMProviderConfig",
134
+ "OpenAIProviderConfig",
135
+ "configure_llm_provider",
136
+ "load_llm_provider_config",
137
+ "parse_llm_provider_config",
138
+ "resolve_openai_client",
139
+ # Session
140
+ "AgentSession",
141
+ "ConversationHistory",
142
+ "SQLiteSessionStore",
143
+ # Models
144
+ "AgentContext",
145
+ "ToolOutput",
146
+ "ChatResponse",
147
+ # Registry
148
+ "AgentCatalog",
149
+ "AgentYamlEntry",
150
+ "CapabilityFactory",
151
+ "CapabilityNotFoundError",
152
+ "CapabilityRef",
153
+ "CapabilityRegistry",
154
+ "get_capability_registry",
155
+ "register_capability",
156
+ "load_agent_catalog",
157
+ "AgentDefinition",
158
+ "AgentRegistry",
159
+ "get_agent_registry",
160
+ "register_agent",
161
+ "create_agent_from_registry",
162
+ "ToolCatalog",
163
+ "ToolYamlEntry",
164
+ "load_tool_catalog",
165
+ "ToolDefinition",
166
+ "ToolRegistry",
167
+ "get_tool_registry",
168
+ "register_tool",
169
+ "GuardrailCategory",
170
+ "GuardrailDefinition",
171
+ "GuardrailRegistry",
172
+ "ResolvedGuardrails",
173
+ "get_guardrail_registry",
174
+ "register_guardrail",
175
+ # Services
176
+ "StreamingRunHooks",
177
+ "chat",
178
+ "chat_with_hooks",
179
+ "chat_streamed",
180
+ # Orchestrator
181
+ "AgentOrchestrator",
182
+ # Utils
183
+ "unwrap_context",
184
+ "tool_response",
185
+ "tool_error",
186
+ ]
@@ -0,0 +1,47 @@
1
+ """Core agent execution components.
2
+
3
+ This module contains fundamental components for agent execution:
4
+ - BaseAgentRunner: Abstract base class for all agent runners
5
+ - Capability: Pluggable agent behavior primitive
6
+ - TurnBudget: Soft turn budget with self-extension (Capability)
7
+ - ToolErrorRecovery: Intelligent tool error tracking (Capability)
8
+ - ToolTracer: Observation-only tool-call tracer (Capability)
9
+ - recover_invalid_final_output: SDK handler that salvages malformed structured output
10
+ - build_error_handlers: Run error handlers a built agent needs
11
+ - build_run_config: Run-level SDK settings a built agent needs
12
+ - ModelRetryConfig: Declarative opt-in retry policy for model calls
13
+ - ToolOutputTrimConfig: Declarative opt-in trimming of oversized tool outputs
14
+ - TurnBudgetConfig: Declarative opt-in soft turn budget for one agent
15
+ - RunErrorKind / classify_run_error: Typed classification of agent-run failures
16
+ """
17
+
18
+ from .base_runner import BaseAgentRunner
19
+ from .capabilities import Capability
20
+ from .errors import structured_tool_error
21
+ from .model_retry import ModelRetryConfig, RetryBackoffConfig, RetryTrigger
22
+ from .output_recovery import build_error_handlers, recover_invalid_final_output
23
+ from .run_config import build_run_config
24
+ from .run_errors import RunErrorKind, classify_run_error
25
+ from .tool_error_recovery import ToolErrorRecovery
26
+ from .tool_output_trim import ToolOutputTrimConfig
27
+ from .tool_tracer import ToolTracer
28
+ from .turn_budget import TurnBudget, TurnBudgetConfig
29
+
30
+ __all__ = [
31
+ "BaseAgentRunner",
32
+ "build_error_handlers",
33
+ "build_run_config",
34
+ "Capability",
35
+ "classify_run_error",
36
+ "ModelRetryConfig",
37
+ "recover_invalid_final_output",
38
+ "RetryBackoffConfig",
39
+ "RetryTrigger",
40
+ "RunErrorKind",
41
+ "structured_tool_error",
42
+ "ToolErrorRecovery",
43
+ "ToolOutputTrimConfig",
44
+ "ToolTracer",
45
+ "TurnBudget",
46
+ "TurnBudgetConfig",
47
+ ]