10xgraph-api 0.7.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 (203) hide show
  1. 10xgraph_api-0.7.0.dist-info/METADATA +618 -0
  2. 10xgraph_api-0.7.0.dist-info/RECORD +203 -0
  3. 10xgraph_api-0.7.0.dist-info/WHEEL +5 -0
  4. 10xgraph_api-0.7.0.dist-info/entry_points.txt +3 -0
  5. 10xgraph_api-0.7.0.dist-info/licenses/LICENSE +21 -0
  6. 10xgraph_api-0.7.0.dist-info/top_level.txt +2 -0
  7. agentflow_cli/__init__.py +69 -0
  8. tenxgraph_api/__init__.py +23 -0
  9. tenxgraph_api/cli/__init__.py +6 -0
  10. tenxgraph_api/cli/capabilities.py +127 -0
  11. tenxgraph_api/cli/commands/__init__.py +49 -0
  12. tenxgraph_api/cli/commands/api.py +262 -0
  13. tenxgraph_api/cli/commands/audit.py +213 -0
  14. tenxgraph_api/cli/commands/build.py +305 -0
  15. tenxgraph_api/cli/commands/config.py +71 -0
  16. tenxgraph_api/cli/commands/demo.py +93 -0
  17. tenxgraph_api/cli/commands/eval.py +909 -0
  18. tenxgraph_api/cli/commands/init.py +531 -0
  19. tenxgraph_api/cli/commands/skills.py +532 -0
  20. tenxgraph_api/cli/commands/test.py +113 -0
  21. tenxgraph_api/cli/commands/version.py +47 -0
  22. tenxgraph_api/cli/config_editor/__init__.py +15 -0
  23. tenxgraph_api/cli/config_editor/schema.py +566 -0
  24. tenxgraph_api/cli/config_editor/server.py +240 -0
  25. tenxgraph_api/cli/config_editor/static/app.css +2 -0
  26. tenxgraph_api/cli/config_editor/static/app.js +3 -0
  27. tenxgraph_api/cli/config_editor/static/favicon.svg +11 -0
  28. tenxgraph_api/cli/config_editor/static/index.html +20 -0
  29. tenxgraph_api/cli/config_editor/store.py +120 -0
  30. tenxgraph_api/cli/config_editor/validation.py +377 -0
  31. tenxgraph_api/cli/constants.py +112 -0
  32. tenxgraph_api/cli/context.py +46 -0
  33. tenxgraph_api/cli/core/__init__.py +0 -0
  34. tenxgraph_api/cli/core/animations.py +550 -0
  35. tenxgraph_api/cli/core/config.py +279 -0
  36. tenxgraph_api/cli/core/output.py +625 -0
  37. tenxgraph_api/cli/core/prompts.py +220 -0
  38. tenxgraph_api/cli/core/screen.py +287 -0
  39. tenxgraph_api/cli/core/steps.py +621 -0
  40. tenxgraph_api/cli/core/theme.py +242 -0
  41. tenxgraph_api/cli/core/validation.py +251 -0
  42. tenxgraph_api/cli/exceptions.py +129 -0
  43. tenxgraph_api/cli/logger.py +84 -0
  44. tenxgraph_api/cli/main.py +936 -0
  45. tenxgraph_api/cli/templates/__init__.py +0 -0
  46. tenxgraph_api/cli/templates/defaults.py +844 -0
  47. tenxgraph_api/cli/templates/dev/.env.example +1 -0
  48. tenxgraph_api/cli/templates/dev/10xgraph.json +16 -0
  49. tenxgraph_api/cli/templates/dev/graph/__init__.py +0 -0
  50. tenxgraph_api/cli/templates/dev/graph/agent.py +63 -0
  51. tenxgraph_api/cli/templates/prod/.env.example +75 -0
  52. tenxgraph_api/cli/templates/prod/.pre-commit-config.yaml +50 -0
  53. tenxgraph_api/cli/templates/prod/.python-version +1 -0
  54. tenxgraph_api/cli/templates/prod/10xgraph.json +42 -0
  55. tenxgraph_api/cli/templates/prod/auth/__init__.py +0 -0
  56. tenxgraph_api/cli/templates/prod/auth/agent_auth.py +46 -0
  57. tenxgraph_api/cli/templates/prod/evals/__init__.py +0 -0
  58. tenxgraph_api/cli/templates/prod/evals/user_simulator_eval.py +76 -0
  59. tenxgraph_api/cli/templates/prod/evals/weather_agents_eval.py +53 -0
  60. tenxgraph_api/cli/templates/prod/graph/__init__.py +0 -0
  61. tenxgraph_api/cli/templates/prod/graph/agent.py +50 -0
  62. tenxgraph_api/cli/templates/prod/graph/state.py +5 -0
  63. tenxgraph_api/cli/templates/prod/graph/thread_name_generator.py +7 -0
  64. tenxgraph_api/cli/templates/prod/graph/tools/__init__.py +0 -0
  65. tenxgraph_api/cli/templates/prod/graph/tools/weather_tool.py +43 -0
  66. tenxgraph_api/cli/templates/prod/graph/validators/__init__.py +0 -0
  67. tenxgraph_api/cli/templates/prod/graph/validators/lifecyle.py +107 -0
  68. tenxgraph_api/cli/templates/prod/graph/validators/manager.py +9 -0
  69. tenxgraph_api/cli/templates/prod/graph/validators/validators.py +21 -0
  70. tenxgraph_api/cli/templates/prod/pyproject.toml +79 -0
  71. tenxgraph_api/cli/templates/prod/tests/__init__.py +0 -0
  72. tenxgraph_api/cli/templates/prod/tests/conftest.py +6 -0
  73. tenxgraph_api/cli/templates/prod/tests/test_agent_eval.py +78 -0
  74. tenxgraph_api/cli/templates/prod/tests/test_catalog_tools.py +47 -0
  75. tenxgraph_api/cli/templates/prod/tests/test_graph_nodes.py +57 -0
  76. tenxgraph_api/cli/templates/skills/10xgraph/SKILL.md +92 -0
  77. tenxgraph_api/cli/templates/skills/10xgraph/references/agents-and-tools.md +389 -0
  78. tenxgraph_api/cli/templates/skills/10xgraph/references/api-client.md +61 -0
  79. tenxgraph_api/cli/templates/skills/10xgraph/references/api-configuration.md +75 -0
  80. tenxgraph_api/cli/templates/skills/10xgraph/references/api-settings-and-middleware.md +89 -0
  81. tenxgraph_api/cli/templates/skills/10xgraph/references/architecture.md +91 -0
  82. tenxgraph_api/cli/templates/skills/10xgraph/references/auth-and-authorization.md +149 -0
  83. tenxgraph_api/cli/templates/skills/10xgraph/references/callbacks-and-command.md +283 -0
  84. tenxgraph_api/cli/templates/skills/10xgraph/references/checkpointing-and-threads.md +63 -0
  85. tenxgraph_api/cli/templates/skills/10xgraph/references/cli-commands.md +73 -0
  86. tenxgraph_api/cli/templates/skills/10xgraph/references/client-auth-and-errors.md +94 -0
  87. tenxgraph_api/cli/templates/skills/10xgraph/references/client-messages-invoke-stream.md +115 -0
  88. tenxgraph_api/cli/templates/skills/10xgraph/references/client-threads-memory-files.md +80 -0
  89. tenxgraph_api/cli/templates/skills/10xgraph/references/context-id-background.md +80 -0
  90. tenxgraph_api/cli/templates/skills/10xgraph/references/dependency-injection.md +58 -0
  91. tenxgraph_api/cli/templates/skills/10xgraph/references/evaluation.md +500 -0
  92. tenxgraph_api/cli/templates/skills/10xgraph/references/id-and-thread-name-generators.md +69 -0
  93. tenxgraph_api/cli/templates/skills/10xgraph/references/media-and-files.md +66 -0
  94. tenxgraph_api/cli/templates/skills/10xgraph/references/memory-and-store.md +70 -0
  95. tenxgraph_api/cli/templates/skills/10xgraph/references/prebuilt-agents-and-tools.md +394 -0
  96. tenxgraph_api/cli/templates/skills/10xgraph/references/production-runtime.md +56 -0
  97. tenxgraph_api/cli/templates/skills/10xgraph/references/providers-and-adapters.md +89 -0
  98. tenxgraph_api/cli/templates/skills/10xgraph/references/publishers-and-runtime-protocols.md +84 -0
  99. tenxgraph_api/cli/templates/skills/10xgraph/references/rate-limiting.md +194 -0
  100. tenxgraph_api/cli/templates/skills/10xgraph/references/realtime.md +172 -0
  101. tenxgraph_api/cli/templates/skills/10xgraph/references/remote-tools.md +55 -0
  102. tenxgraph_api/cli/templates/skills/10xgraph/references/rest-api-and-errors.md +97 -0
  103. tenxgraph_api/cli/templates/skills/10xgraph/references/security-and-validators.md +86 -0
  104. tenxgraph_api/cli/templates/skills/10xgraph/references/state-and-messages.md +68 -0
  105. tenxgraph_api/cli/templates/skills/10xgraph/references/state-graph.md +232 -0
  106. tenxgraph_api/cli/templates/skills/10xgraph/references/stream-emitter.md +144 -0
  107. tenxgraph_api/cli/templates/skills/10xgraph/references/streaming.md +53 -0
  108. tenxgraph_api/cli/templates/skills/10xgraph/references/testing-and-evaluation.md +64 -0
  109. tenxgraph_api/cli/templates/skills/10xgraph/references/unit-testing.md +202 -0
  110. tenxgraph_api/cli/templates/skills/copilot/10xgraph.instructions.md +108 -0
  111. tenxgraph_api/py.typed +0 -0
  112. tenxgraph_api/src/__init__.py +0 -0
  113. tenxgraph_api/src/app/__init__.py +13 -0
  114. tenxgraph_api/src/app/core/__init__.py +15 -0
  115. tenxgraph_api/src/app/core/auth/__init__.py +0 -0
  116. tenxgraph_api/src/app/core/auth/auth_backend.py +38 -0
  117. tenxgraph_api/src/app/core/auth/authorization.py +379 -0
  118. tenxgraph_api/src/app/core/auth/base_auth.py +27 -0
  119. tenxgraph_api/src/app/core/auth/jwt_auth.py +122 -0
  120. tenxgraph_api/src/app/core/auth/ownership_resolver.py +170 -0
  121. tenxgraph_api/src/app/core/auth/permissions.py +354 -0
  122. tenxgraph_api/src/app/core/auth/request_config.py +130 -0
  123. tenxgraph_api/src/app/core/auth/route_guard.py +105 -0
  124. tenxgraph_api/src/app/core/config/__init__.py +0 -0
  125. tenxgraph_api/src/app/core/config/graph_config.py +532 -0
  126. tenxgraph_api/src/app/core/config/media_settings.py +72 -0
  127. tenxgraph_api/src/app/core/config/sentry_config.py +60 -0
  128. tenxgraph_api/src/app/core/config/settings.py +202 -0
  129. tenxgraph_api/src/app/core/config/setup_logs.py +65 -0
  130. tenxgraph_api/src/app/core/config/setup_middleware.py +483 -0
  131. tenxgraph_api/src/app/core/config/worker_middleware.py +99 -0
  132. tenxgraph_api/src/app/core/exceptions/__init__.py +17 -0
  133. tenxgraph_api/src/app/core/exceptions/general_exception.py +58 -0
  134. tenxgraph_api/src/app/core/exceptions/handle_errors.py +363 -0
  135. tenxgraph_api/src/app/core/exceptions/resources_exceptions.py +72 -0
  136. tenxgraph_api/src/app/core/exceptions/user_exception.py +58 -0
  137. tenxgraph_api/src/app/core/middleware/__init__.py +25 -0
  138. tenxgraph_api/src/app/core/middleware/rate_limit/__init__.py +15 -0
  139. tenxgraph_api/src/app/core/middleware/rate_limit/base.py +27 -0
  140. tenxgraph_api/src/app/core/middleware/rate_limit/factory.py +98 -0
  141. tenxgraph_api/src/app/core/middleware/rate_limit/keying.py +133 -0
  142. tenxgraph_api/src/app/core/middleware/rate_limit/memory.py +98 -0
  143. tenxgraph_api/src/app/core/middleware/rate_limit/middleware.py +90 -0
  144. tenxgraph_api/src/app/core/middleware/rate_limit/redis.py +115 -0
  145. tenxgraph_api/src/app/core/middleware/request_limits.py +154 -0
  146. tenxgraph_api/src/app/core/middleware/security_headers.py +239 -0
  147. tenxgraph_api/src/app/core/utils/__init__.py +14 -0
  148. tenxgraph_api/src/app/core/utils/log_sanitizer.py +216 -0
  149. tenxgraph_api/src/app/loader.py +516 -0
  150. tenxgraph_api/src/app/main.py +180 -0
  151. tenxgraph_api/src/app/routers/__init__.py +4 -0
  152. tenxgraph_api/src/app/routers/ag_ui/__init__.py +10 -0
  153. tenxgraph_api/src/app/routers/ag_ui/converter.py +195 -0
  154. tenxgraph_api/src/app/routers/ag_ui/event_mapper.py +353 -0
  155. tenxgraph_api/src/app/routers/ag_ui/router.py +90 -0
  156. tenxgraph_api/src/app/routers/ag_ui/service.py +193 -0
  157. tenxgraph_api/src/app/routers/checkpointer/__init__.py +1 -0
  158. tenxgraph_api/src/app/routers/checkpointer/router.py +482 -0
  159. tenxgraph_api/src/app/routers/checkpointer/schemas/__init__.py +1 -0
  160. tenxgraph_api/src/app/routers/checkpointer/schemas/checkpointer_schemas.py +121 -0
  161. tenxgraph_api/src/app/routers/checkpointer/services/__init__.py +1 -0
  162. tenxgraph_api/src/app/routers/checkpointer/services/checkpointer_service.py +300 -0
  163. tenxgraph_api/src/app/routers/evals/__init__.py +6 -0
  164. tenxgraph_api/src/app/routers/evals/router.py +38 -0
  165. tenxgraph_api/src/app/routers/evals/services/__init__.py +1 -0
  166. tenxgraph_api/src/app/routers/evals/services/eval_report_service.py +354 -0
  167. tenxgraph_api/src/app/routers/graph/__init__.py +6 -0
  168. tenxgraph_api/src/app/routers/graph/realtime_guard.py +161 -0
  169. tenxgraph_api/src/app/routers/graph/router.py +821 -0
  170. tenxgraph_api/src/app/routers/graph/schemas/__init__.py +1 -0
  171. tenxgraph_api/src/app/routers/graph/schemas/graph_schemas.py +386 -0
  172. tenxgraph_api/src/app/routers/graph/services/__init__.py +1 -0
  173. tenxgraph_api/src/app/routers/graph/services/graph_service.py +1219 -0
  174. tenxgraph_api/src/app/routers/graph/services/multimodal_preprocessor.py +164 -0
  175. tenxgraph_api/src/app/routers/media/__init__.py +506 -0
  176. tenxgraph_api/src/app/routers/media/router.py +242 -0
  177. tenxgraph_api/src/app/routers/media/schemas.py +39 -0
  178. tenxgraph_api/src/app/routers/ping/__init__.py +4 -0
  179. tenxgraph_api/src/app/routers/ping/router.py +28 -0
  180. tenxgraph_api/src/app/routers/setup_router.py +60 -0
  181. tenxgraph_api/src/app/routers/store/__init__.py +4 -0
  182. tenxgraph_api/src/app/routers/store/router.py +200 -0
  183. tenxgraph_api/src/app/routers/store/schemas/__init__.py +28 -0
  184. tenxgraph_api/src/app/routers/store/schemas/store_schemas.py +200 -0
  185. tenxgraph_api/src/app/routers/store/services/__init__.py +4 -0
  186. tenxgraph_api/src/app/routers/store/services/store_service.py +203 -0
  187. tenxgraph_api/src/app/tasks/__init__.py +0 -0
  188. tenxgraph_api/src/app/tasks/user_tasks.py +38 -0
  189. tenxgraph_api/src/app/utils/__init__.py +12 -0
  190. tenxgraph_api/src/app/utils/callable_helper.py +26 -0
  191. tenxgraph_api/src/app/utils/media/__init__.py +15 -0
  192. tenxgraph_api/src/app/utils/media/extractor.py +172 -0
  193. tenxgraph_api/src/app/utils/media/pipeline.py +83 -0
  194. tenxgraph_api/src/app/utils/parse_output.py +17 -0
  195. tenxgraph_api/src/app/utils/response_helper.py +129 -0
  196. tenxgraph_api/src/app/utils/schemas/__init__.py +11 -0
  197. tenxgraph_api/src/app/utils/schemas/output_schemas.py +28 -0
  198. tenxgraph_api/src/app/utils/schemas/user_schemas.py +13 -0
  199. tenxgraph_api/src/app/utils/snowflake_id_generator.py +90 -0
  200. tenxgraph_api/src/app/utils/swagger_helper.py +160 -0
  201. tenxgraph_api/src/app/utils/telemetry_store.py +123 -0
  202. tenxgraph_api/src/app/utils/thread_name_generator.py +304 -0
  203. tenxgraph_api/src/app/worker.py +91 -0
@@ -0,0 +1,389 @@
1
+ # Agents and Tools
2
+
3
+ Use this when adding model behavior, tools, tool routing, provider options, retries, fallbacks, memory, skills, or structured output to an agent.
4
+
5
+ ---
6
+
7
+ ## Agent
8
+
9
+ `Agent` is a graph node that calls an LLM provider and appends the response to state. It supports OpenAI, Google GenAI, and any OpenAI-compatible API behind a unified interface.
10
+
11
+ ### Constructor reference
12
+
13
+ ```python
14
+ Agent(
15
+ model: str, # required
16
+ output_type: str = "text", # "text" | "image" | "video" | "audio"
17
+ system_prompt: list[dict] | None = None,
18
+ tool_node: str | ToolNode | None = None,
19
+ extra_messages: list[Message] | None = None,
20
+ trim_context: bool = False,
21
+ tools_tags: set[str] | None = None,
22
+ reasoning_config: dict | bool | None = {"effort": "medium"},
23
+ skills: SkillConfig | None = None,
24
+ memory: MemoryConfig | None = None,
25
+ retry_config: RetryConfig | bool | None = True,
26
+ fallback_models: list[str | tuple[str, str]] | None = None,
27
+ multimodal_config: MultimodalConfig | None = None,
28
+ output_schema: type[BaseModel] | None = None,
29
+ # extra kwargs forwarded to provider SDK:
30
+ provider: str | None = None, # "openai" | "google"; auto-detected if omitted
31
+ base_url: str | None = None,
32
+ api_style: str = "chat", # "chat" | "responses" (OpenAI only)
33
+ use_vertex_ai: bool = False,
34
+ temperature: float | None = None,
35
+ max_tokens: int | None = None,
36
+ # ...any other provider kwargs
37
+ )
38
+ ```
39
+
40
+ ### Model and provider
41
+
42
+ Provider is auto-detected from the model name. Three ways to set it:
43
+
44
+ ```python
45
+ agent = Agent(model="gpt-4o") # auto → openai
46
+ agent = Agent(model="gemini-2.5-flash") # auto → google
47
+ agent = Agent(model="openai/gpt-4o") # prefix syntax
48
+ agent = Agent(model="gpt-4o", provider="openai") # explicit kwarg
49
+ ```
50
+
51
+ Third-party OpenAI-compatible APIs use `provider="openai"` + `base_url`:
52
+
53
+ ```python
54
+ # Ollama (local)
55
+ Agent(model="llama3.2", provider="openai", base_url="http://localhost:11434/v1")
56
+
57
+ # DeepSeek
58
+ Agent(model="deepseek-chat", provider="openai", base_url="https://api.deepseek.com/v1")
59
+
60
+ # OpenRouter
61
+ Agent(model="anthropic/claude-3-5-sonnet", provider="openai", base_url="https://openrouter.ai/api/v1")
62
+ ```
63
+
64
+ ### System prompt
65
+
66
+ Pass a list of message dicts. `{field_name}` placeholders are replaced at runtime with values from `AgentState`:
67
+
68
+ ```python
69
+ class MyState(AgentState):
70
+ user_name: str = "Guest"
71
+ language: str = "English"
72
+
73
+ agent = Agent(
74
+ model="gpt-4o",
75
+ system_prompt=[{"role": "system", "content": "Help {user_name}. Reply in {language}."}],
76
+ )
77
+ ```
78
+
79
+ ### Reasoning config
80
+
81
+ Reasoning is **on by default** at medium effort. Applies to both OpenAI and Google models.
82
+
83
+ ```python
84
+ agent = Agent(model="gpt-4o") # on, medium effort
85
+ agent = Agent(model="gpt-4o", reasoning_config={"effort": "high"})
86
+ agent = Agent(model="gpt-4o", reasoning_config=None) # off
87
+ agent = Agent(model="o4-mini", reasoning_config={"effort": "low", "summary": "auto"}) # OpenAI
88
+ agent = Agent(model="gemini-2.5-flash", reasoning_config={"thinking_budget": 5000}) # Google exact
89
+ ```
90
+
91
+ Google effort → thinking_budget mapping:
92
+
93
+ | `effort` | `thinking_budget` |
94
+ |---|---|
95
+ | `"low"` | 512 |
96
+ | `"medium"` (default) | 8192 |
97
+ | `"high"` | 24576 |
98
+
99
+ ### Retry config
100
+
101
+ Default: 3 retries, 1 s initial delay, 2x back-off, 30 s cap. Retries on HTTP 429, 500, 502, 503, 529.
102
+
103
+ ```python
104
+ from tenxgraph.core.graph.agent_internal.constants import RetryConfig
105
+
106
+ agent = Agent(model="gpt-4o", retry_config=False) # disable
107
+
108
+ agent = Agent(
109
+ model="gpt-4o",
110
+ retry_config=RetryConfig(max_retries=5, initial_delay=2.0, max_delay=60.0, backoff_factor=2.0),
111
+ )
112
+ ```
113
+
114
+ `RetryConfig` fields: `max_retries` (3), `initial_delay` (1.0 s), `max_delay` (30.0 s), `backoff_factor` (2.0).
115
+
116
+ ### Circuit breaker (opt-in)
117
+
118
+ Complements retry + `fallback_models`. Once a `(provider, model)` target fails
119
+ `circuit_breaker_threshold` times in a row, its circuit opens and that target is skipped (straight
120
+ to the next fallback) for `circuit_breaker_reset_timeout` seconds, instead of being retried on every
121
+ call. Configure on `RetryConfig`:
122
+
123
+ - `circuit_breaker_enabled: bool = False`
124
+ - `circuit_breaker_threshold: int = 5`
125
+ - `circuit_breaker_reset_timeout: float = 30.0`
126
+
127
+ ```python
128
+ RetryConfig(circuit_breaker_enabled=True, circuit_breaker_threshold=3, circuit_breaker_reset_timeout=60.0)
129
+ ```
130
+
131
+ ### Fallback models
132
+
133
+ When the primary model exhausts all retries, 10xGraph tries each fallback in order:
134
+
135
+ ```python
136
+ agent = Agent(
137
+ model="gemini-2.5-flash",
138
+ provider="google",
139
+ fallback_models=[
140
+ "gemini-2.0-flash", # inherit provider
141
+ ("gpt-4o-mini", "openai"), # explicit (model, provider) tuple
142
+ ],
143
+ )
144
+ ```
145
+
146
+ ### LLM call timeout
147
+
148
+ All LLM clients apply a default request timeout (600 s) so a stalled provider cannot hang a run
149
+ indefinitely. Override globally via the `AGENTFLOW_LLM_TIMEOUT` env var (seconds), or
150
+ programmatically:
151
+
152
+ ```python
153
+ from tenxgraph.core.llm import (
154
+ set_default_llm_timeout, get_default_llm_timeout, DEFAULT_LLM_TIMEOUT_SECONDS,
155
+ )
156
+
157
+ set_default_llm_timeout(120.0) # set
158
+ set_default_llm_timeout(None) # reset to default
159
+ ```
160
+
161
+ An explicit per-client `timeout=` still takes precedence.
162
+
163
+ ### Structured output
164
+
165
+ `output_schema` with a Pydantic model forces JSON output. Requires `output_type="text"` (default).
166
+
167
+ ```python
168
+ from pydantic import BaseModel
169
+
170
+ class ReviewAnalysis(BaseModel):
171
+ sentiment: str
172
+ score: float
173
+ summary: str
174
+
175
+ agent = Agent(model="gpt-4o", output_schema=ReviewAnalysis)
176
+ ```
177
+
178
+ ### Extra messages
179
+
180
+ `extra_messages` are injected into every LLM call after the system prompt and before the context window. Use for few-shot examples or static instructions:
181
+
182
+ ```python
183
+ agent = Agent(
184
+ model="gpt-4o",
185
+ extra_messages=[
186
+ Message.text_message("Q: What is 2+2?", role="user"),
187
+ Message.text_message("A: 4", role="assistant"),
188
+ ],
189
+ )
190
+ ```
191
+
192
+ ### API style (OpenAI)
193
+
194
+ ```python
195
+ agent = Agent(model="gpt-4o", api_style="chat") # default — Chat Completions
196
+ agent = Agent(model="o4-mini", api_style="responses") # Responses API
197
+ ```
198
+
199
+ ---
200
+
201
+ ## ToolNode
202
+
203
+ `ToolNode` registers and executes callable tools. It supports local Python functions, MCP tools, Composio integrations, and dynamically added tools.
204
+
205
+ ```python
206
+ from tenxgraph.core.graph import ToolNode
207
+
208
+ tool_node = ToolNode([get_weather, safe_calculator])
209
+
210
+ # Add a tool after creation
211
+ tool_node.add_tool(search_db)
212
+ ```
213
+
214
+ ### Tool authoring rules
215
+
216
+ - Docstring → model-facing tool description. Required for useful behavior.
217
+ - Type annotations → parameter schema. Required for correct tool calls.
218
+ - Return a plain value for a normal tool result.
219
+ - Return `ToolResult` to update state fields and return a message to the model.
220
+ - Keep model-visible parameters separate from injected parameters.
221
+
222
+ ### Injectable parameters
223
+
224
+ These are invisible to the model schema — `ToolNode` injects them automatically:
225
+
226
+ | Parameter | Type | What is injected |
227
+ |---|---|---|
228
+ | `state` | `AgentState \| None` | Current graph state |
229
+ | `tool_call_id` | `str \| None` | ID of this specific tool call |
230
+ | `config` | `dict` | Execution config (`thread_id`, `user_id`, `run_id`, …) |
231
+
232
+ ```python
233
+ def get_weather(
234
+ location: str, # from model
235
+ state: AgentState | None = None, # injected, hidden from schema
236
+ config: dict | None = None, # injected, hidden from schema
237
+ ) -> str:
238
+ """Get weather for a location."""
239
+ user = config.get("user_id", "anon") if config else "anon"
240
+ return f"Sunny in {location} (user: {user})"
241
+ ```
242
+
243
+ ### Returning state updates
244
+
245
+ Use `ToolResult` when a tool needs to update state fields and return a message:
246
+
247
+ ```python
248
+ from tenxgraph.core.state.tool_result import ToolResult
249
+
250
+ class MyState(AgentState):
251
+ selected_city: str = ""
252
+
253
+ def select_city(city: str) -> ToolResult:
254
+ """Set the currently selected city."""
255
+ return ToolResult(message=f"City set to '{city}'.", state={"selected_city": city})
256
+ ```
257
+
258
+ ### Filter tools by tag
259
+
260
+ `tools_tags` on `Agent` exposes only matching tools to the LLM:
261
+
262
+ ```python
263
+ @tool(tags=["safe"])
264
+ def safe_search(query: str) -> str: ...
265
+
266
+ @tool(tags=["admin"])
267
+ def admin_action(cmd: str) -> str: ...
268
+
269
+ tool_node = ToolNode([safe_search, admin_action])
270
+ agent = Agent(model="gpt-4o", tool_node=tool_node, tools_tags={"safe"})
271
+ # admin_action is hidden from this agent's model schema
272
+ ```
273
+
274
+ ### MCP tools
275
+
276
+ ```bash
277
+ pip install "10xgraph[mcp]"
278
+ ```
279
+
280
+ ```python
281
+ tool_node = ToolNode(
282
+ [local_fn],
283
+ client=mcp_client, # fastmcp Client
284
+ pass_user_info_to_mcp=True, # forward config["user"] to MCP context
285
+ )
286
+ ```
287
+
288
+ ---
289
+
290
+ ## The `@tool` decorator
291
+
292
+ Attaches metadata to any function. Does not change injection behavior — enriches the model schema:
293
+
294
+ ```python
295
+ from tenxgraph.utils import tool
296
+
297
+ @tool(
298
+ name="web_search",
299
+ description="Search the web for up-to-date information.",
300
+ tags=["search", "web"],
301
+ provider="custom",
302
+ capabilities=["network_access"],
303
+ metadata={"rate_limit": 100},
304
+ )
305
+ async def search_web(query: str, max_results: int = 5) -> list[str]:
306
+ """Search the web."""
307
+ ...
308
+ ```
309
+
310
+ Without arguments: function name and docstring are used as defaults.
311
+
312
+ ---
313
+
314
+ ## ReAct loop
315
+
316
+ Standard routing pattern. The routing function inspects the last message:
317
+
318
+ ```python
319
+ from tenxgraph.utils import END
320
+
321
+ def route(state: AgentState) -> str:
322
+ if not state.context:
323
+ return END
324
+ last = state.context[-1]
325
+ if hasattr(last, "tools_calls") and last.tools_calls and last.role == "assistant":
326
+ return "TOOL"
327
+ if last.role == "tool":
328
+ return "MAIN"
329
+ return END
330
+
331
+ graph.add_conditional_edges("MAIN", route, {"TOOL": "TOOL", END: END})
332
+ graph.add_edge("TOOL", "MAIN")
333
+ ```
334
+
335
+ ### Passing tool_node by name
336
+
337
+ Pass a string to share one `ToolNode` across multiple agents:
338
+
339
+ ```python
340
+ agent = Agent(model="gpt-4o", tool_node="TOOL")
341
+ graph.add_node("MAIN", agent)
342
+ graph.add_node("TOOL", tool_node)
343
+ ```
344
+
345
+ ---
346
+
347
+ ## Skills (Agent Skills specification)
348
+
349
+ `skills=SkillConfig(...)` loads skills that follow https://agentskills.io/specification: one
350
+ directory per skill with a `SKILL.md` (YAML frontmatter `name` + `description`, optional
351
+ `license`, `compatibility`, `allowed-tools`, `metadata`) and optional `scripts/`, `references/`,
352
+ `assets/`.
353
+
354
+ ```python
355
+ from tenxgraph.core.skills import SkillConfig
356
+
357
+ agent = Agent(
358
+ model="gpt-4o",
359
+ tool_node=ToolNode([]),
360
+ skills=SkillConfig(skills_dir=["./.agents/skills", "./shared-skills"]),
361
+ )
362
+ ```
363
+
364
+ - On-demand mode (default) adds an `<available_skills>` catalog (name + description) to the
365
+ system prompt and registers `activate_skill(skill_name)`. The result is the SKILL.md body in
366
+ `<skill_content name="...">` tags plus a `<skill_resources>` file list.
367
+ - `read_skill_resource(skill_name, path)` is registered when any skill bundles files. It reads any
368
+ file in the skill directory as text (markdown, `.py`, `.sh`, JSON, ...); nothing is executed.
369
+ - `mode="session", preload_from="FIELD"` injects the skill named by `state.FIELD` every call.
370
+ - Activated skills are recorded in `state.execution_meta.internal_data["active_skills"]` and are
371
+ re-injected if context trimming drops their tool result.
372
+ - 10xGraph extensions live in `metadata` as strings: `triggers: "a; b"`, `tags: "x, y"`,
373
+ `priority: "10"`.
374
+ - `SkillConfig` options: `skills_dir` (path or ordered list; earlier wins on name clashes),
375
+ `inject_catalog`, `hot_reload`, `max_resource_bytes`, `include_skill_path`, `mode`,
376
+ `preload_from`.
377
+ - Validate with `10xgraph skills --validate PATH` or `tenxgraph.core.skills.validate_skill`.
378
+
379
+ ---
380
+
381
+ ## Source map
382
+
383
+ - Agent: https://github.com/10xGraph/10xGraph/blob/main/tenxgraph/core/graph/agent.py
384
+ - ToolNode: https://github.com/10xGraph/10xGraph/tree/main/tenxgraph/core/graph
385
+ - ToolResult: https://github.com/10xGraph/10xGraph/blob/main/tenxgraph/core/state/tool_result.py
386
+ - RetryConfig: https://github.com/10xGraph/10xGraph/blob/main/tenxgraph/core/graph/agent_internal/constants.py
387
+ - `@tool` decorator: https://github.com/10xGraph/10xGraph/blob/main/tenxgraph/utils/decorators.py
388
+ - Skills: https://github.com/10xGraph/10xGraph/tree/main/tenxgraph/core/skills
389
+ - How-to (configure Agent): https://10xgraph.com/how-to/python/configure-agent
@@ -0,0 +1,61 @@
1
+ # API and TypeScript Client
2
+
3
+ Use this when aligning REST routes, schemas, generated docs, or the TypeScript npm SDK. The public npm package is `@10xscale/agentflow-client`; install it with `npm install @10xscale/agentflow-client`.
4
+
5
+ Check current docs first: https://10xgraph.com/
6
+
7
+ ## API Routers
8
+
9
+ Active routers are included from https://github.com/10xGraph/10xgraph-api/blob/main/tenxgraph_api/src/app/routers/setup_router.py:
10
+
11
+ - Graph router
12
+ - Checkpointer/thread router
13
+ - Store router
14
+ - Ping router
15
+ - Media/files router
16
+
17
+ Graph routes include:
18
+
19
+ - `POST /v1/graph/invoke`
20
+ - `POST /v1/graph/stream`
21
+ - `GET /v1/graph`
22
+ - `GET /v1/graph:StateSchema`
23
+ - `POST /v1/graph/stop`
24
+ - `POST /v1/graph/fix`
25
+
26
+ Memory/file routes are summarized in their topic references.
27
+
28
+ ## TypeScript SDK Facade
29
+
30
+ `AgentFlowClient` is exported by `@10xscale/agentflow-client`. Its source facade is https://github.com/10xHub/agentflow-client/blob/main/src/client.ts, and it wraps:
31
+
32
+ - Connectivity and metadata: `ping`, `graph`, `graphStateSchema`
33
+ - Execution: `invoke`, `stream`, `stopGraph`, `fixGraph`
34
+ - Threads/messages: `threadState`, `updateThreadState`, `clearThreadState`, `threadDetails`, `threads`, `threadMessages`, `addThreadMessages`, `singleMessage`, `deleteMessage`, `deleteThread`
35
+ - Memory: `storeMemory`, `searchMemory`, `getMemory`, `updateMemory`, `deleteMemory`, `listMemories`, `forgetMemories`
36
+ - Files: `uploadFile`, `getFile`, `getFileInfo`, `getFileAccessUrl`, `getMultimodalConfig`
37
+ - Remote tools: schemas in server `10xgraph.json`, handlers via `registerToolHandler`
38
+
39
+ For remote tools, read `remote-tools.md`; that flow has a client-managed execution loop around `remote_tool_call` blocks.
40
+
41
+ ## Request Conventions
42
+
43
+ - The client serializes `Message` instances to plain API payloads.
44
+ - Server expects message content as an array of content blocks.
45
+ - `message_id` is sent as a string; `"0"` lets the server generate/normalize where applicable.
46
+ - `recursion_limit` defaults to `25`.
47
+ - Streaming defaults to low response granularity in the client.
48
+
49
+ ## Rules
50
+
51
+ - Use `@10xscale/agentflow-client` in user-facing examples and docs.
52
+ - The TypeScript SDK calls a running 10xGraph API server. It does not import or execute Python graph code.
53
+ - Keep endpoint schema changes mirrored in the client endpoints directory.
54
+ - Test both endpoint helpers and the `AgentFlowClient` facade for client-visible changes.
55
+
56
+ ## Source Map
57
+
58
+ - Client facade: https://github.com/10xHub/agentflow-client/blob/main/src/client.ts
59
+ - Client endpoints: https://github.com/10xHub/agentflow-client/tree/main/src/endpoints
60
+ - Client message model: https://github.com/10xHub/agentflow-client/blob/main/src/message.ts
61
+ - API schemas/services: https://github.com/10xGraph/10xgraph-api/tree/main/tenxgraph_api/src/app/routers
@@ -0,0 +1,75 @@
1
+ # API Configuration
2
+
3
+ Use this when changing `10xgraph.json`, dependency loading, app startup, or graph import behavior.
4
+
5
+ ## `10xgraph.json`
6
+
7
+ Minimal:
8
+
9
+ ```json
10
+ {
11
+ "agent": "graph.react:app"
12
+ }
13
+ ```
14
+
15
+ Common full shape:
16
+
17
+ ```json
18
+ {
19
+ "agent": "graph.react:app",
20
+ "checkpointer": "graph.dependencies:my_checkpointer",
21
+ "store": "graph.dependencies:my_store",
22
+ "injectq": "graph.dependencies:container",
23
+ "thread_name_generator": "graph.thread_name_generator:MyNameGenerator",
24
+ "authorization": "graph.auth:my_authorization_backend",
25
+ "env": ".env",
26
+ "auth": "jwt",
27
+ "remote_tools": [],
28
+ "rate_limit": {
29
+ "enabled": true,
30
+ "backend": "memory",
31
+ "requests": 100,
32
+ "window": 60,
33
+ "by": "ip",
34
+ "exclude_paths": ["/ping", "/docs", "/redoc", "/openapi.json"]
35
+ }
36
+ }
37
+ ```
38
+
39
+ ## Fields
40
+
41
+ - `agent`: required import path to a compiled graph variable, in `module.path:attribute` format.
42
+ - `checkpointer`: optional import path to a `BaseCheckpointer` instance.
43
+ - `store`: optional import path to a `BaseStore` instance; required for store endpoints.
44
+ - `injectq`: optional import path to an `InjectQ` container.
45
+ - `thread_name_generator`: optional import path to a thread-name generator class/instance.
46
+ - `authorization`: `null` (mode default: `ownership` in production, `allow_all` in dev), a built-in name (`"ownership"` | `"allow_all"`/`"default"`/`"none"`), an RBAC config object (`{"backend": "rbac", "roles": {...}, "default_scopes": [...], "isolation": "owner"}`), or a `module:attr` import path to a custom `AuthorizationBackend`. See `references/auth-and-authorization.md`.
47
+ - `env`: optional `.env` path loaded before graph import.
48
+ - `auth`: `null`, `"jwt"`, or `{"method": "custom", "path": "module:backend"}`.
49
+ - `remote_tools`: validated client-executed tool schemas, attached once at startup.
50
+ - `rate_limit`: optional sliding-window rate limiter config object; omit or set to `null` to disable. See `references/rate-limiting.md` for the full field reference.
51
+
52
+ ## Loading Order
53
+
54
+ 1. Read `10xgraph.json`.
55
+ 2. Load `.env` when configured.
56
+ 3. Import the compiled graph from `agent`.
57
+ 4. Attach `remote_tools`, then import and bind `checkpointer`, `store`, `injectq`, `thread_name_generator`, and `authorization` when configured.
58
+ 5. Configure auth.
59
+ 6. Start FastAPI routes and services.
60
+
61
+ ## Rules
62
+
63
+ - Keep graph modules importable from the project root.
64
+ - Keep `agent` pointing to a compiled graph object, not an uncompiled `StateGraph`.
65
+ - Keep dependency modules side-effect light.
66
+ - Load secrets through `.env` or process environment, not committed config.
67
+ - Validate import paths early and surface clear CLI/API errors.
68
+
69
+ ## Source Map
70
+
71
+ - Graph config: https://github.com/10xGraph/10xgraph-api/blob/main/tenxgraph_api/src/app/core/config/graph_config.py
72
+ - Loader: https://github.com/10xGraph/10xgraph-api/blob/main/tenxgraph_api/src/app/loader.py
73
+ - App startup: https://github.com/10xGraph/10xgraph-api/blob/main/tenxgraph_api/src/app/main.py
74
+ - Docs: https://10xgraph.com/
75
+ - Rate limit config details: `references/rate-limiting.md`
@@ -0,0 +1,89 @@
1
+ # API Settings and Middleware
2
+
3
+ Use this when changing environment variables, app settings, middleware, CORS, request limits, security headers, docs paths, or Sentry.
4
+
5
+ ## Settings
6
+
7
+ `Settings` reads environment variables through Pydantic settings.
8
+
9
+ Important variables:
10
+
11
+ - `APP_NAME`
12
+ - `APP_VERSION`
13
+ - `MODE`
14
+ - `LOG_LEVEL`
15
+ - `IS_DEBUG`
16
+ - `MAX_REQUEST_SIZE`
17
+ - `ORIGINS`
18
+ - `ALLOWED_HOST`
19
+ - `ROOT_PATH`
20
+ - `DOCS_PATH`
21
+ - `REDOCS_PATH`
22
+ - `REDIS_URL`
23
+ - `SENTRY_DSN`
24
+ - `JWT_SECRET_KEY`
25
+ - `JWT_ALGORITHM`
26
+
27
+ Security header variables:
28
+
29
+ - `SECURITY_HEADERS_ENABLED`
30
+ - `HSTS_ENABLED`
31
+ - `HSTS_MAX_AGE`
32
+ - `HSTS_INCLUDE_SUBDOMAINS`
33
+ - `HSTS_PRELOAD`
34
+ - `FRAME_OPTIONS`
35
+ - `CONTENT_TYPE_OPTIONS`
36
+ - `XSS_PROTECTION`
37
+ - `REFERRER_POLICY`
38
+ - `PERMISSIONS_POLICY`
39
+ - `CSP_POLICY`
40
+
41
+ ## Middleware
42
+
43
+ Active middleware areas:
44
+
45
+ - CORS and host handling.
46
+ - Request size limits.
47
+ - Security headers.
48
+ - Request ID assignment.
49
+ - Selective gzip behavior; streaming endpoints should avoid gzip buffering when configured.
50
+ - Worker middleware where used by deployment.
51
+ - Rate limiting: sliding-window limiter controlled by the `rate_limit` block in `10xgraph.json`.
52
+ Uses an in-process `memory` backend by default; use the `redis` backend (requires
53
+ `pip install "10xgraph-api[redis]"`) for multi-worker or multi-instance deployments.
54
+ Excluded paths, identity mode (`ip` or `global`), and `fail_open` behavior are all configurable.
55
+ See `references/rate-limiting.md` for the full option reference.
56
+
57
+ ## Production Warnings
58
+
59
+ Production mode warns about unsafe defaults such as:
60
+
61
+ - `ORIGINS=*`
62
+ - debug enabled
63
+ - docs endpoints enabled
64
+ - `ALLOWED_HOST=*`
65
+
66
+ ## Sentry
67
+
68
+ `SENTRY_DSN` enables Sentry setup through the API config module. Keep error reporting optional and safe when unset.
69
+
70
+ ## Rules
71
+
72
+ - Keep environment variable docs in sync with `Settings`.
73
+ - Use `ROOT_PATH` when serving behind a reverse proxy subpath.
74
+ - Disable or protect docs paths in production when needed.
75
+ - Do not gzip SSE streams.
76
+ - Sanitize logs for tokens, secrets, and large payloads.
77
+
78
+ ## Source Map
79
+
80
+ - Settings: https://github.com/10xGraph/10xgraph-api/blob/main/tenxgraph_api/src/app/core/config/settings.py
81
+ - Middleware setup: https://github.com/10xGraph/10xgraph-api/blob/main/tenxgraph_api/src/app/core/config/setup_middleware.py
82
+ - Request limits: https://github.com/10xGraph/10xgraph-api/blob/main/tenxgraph_api/src/app/core/middleware/request_limits.py
83
+ - Security headers: https://github.com/10xGraph/10xgraph-api/blob/main/tenxgraph_api/src/app/core/middleware/security_headers.py
84
+ - Rate limit middleware: https://github.com/10xGraph/10xgraph-api/tree/main/tenxgraph_api/src/app/core/middleware/rate_limit
85
+ - Rate limit base class: https://github.com/10xGraph/10xgraph-api/blob/main/tenxgraph_api/src/app/core/middleware/rate_limit/base.py
86
+ - Sentry: https://github.com/10xGraph/10xgraph-api/blob/main/tenxgraph_api/src/app/core/config/sentry_config.py
87
+ - Log sanitizer: https://github.com/10xGraph/10xgraph-api/blob/main/tenxgraph_api/src/app/core/utils/log_sanitizer.py
88
+ - Docs: https://10xgraph.com/
89
+ - Rate limiting docs: https://github.com/10xGraph/10xgraph-api/blob/main/docs/rate-limiting.md