smith-agents 0.11.0 → 0.12.1

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 (193) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +712 -0
  3. data/README.md +622 -15
  4. data/UPSTREAM_PROPOSAL.md +1 -0
  5. data/docs/CONFIGURATION.md +80 -14
  6. data/docs/PATTERNS.md +30 -13
  7. data/docs/PERSISTENCE.md +733 -5
  8. data/docs/TOOLS_AND_GUARDRAILS.md +24 -3
  9. data/lib/generators/smith/install/install_generator.rb +67 -2
  10. data/lib/generators/smith/install/templates/create_workflow_states.rb.tt +31 -0
  11. data/lib/generators/smith/install/templates/smith.rb.tt +39 -8
  12. data/lib/generators/smith/install/templates/workflow_state.rb.tt +19 -0
  13. data/lib/smith/agent/completion.rb +32 -6
  14. data/lib/smith/agent/completion_usage_recording.rb +23 -14
  15. data/lib/smith/agent/content_bytes.rb +98 -0
  16. data/lib/smith/agent/content_parts.rb +149 -0
  17. data/lib/smith/agent/invocation_preparation.rb +37 -14
  18. data/lib/smith/agent/lifecycle.rb +16 -5
  19. data/lib/smith/agent/observed_model.rb +29 -0
  20. data/lib/smith/agent/output_contract_check.rb +53 -0
  21. data/lib/smith/agent/output_integrity.rb +137 -0
  22. data/lib/smith/agent/output_policy.rb +92 -0
  23. data/lib/smith/agent/output_recovery.rb +129 -0
  24. data/lib/smith/agent/provider_attempt.rb +6 -0
  25. data/lib/smith/agent/provider_call_timing.rb +13 -4
  26. data/lib/smith/agent/provider_completion.rb +35 -32
  27. data/lib/smith/agent/provider_failure_handling.rb +5 -1
  28. data/lib/smith/agent/provider_request.rb +36 -0
  29. data/lib/smith/agent/provider_streaming.rb +155 -0
  30. data/lib/smith/agent/provider_usage.rb +70 -3
  31. data/lib/smith/agent/usage_entry_recording.rb +4 -2
  32. data/lib/smith/agent/usage_traces.rb +9 -2
  33. data/lib/smith/agent/usage_tracking.rb +64 -51
  34. data/lib/smith/agent.rb +5 -0
  35. data/lib/smith/artifacts/active_record_store.rb +79 -0
  36. data/lib/smith/artifacts/file.rb +45 -18
  37. data/lib/smith/artifacts/memory.rb +47 -36
  38. data/lib/smith/artifacts/s3.rb +126 -0
  39. data/lib/smith/artifacts/scoped_store.rb +55 -7
  40. data/lib/smith/artifacts/store_rules.rb +49 -0
  41. data/lib/smith/artifacts.rb +98 -1
  42. data/lib/smith/batch/message_shape.rb +36 -0
  43. data/lib/smith/batch.rb +166 -0
  44. data/lib/smith/budget/amount.rb +25 -0
  45. data/lib/smith/budget/continuation.rb +153 -0
  46. data/lib/smith/budget/host_ledger.rb +137 -0
  47. data/lib/smith/budget/ledger.rb +4 -2
  48. data/lib/smith/budget/ledger_state_transition.rb +7 -5
  49. data/lib/smith/budget/request_hold.rb +211 -0
  50. data/lib/smith/budget/spent_reservation.rb +18 -0
  51. data/lib/smith/child_run.rb +41 -0
  52. data/lib/smith/child_runs_failed.rb +56 -0
  53. data/lib/smith/content.rb +96 -0
  54. data/lib/smith/context/session.rb +14 -2
  55. data/lib/smith/context/state_injection.rb +10 -5
  56. data/lib/smith/context.rb +28 -0
  57. data/lib/smith/doctor/checks/artifacts.rb +103 -0
  58. data/lib/smith/doctor/checks/configuration.rb +0 -11
  59. data/lib/smith/doctor/checks/durability.rb +20 -18
  60. data/lib/smith/doctor/checks/state_model.rb +63 -0
  61. data/lib/smith/doctor/installer.rb +9 -2
  62. data/lib/smith/doctor.rb +4 -0
  63. data/lib/smith/errors.rb +249 -2
  64. data/lib/smith/idempotency_key/canonical.rb +74 -0
  65. data/lib/smith/idempotency_key.rb +145 -0
  66. data/lib/smith/launchers/inline.rb +46 -0
  67. data/lib/smith/message.rb +76 -0
  68. data/lib/smith/models/tool_routing.rb +47 -44
  69. data/lib/smith/output_failure.rb +130 -0
  70. data/lib/smith/persistence_adapters/active_record_exact_store.rb +43 -0
  71. data/lib/smith/pricing/catalog_validation.rb +91 -0
  72. data/lib/smith/pricing.rb +95 -64
  73. data/lib/smith/providers/anthropic/batches.rb +116 -0
  74. data/lib/smith/providers/batch_exchange.rb +77 -0
  75. data/lib/smith/providers/openai/responses.rb +45 -20
  76. data/lib/smith/providers/output_limit.rb +68 -0
  77. data/lib/smith/providers/request_holds.rb +139 -0
  78. data/lib/smith/providers/response_facts.rb +108 -0
  79. data/lib/smith/providers/schema_constraint_check.rb +141 -0
  80. data/lib/smith/providers/schema_constraints.rb +87 -0
  81. data/lib/smith/providers/schema_rules.rb +66 -0
  82. data/lib/smith/providers/stop_reason.rb +39 -0
  83. data/lib/smith/providers/stream_facts.rb +192 -0
  84. data/lib/smith/response_memo.rb +152 -0
  85. data/lib/smith/setting_constructors.rb +47 -0
  86. data/lib/smith/streaming/json_field.rb +136 -0
  87. data/lib/smith/streaming/json_string.rb +91 -0
  88. data/lib/smith/streaming/session.rb +77 -0
  89. data/lib/smith/streaming/think_tags.rb +67 -0
  90. data/lib/smith/streaming.rb +64 -0
  91. data/lib/smith/testing/checks.rb +58 -0
  92. data/lib/smith/testing/hooks.rb +85 -0
  93. data/lib/smith/testing/minitest.rb +37 -0
  94. data/lib/smith/testing/rspec.rb +52 -0
  95. data/lib/smith/testing/stub.rb +110 -0
  96. data/lib/smith/testing.rb +158 -0
  97. data/lib/smith/tool/scoped_context.rb +9 -12
  98. data/lib/smith/tool.rb +14 -0
  99. data/lib/smith/trace/logger.rb +1 -1
  100. data/lib/smith/trace/memory.rb +1 -1
  101. data/lib/smith/trace/open_telemetry.rb +1 -1
  102. data/lib/smith/trace.rb +11 -4
  103. data/lib/smith/untrusted.rb +74 -0
  104. data/lib/smith/version.rb +2 -2
  105. data/lib/smith/workflow/active_clock.rb +61 -0
  106. data/lib/smith/workflow/agent_result.rb +37 -0
  107. data/lib/smith/workflow/artifact_integration.rb +57 -7
  108. data/lib/smith/workflow/await_step.rb +42 -0
  109. data/lib/smith/workflow/batch_charges.rb +74 -0
  110. data/lib/smith/workflow/batch_execution.rb +149 -0
  111. data/lib/smith/workflow/batch_holds.rb +73 -0
  112. data/lib/smith/workflow/batch_wait.rb +134 -0
  113. data/lib/smith/workflow/budget_integration.rb +11 -5
  114. data/lib/smith/workflow/budget_pause.rb +51 -0
  115. data/lib/smith/workflow/child_run_declarations.rb +127 -0
  116. data/lib/smith/workflow/child_run_execution.rb +150 -0
  117. data/lib/smith/workflow/child_run_results.rb +55 -0
  118. data/lib/smith/workflow/composite/effects.rb +37 -6
  119. data/lib/smith/workflow/composite/error.rb +1 -1
  120. data/lib/smith/workflow/composite/error_evidence.rb +9 -9
  121. data/lib/smith/workflow/composite/input.rb +11 -4
  122. data/lib/smith/workflow/context_keys.rb +77 -0
  123. data/lib/smith/workflow/deadline_enforcement.rb +1 -1
  124. data/lib/smith/workflow/deterministic_execution.rb +61 -10
  125. data/lib/smith/workflow/deterministic_step.rb +55 -6
  126. data/lib/smith/workflow/dsl.rb +59 -0
  127. data/lib/smith/workflow/durability.rb +139 -30
  128. data/lib/smith/workflow/evaluator_optimizer.rb +12 -6
  129. data/lib/smith/workflow/event_integration.rb +9 -0
  130. data/lib/smith/workflow/execution.rb +30 -23
  131. data/lib/smith/workflow/execution_binding_resolution.rb +13 -0
  132. data/lib/smith/workflow/failure_reconstructor.rb +27 -4
  133. data/lib/smith/workflow/failure_record.rb +6 -1
  134. data/lib/smith/workflow/failure_record_validator.rb +11 -4
  135. data/lib/smith/workflow/fanout_execution.rb +5 -8
  136. data/lib/smith/workflow/graph/batch_diagnostic.rb +83 -0
  137. data/lib/smith/workflow/graph/branch_limit_diagnostic.rb +41 -0
  138. data/lib/smith/workflow/graph/budget_ledger_diagnostic.rb +126 -0
  139. data/lib/smith/workflow/graph/durable_retry_diagnostic.rb +50 -0
  140. data/lib/smith/workflow/graph/execution_successors.rb +16 -2
  141. data/lib/smith/workflow/graph/inherited_untrusted_diagnostics.rb +77 -0
  142. data/lib/smith/workflow/graph/isolated_input_diagnostic.rb +50 -0
  143. data/lib/smith/workflow/graph/nested_readiness_diagnostics.rb +43 -4
  144. data/lib/smith/workflow/graph/output_key_diagnostic.rb +53 -0
  145. data/lib/smith/workflow/graph/output_schema_diagnostic.rb +49 -0
  146. data/lib/smith/workflow/graph/retry_policy_diagnostic.rb +1 -0
  147. data/lib/smith/workflow/graph/run_launcher_diagnostic.rb +30 -0
  148. data/lib/smith/workflow/graph/runtime_binding_diagnostic_builder.rb +9 -3
  149. data/lib/smith/workflow/graph/runtime_binding_diagnostics.rb +7 -3
  150. data/lib/smith/workflow/graph/runtime_readiness_metrics.rb +8 -1
  151. data/lib/smith/workflow/graph/runtime_readiness_report_builder.rb +9 -2
  152. data/lib/smith/workflow/graph/runtime_readiness_traversal.rb +7 -4
  153. data/lib/smith/workflow/graph/stream_diagnostic.rb +95 -0
  154. data/lib/smith/workflow/graph/transition_contract.rb +19 -0
  155. data/lib/smith/workflow/graph/transition_contract_attributes.rb +25 -2
  156. data/lib/smith/workflow/graph/transition_contract_configurations.rb +24 -3
  157. data/lib/smith/workflow/graph/transition_diagnostics.rb +11 -24
  158. data/lib/smith/workflow/graph/transition_snapshot.rb +40 -39
  159. data/lib/smith/workflow/graph/untrusted_input_diagnostic.rb +57 -0
  160. data/lib/smith/workflow/graph/waiting_child_diagnostic.rb +24 -0
  161. data/lib/smith/workflow/graph.rb +12 -0
  162. data/lib/smith/workflow/guarded_step_execution.rb +48 -3
  163. data/lib/smith/workflow/message_batch.rb +6 -0
  164. data/lib/smith/workflow/message_roles.rb +25 -0
  165. data/lib/smith/workflow/message_value_normalizer.rb +2 -1
  166. data/lib/smith/workflow/nested_execution.rb +47 -4
  167. data/lib/smith/workflow/orchestrator_worker.rb +9 -3
  168. data/lib/smith/workflow/parallel_execution.rb +10 -0
  169. data/lib/smith/workflow/persistence.rb +136 -13
  170. data/lib/smith/workflow/remembered_calls.rb +92 -0
  171. data/lib/smith/workflow/retry_execution.rb +68 -9
  172. data/lib/smith/workflow/retry_wait.rb +134 -0
  173. data/lib/smith/workflow/split_step_persistence/checkpoint.rb +3 -0
  174. data/lib/smith/workflow/split_step_persistence/checkpoint_state.rb +7 -0
  175. data/lib/smith/workflow/split_step_persistence/composite_branch_execution.rb +4 -1
  176. data/lib/smith/workflow/split_step_persistence/composite_preparation.rb +3 -1
  177. data/lib/smith/workflow/split_step_persistence/dispatch_claim.rb +1 -0
  178. data/lib/smith/workflow/split_step_persistence/preparation.rb +5 -0
  179. data/lib/smith/workflow/split_step_persistence/state_snapshot.rb +1 -0
  180. data/lib/smith/workflow/step_completion.rb +36 -7
  181. data/lib/smith/workflow/step_context.rb +21 -0
  182. data/lib/smith/workflow/step_io.rb +132 -0
  183. data/lib/smith/workflow/step_stream.rb +52 -0
  184. data/lib/smith/workflow/thread_context_snapshot.rb +2 -0
  185. data/lib/smith/workflow/transition.rb +267 -13
  186. data/lib/smith/workflow/transition_actionability.rb +2 -0
  187. data/lib/smith/workflow/usage_entry.rb +24 -3
  188. data/lib/smith/workflow/wait_completion.rb +131 -0
  189. data/lib/smith/workflow/wait_execution.rb +180 -0
  190. data/lib/smith/workflow/wait_record.rb +157 -0
  191. data/lib/smith/workflow.rb +113 -17
  192. data/lib/smith.rb +101 -45
  193. metadata +88 -1
data/lib/smith.rb CHANGED
@@ -4,33 +4,16 @@ require "dry-configurable"
4
4
 
5
5
  require_relative "smith/version"
6
6
  require_relative "smith/error"
7
+ require_relative "smith/setting_constructors"
7
8
 
8
9
  module Smith
9
10
  extend Dry::Configurable
10
11
 
11
- positive_integer_setting = lambda do |name|
12
- lambda do |value|
13
- unless value.is_a?(Integer) && value.positive?
14
- raise ArgumentError, "Smith.config.#{name} must be a positive integer, got #{value.inspect}"
15
- end
16
-
17
- value
18
- end
19
- end
20
-
21
- bounded_positive_integer_setting = lambda do |name, maximum|
22
- lambda do |value|
23
- unless value.is_a?(Integer) && value.positive? && value <= maximum
24
- message = "Smith.config.#{name} must be a positive integer no greater than #{maximum}"
25
- raise ArgumentError, "#{message}, got #{value.inspect}"
26
- end
27
-
28
- value
29
- end
30
- end
31
-
32
- # Artifact store (§4.7)
12
+ # Artifact store (§4.7): a store, a store class, or :s3, :active_record,
13
+ # :file or :memory, built with artifact_options. Required outside
14
+ # test_mode (Smith::Artifacts).
33
15
  setting :artifact_store
16
+ setting :artifact_options, default: {}.freeze
34
17
  setting :artifact_retention
35
18
  setting :artifact_encryption, default: :none
36
19
  setting :artifact_tenant_isolation, default: false
@@ -64,6 +47,52 @@ module Smith
64
47
  # Per-workflow `Workflow.persistence_ttl 1.day.to_i` DSL overrides this.
65
48
  setting :persistence_ttl, default: nil
66
49
 
50
+ # The most bytes a stored workflow state may take, or nil for no bound.
51
+ # A state past it is refused before anything is written
52
+ # (Smith::PersistedStateTooLarge). A database CHECK on the payload column
53
+ # (`rails g smith:install` writes one) bounds the stored bytes the same.
54
+ setting :persistence_max_bytes,
55
+ default: nil, constructor: SettingConstructors.optional_positive_integer(:persistence_max_bytes)
56
+
57
+ # Starts the runs `map`, `call` and `spawn` steps launch:
58
+ # `launch(children:, parent_key:, await_token:)`, idempotent on each
59
+ # `child.key`. Smith::Launchers::Inline runs them in process.
60
+ setting :run_launcher, default: nil
61
+
62
+ # The sinks `execute Agent, stream: :name` steps stream to, by name
63
+ # (Smith::Streaming): callables that take a step's info and return its
64
+ # sink (or nil), an object with any of start(info), delta(text),
65
+ # reset(reason), finish(output) and fail(error_class).
66
+ setting :stream_sinks, default: {}.freeze, constructor: ->(sinks) { Smith::Streaming.check_sinks!(sinks) }
67
+
68
+ # Takes the requests `mode: :batch` steps send (Smith::Batch):
69
+ # `enqueue(custom_id:, await_token:, request:, execution_key:)`, idempotent
70
+ # on `custom_id`. The host submits them and resumes each run with its
71
+ # results.
72
+ setting :batch_queue, default: nil, constructor: SettingConstructors.adapter(
73
+ :batch_queue, { enqueue: "enqueue(custom_id:, await_token:, request:, execution_key:)" }
74
+ )
75
+
76
+ # Keeps what a step's provider calls got (Smith::ResponseMemo), so a step
77
+ # replayed after its process died reuses it instead of paying again.
78
+ setting :response_memo, default: nil, constructor: SettingConstructors.adapter(
79
+ :response_memo, { fetch: "fetch(key)", store: "store(key, record)" }
80
+ )
81
+
82
+ # How long a provider request's hold on a host's budget ledger
83
+ # (`budget_ledger`) lasts unsettled, in seconds: past it the request's
84
+ # process is taken to have died, and the ledger drops the hold. It must
85
+ # outlast the longest request (its retries and stream included). A batch
86
+ # request's hold lasts its wait (25 hours) longer.
87
+ setting :budget_hold_ttl, default: 3600, constructor: SettingConstructors.positive_integer(:budget_hold_ttl)
88
+
89
+ # The most output tokens a request's hold counts, or nil for its own cap
90
+ # (`max_tokens`, else the model's maximum, which can be tens of thousands
91
+ # for an agent that sets none). Only the hold changes, not the request: a
92
+ # longer reply is reconciled at what it cost, past its hold.
93
+ setting :budget_hold_output_tokens,
94
+ default: nil, constructor: SettingConstructors.optional_positive_integer(:budget_hold_output_tokens)
95
+
67
96
  # Retry policy for transient persistence I/O failures.
68
97
  # attempts: total attempts (including the first)
69
98
  # base_delay: initial sleep between attempts, doubled each retry
@@ -72,12 +101,13 @@ module Smith
72
101
 
73
102
  # Generic runtime resource bounds. Branch concurrency is scoped to one
74
103
  # parallel execution; hosts retain control over process-level concurrency.
75
- setting :parallel_branch_limit, default: 1_000, constructor: positive_integer_setting.call(:parallel_branch_limit)
76
- setting :parallel_concurrency, default: 8, constructor: positive_integer_setting.call(:parallel_concurrency)
77
- setting :parallel_nesting_limit, default: 64, constructor: bounded_positive_integer_setting.call(
104
+ setting :parallel_branch_limit,
105
+ default: 1_000, constructor: SettingConstructors.positive_integer(:parallel_branch_limit)
106
+ setting :parallel_concurrency, default: 8, constructor: SettingConstructors.positive_integer(:parallel_concurrency)
107
+ setting :parallel_nesting_limit, default: 64, constructor: SettingConstructors.bounded_positive_integer(
78
108
  :parallel_nesting_limit, 256
79
109
  )
80
- setting :retry_attempt_limit, default: 100, constructor: positive_integer_setting.call(:retry_attempt_limit)
110
+ setting :retry_attempt_limit, default: 100, constructor: SettingConstructors.positive_integer(:retry_attempt_limit)
81
111
 
82
112
  # Test isolation: when true AND persistence_adapter is nil, Smith
83
113
  # auto-selects the in-process Memory adapter. Lets specs avoid wiring
@@ -95,9 +125,9 @@ module Smith
95
125
  # Default :auto reflects the "use both when possible" design intent.
96
126
  # Smith ships the Responses adapter vendored from crmne/ruby_llm PR #770
97
127
  # at a pinned SHA, so the routing path is operational for sync
98
- # completions. Streaming over /v1/responses is not yet supported and
99
- # raises NotImplementedError; hosts who need streaming with the
100
- # (gpt-5 + tools + thinking) combo should set openai_api_mode = :off
128
+ # completions. It does not stream: a streamed call gets the whole reply
129
+ # as one chunk. Hosts who need token streaming with the
130
+ # (gpt-5 + tools + thinking) combo can set openai_api_mode = :off
101
131
  # for graceful tool-dropping via chat-completions.
102
132
  setting :openai_api_mode, default: :auto, constructor: lambda { |value|
103
133
  unless %i[off auto].include?(value)
@@ -115,22 +145,6 @@ module Smith
115
145
  # Logger (§7 — Ruby Logger, not Rails.logger)
116
146
  setting :logger, default: nil
117
147
 
118
- def self.artifacts
119
- scoped_artifacts || config.artifact_store || (@_default_artifacts ||= Artifacts::Memory.new)
120
- end
121
-
122
- def self.artifacts=(store)
123
- config.artifact_store = store
124
- end
125
-
126
- def self.scoped_artifacts
127
- Thread.current[:smith_scoped_artifacts]
128
- end
129
-
130
- def self.scoped_artifacts=(store)
131
- Thread.current[:smith_scoped_artifacts] = store
132
- end
133
-
134
148
  def self.persistence_adapter
135
149
  raw_adapter = config.persistence_adapter
136
150
  raw_options = config.persistence_options || {}
@@ -181,6 +195,11 @@ end
181
195
  # Leaf modules (no internal dependencies)
182
196
  require_relative "smith/types"
183
197
  require_relative "smith/errors"
198
+ require_relative "smith/output_failure"
199
+ require_relative "smith/child_runs_failed"
200
+ require_relative "smith/providers/stop_reason"
201
+ require_relative "smith/providers/output_limit"
202
+ require_relative "smith/providers/schema_constraints"
184
203
  require_relative "smith/tool_failure_notification_failed"
185
204
  require_relative "smith/persistence_payload_conflict"
186
205
  require_relative "smith/exponential_backoff"
@@ -196,6 +215,10 @@ require_relative "smith/events/step_failed"
196
215
  # Budget (depends on Errors)
197
216
  require_relative "smith/budget"
198
217
  require_relative "smith/budget/ledger"
218
+ require_relative "smith/budget/host_ledger"
219
+ require_relative "smith/budget/request_hold"
220
+ require_relative "smith/budget/continuation"
221
+ require_relative "smith/response_memo"
199
222
 
200
223
  # Pricing (depends on Smith config)
201
224
  require_relative "smith/pricing"
@@ -234,17 +257,31 @@ require_relative "smith/trace/memory"
234
257
  require_relative "smith/trace/logger"
235
258
  require_relative "smith/trace/open_telemetry"
236
259
 
260
+ # Streaming and batch mode (no internal deps)
261
+ require_relative "smith/streaming"
262
+ require_relative "smith/providers/stream_facts"
263
+ require_relative "smith/batch"
264
+ require_relative "smith/providers/batch_exchange"
265
+ require_relative "smith/providers/request_holds"
266
+ require_relative "smith/providers/anthropic/batches"
267
+
237
268
  # Artifact store (no internal deps)
238
269
  require_relative "smith/artifacts"
239
270
  require_relative "smith/artifacts/memory"
240
271
  require_relative "smith/artifacts/file"
241
272
  require_relative "smith/artifacts/scoped_store"
273
+ require_relative "smith/artifacts/s3"
274
+ require_relative "smith/artifacts/active_record_store"
242
275
 
243
276
  # Host persistence adapters (no internal deps)
244
277
  require_relative "smith/persistence_adapters"
245
278
 
246
279
  # Tool (depends on RubyLLM::Tool)
247
280
  require_relative "smith/tool"
281
+ require_relative "smith/idempotency_key"
282
+ require_relative "smith/untrusted"
283
+ require_relative "smith/content"
284
+ require_relative "smith/message"
248
285
  require_relative "smith/tools"
249
286
  require_relative "smith/tools/web_search"
250
287
  require_relative "smith/tools/url_fetcher"
@@ -268,7 +305,9 @@ require_relative "smith/agent/registry"
268
305
 
269
306
  # Workflow (Transition, DSL, Persistence, and Execution must load before Workflow)
270
307
  require_relative "smith/workflow/identifier"
308
+ require_relative "smith/workflow/context_keys"
271
309
  require_relative "smith/workflow/transition"
310
+ require_relative "smith/workflow/child_run_declarations"
272
311
  require_relative "smith/workflow/transition_actionability"
273
312
  require_relative "smith/workflow/graph"
274
313
  require_relative "smith/workflow/graph_dsl"
@@ -286,6 +325,7 @@ require_relative "smith/workflow/definition_identity"
286
325
  require_relative "smith/workflow/prepared_step_dispatch"
287
326
  require_relative "smith/workflow/prepared_branch_execution"
288
327
  require_relative "smith/workflow/message_value_normalizer"
328
+ require_relative "smith/workflow/message_roles"
289
329
  require_relative "smith/workflow/message_admission"
290
330
  require_relative "smith/workflow/message_batch"
291
331
  require_relative "smith/workflow/message_admission_boundary"
@@ -306,8 +346,24 @@ require_relative "smith/workflow/fanout_execution"
306
346
  require_relative "smith/workflow/retry_execution"
307
347
  require_relative "smith/workflow/deterministic_step"
308
348
  require_relative "smith/workflow/deterministic_execution"
349
+ require_relative "smith/workflow/step_io"
350
+ require_relative "smith/workflow/active_clock"
351
+ require_relative "smith/workflow/wait_record"
352
+ require_relative "smith/workflow/wait_completion"
353
+ require_relative "smith/workflow/retry_wait"
354
+ require_relative "smith/workflow/batch_execution"
355
+ require_relative "smith/workflow/batch_wait"
356
+ require_relative "smith/workflow/batch_charges"
357
+ require_relative "smith/workflow/batch_holds"
358
+ require_relative "smith/workflow/budget_pause"
359
+ require_relative "smith/workflow/remembered_calls"
360
+ require_relative "smith/workflow/child_run_results"
361
+ require_relative "smith/workflow/child_run_execution"
362
+ require_relative "smith/workflow/wait_execution"
309
363
  require_relative "smith/workflow/execution"
310
364
  require_relative "smith/workflow"
365
+ require_relative "smith/child_run"
366
+ require_relative "smith/launchers/inline"
311
367
  require_relative "smith/workflow/claim"
312
368
  require_relative "smith/workflow/execution_frame"
313
369
  require_relative "smith/workflow/pipeline"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smith-agents
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Ralak
@@ -150,22 +150,33 @@ files:
150
150
  - docs/workflow_claim.md
151
151
  - exe/smith
152
152
  - lib/generators/smith/install/install_generator.rb
153
+ - lib/generators/smith/install/templates/create_workflow_states.rb.tt
153
154
  - lib/generators/smith/install/templates/smith.rb.tt
155
+ - lib/generators/smith/install/templates/workflow_state.rb.tt
154
156
  - lib/smith.rb
155
157
  - lib/smith/agent.rb
156
158
  - lib/smith/agent/chat_construction.rb
157
159
  - lib/smith/agent/completion.rb
158
160
  - lib/smith/agent/completion_usage_recording.rb
161
+ - lib/smith/agent/content_bytes.rb
162
+ - lib/smith/agent/content_parts.rb
159
163
  - lib/smith/agent/dynamic_configuration.rb
160
164
  - lib/smith/agent/fallback_configuration.rb
161
165
  - lib/smith/agent/invocation_preparation.rb
162
166
  - lib/smith/agent/lifecycle.rb
163
167
  - lib/smith/agent/model_reference.rb
168
+ - lib/smith/agent/observed_model.rb
169
+ - lib/smith/agent/output_contract_check.rb
170
+ - lib/smith/agent/output_integrity.rb
171
+ - lib/smith/agent/output_policy.rb
172
+ - lib/smith/agent/output_recovery.rb
164
173
  - lib/smith/agent/provider_attempt.rb
165
174
  - lib/smith/agent/provider_call_timing.rb
166
175
  - lib/smith/agent/provider_candidate_sequence.rb
167
176
  - lib/smith/agent/provider_completion.rb
168
177
  - lib/smith/agent/provider_failure_handling.rb
178
+ - lib/smith/agent/provider_request.rb
179
+ - lib/smith/agent/provider_streaming.rb
169
180
  - lib/smith/agent/provider_usage.rb
170
181
  - lib/smith/agent/registry.rb
171
182
  - lib/smith/agent/registry/execution_binding_capture.rb
@@ -177,22 +188,35 @@ files:
177
188
  - lib/smith/agent/usage_traces.rb
178
189
  - lib/smith/agent/usage_tracking.rb
179
190
  - lib/smith/artifacts.rb
191
+ - lib/smith/artifacts/active_record_store.rb
180
192
  - lib/smith/artifacts/file.rb
181
193
  - lib/smith/artifacts/memory.rb
194
+ - lib/smith/artifacts/s3.rb
182
195
  - lib/smith/artifacts/scoped_store.rb
196
+ - lib/smith/artifacts/store_rules.rb
183
197
  - lib/smith/attribution.rb
198
+ - lib/smith/batch.rb
199
+ - lib/smith/batch/message_shape.rb
184
200
  - lib/smith/budget.rb
201
+ - lib/smith/budget/amount.rb
185
202
  - lib/smith/budget/amount_contract.rb
186
203
  - lib/smith/budget/amount_representation.rb
204
+ - lib/smith/budget/continuation.rb
187
205
  - lib/smith/budget/decimal_context.rb
206
+ - lib/smith/budget/host_ledger.rb
188
207
  - lib/smith/budget/ledger.rb
189
208
  - lib/smith/budget/ledger_publication.rb
190
209
  - lib/smith/budget/ledger_state.rb
191
210
  - lib/smith/budget/ledger_state_transition.rb
192
211
  - lib/smith/budget/public_state_validator.rb
212
+ - lib/smith/budget/request_hold.rb
193
213
  - lib/smith/budget/reservation.rb
194
214
  - lib/smith/budget/reservation_contract.rb
215
+ - lib/smith/budget/spent_reservation.rb
216
+ - lib/smith/child_run.rb
217
+ - lib/smith/child_runs_failed.rb
195
218
  - lib/smith/cli.rb
219
+ - lib/smith/content.rb
196
220
  - lib/smith/context.rb
197
221
  - lib/smith/context/observation_masking.rb
198
222
  - lib/smith/context/session.rb
@@ -200,6 +224,7 @@ files:
200
224
  - lib/smith/diagnostic_text.rb
201
225
  - lib/smith/doctor.rb
202
226
  - lib/smith/doctor/check.rb
227
+ - lib/smith/doctor/checks/artifacts.rb
203
228
  - lib/smith/doctor/checks/baseline.rb
204
229
  - lib/smith/doctor/checks/configuration.rb
205
230
  - lib/smith/doctor/checks/durability.rb
@@ -211,6 +236,7 @@ files:
211
236
  - lib/smith/doctor/checks/persistence_registry.rb
212
237
  - lib/smith/doctor/checks/rails.rb
213
238
  - lib/smith/doctor/checks/serialization.rb
239
+ - lib/smith/doctor/checks/state_model.rb
214
240
  - lib/smith/doctor/installer.rb
215
241
  - lib/smith/doctor/printer.rb
216
242
  - lib/smith/doctor/report.rb
@@ -227,6 +253,10 @@ files:
227
253
  - lib/smith/guardrails.rb
228
254
  - lib/smith/guardrails/runner.rb
229
255
  - lib/smith/guardrails/url_verifier.rb
256
+ - lib/smith/idempotency_key.rb
257
+ - lib/smith/idempotency_key/canonical.rb
258
+ - lib/smith/launchers/inline.rb
259
+ - lib/smith/message.rb
230
260
  - lib/smith/models.rb
231
261
  - lib/smith/models/ambiguous_profile_error.rb
232
262
  - lib/smith/models/collision_error.rb
@@ -235,6 +265,7 @@ files:
235
265
  - lib/smith/models/profile.rb
236
266
  - lib/smith/models/provider_qualified_registry.rb
237
267
  - lib/smith/models/tool_routing.rb
268
+ - lib/smith/output_failure.rb
238
269
  - lib/smith/persisted_failure_invalid.rb
239
270
  - lib/smith/persistence_adapters.rb
240
271
  - lib/smith/persistence_adapters/active_record_connection_errors.rb
@@ -255,13 +286,37 @@ files:
255
286
  - lib/smith/persistence_adapters/version_expectation.rb
256
287
  - lib/smith/persistence_payload_conflict.rb
257
288
  - lib/smith/pricing.rb
289
+ - lib/smith/pricing/catalog_validation.rb
258
290
  - lib/smith/pricing_configuration_error.rb
259
291
  - lib/smith/provider_permanent_failure.rb
292
+ - lib/smith/providers/anthropic/batches.rb
293
+ - lib/smith/providers/batch_exchange.rb
260
294
  - lib/smith/providers/openai/responses.rb
261
295
  - lib/smith/providers/openai/routing.rb
262
296
  - lib/smith/providers/openai/tools_extensions.rb
297
+ - lib/smith/providers/output_limit.rb
298
+ - lib/smith/providers/request_holds.rb
299
+ - lib/smith/providers/response_facts.rb
300
+ - lib/smith/providers/schema_constraint_check.rb
301
+ - lib/smith/providers/schema_constraints.rb
302
+ - lib/smith/providers/schema_rules.rb
303
+ - lib/smith/providers/stop_reason.rb
304
+ - lib/smith/providers/stream_facts.rb
263
305
  - lib/smith/railtie.rb
306
+ - lib/smith/response_memo.rb
307
+ - lib/smith/setting_constructors.rb
308
+ - lib/smith/streaming.rb
309
+ - lib/smith/streaming/json_field.rb
310
+ - lib/smith/streaming/json_string.rb
311
+ - lib/smith/streaming/session.rb
312
+ - lib/smith/streaming/think_tags.rb
264
313
  - lib/smith/tasks/doctor.rake
314
+ - lib/smith/testing.rb
315
+ - lib/smith/testing/checks.rb
316
+ - lib/smith/testing/hooks.rb
317
+ - lib/smith/testing/minitest.rb
318
+ - lib/smith/testing/rspec.rb
319
+ - lib/smith/testing/stub.rb
265
320
  - lib/smith/tool.rb
266
321
  - lib/smith/tool/argument_container_reader.rb
267
322
  - lib/smith/tool/argument_scalar_snapshot.rb
@@ -325,12 +380,23 @@ files:
325
380
  - lib/smith/trace/memory.rb
326
381
  - lib/smith/trace/open_telemetry.rb
327
382
  - lib/smith/types.rb
383
+ - lib/smith/untrusted.rb
328
384
  - lib/smith/version.rb
329
385
  - lib/smith/workflow.rb
386
+ - lib/smith/workflow/active_clock.rb
330
387
  - lib/smith/workflow/agent_result.rb
331
388
  - lib/smith/workflow/artifact_integration.rb
389
+ - lib/smith/workflow/await_step.rb
390
+ - lib/smith/workflow/batch_charges.rb
391
+ - lib/smith/workflow/batch_execution.rb
392
+ - lib/smith/workflow/batch_holds.rb
393
+ - lib/smith/workflow/batch_wait.rb
332
394
  - lib/smith/workflow/branch_env.rb
333
395
  - lib/smith/workflow/budget_integration.rb
396
+ - lib/smith/workflow/budget_pause.rb
397
+ - lib/smith/workflow/child_run_declarations.rb
398
+ - lib/smith/workflow/child_run_execution.rb
399
+ - lib/smith/workflow/child_run_results.rb
334
400
  - lib/smith/workflow/claim.rb
335
401
  - lib/smith/workflow/composite/branch.rb
336
402
  - lib/smith/workflow/composite/branch_budget_contract.rb
@@ -364,6 +430,7 @@ files:
364
430
  - lib/smith/workflow/composite/reduction.rb
365
431
  - lib/smith/workflow/composite/value_budget.rb
366
432
  - lib/smith/workflow/composite_branch_execution_authorization.rb
433
+ - lib/smith/workflow/context_keys.rb
367
434
  - lib/smith/workflow/data_volume_policy.rb
368
435
  - lib/smith/workflow/deadline_enforcement.rb
369
436
  - lib/smith/workflow/definition_identity.rb
@@ -386,21 +453,30 @@ files:
386
453
  - lib/smith/workflow/failure_record_validator.rb
387
454
  - lib/smith/workflow/fanout_execution.rb
388
455
  - lib/smith/workflow/graph.rb
456
+ - lib/smith/workflow/graph/batch_diagnostic.rb
457
+ - lib/smith/workflow/graph/branch_limit_diagnostic.rb
458
+ - lib/smith/workflow/graph/budget_ledger_diagnostic.rb
389
459
  - lib/smith/workflow/graph/contract_helpers.rb
390
460
  - lib/smith/workflow/graph/diagnostic.rb
391
461
  - lib/smith/workflow/graph/diagnostic_path.rb
462
+ - lib/smith/workflow/graph/durable_retry_diagnostic.rb
392
463
  - lib/smith/workflow/graph/execution_successors.rb
393
464
  - lib/smith/workflow/graph/fanout_contract.rb
394
465
  - lib/smith/workflow/graph/identifier_projection.rb
466
+ - lib/smith/workflow/graph/inherited_untrusted_diagnostics.rb
467
+ - lib/smith/workflow/graph/isolated_input_diagnostic.rb
395
468
  - lib/smith/workflow/graph/metrics.rb
396
469
  - lib/smith/workflow/graph/nested_readiness_diagnostics.rb
397
470
  - lib/smith/workflow/graph/optimization_contract.rb
398
471
  - lib/smith/workflow/graph/orchestration_contract.rb
472
+ - lib/smith/workflow/graph/output_key_diagnostic.rb
473
+ - lib/smith/workflow/graph/output_schema_diagnostic.rb
399
474
  - lib/smith/workflow/graph/reachability.rb
400
475
  - lib/smith/workflow/graph/reachability_diagnostics.rb
401
476
  - lib/smith/workflow/graph/reference.rb
402
477
  - lib/smith/workflow/graph/report.rb
403
478
  - lib/smith/workflow/graph/retry_policy_diagnostic.rb
479
+ - lib/smith/workflow/graph/run_launcher_diagnostic.rb
404
480
  - lib/smith/workflow/graph/runtime_binding_diagnostic_builder.rb
405
481
  - lib/smith/workflow/graph/runtime_binding_diagnostics.rb
406
482
  - lib/smith/workflow/graph/runtime_readiness.rb
@@ -409,6 +485,7 @@ files:
409
485
  - lib/smith/workflow/graph/runtime_readiness_report_builder.rb
410
486
  - lib/smith/workflow/graph/runtime_readiness_traversal.rb
411
487
  - lib/smith/workflow/graph/state_diagnostics.rb
488
+ - lib/smith/workflow/graph/stream_diagnostic.rb
412
489
  - lib/smith/workflow/graph/targets.rb
413
490
  - lib/smith/workflow/graph/transition_contract.rb
414
491
  - lib/smith/workflow/graph/transition_contract_attributes.rb
@@ -416,7 +493,9 @@ files:
416
493
  - lib/smith/workflow/graph/transition_diagnostics.rb
417
494
  - lib/smith/workflow/graph/transition_optimization_configuration.rb
418
495
  - lib/smith/workflow/graph/transition_snapshot.rb
496
+ - lib/smith/workflow/graph/untrusted_input_diagnostic.rb
419
497
  - lib/smith/workflow/graph/validator.rb
498
+ - lib/smith/workflow/graph/waiting_child_diagnostic.rb
420
499
  - lib/smith/workflow/graph_dsl.rb
421
500
  - lib/smith/workflow/guarded_step_execution.rb
422
501
  - lib/smith/workflow/guardrail_integration.rb
@@ -424,6 +503,7 @@ files:
424
503
  - lib/smith/workflow/message_admission.rb
425
504
  - lib/smith/workflow/message_admission_boundary.rb
426
505
  - lib/smith/workflow/message_batch.rb
506
+ - lib/smith/workflow/message_roles.rb
427
507
  - lib/smith/workflow/message_value_normalizer.rb
428
508
  - lib/smith/workflow/nested_execution.rb
429
509
  - lib/smith/workflow/optimization_state.rb
@@ -447,7 +527,9 @@ files:
447
527
  - lib/smith/workflow/prepared_step_execution_scope.rb
448
528
  - lib/smith/workflow/prepared_step_recovery.rb
449
529
  - lib/smith/workflow/process_local.rb
530
+ - lib/smith/workflow/remembered_calls.rb
450
531
  - lib/smith/workflow/retry_execution.rb
532
+ - lib/smith/workflow/retry_wait.rb
451
533
  - lib/smith/workflow/router.rb
452
534
  - lib/smith/workflow/run_result.rb
453
535
  - lib/smith/workflow/split_step_persistence.rb
@@ -497,11 +579,16 @@ files:
497
579
  - lib/smith/workflow/split_step_persistence/transition_contract_structured_values.rb
498
580
  - lib/smith/workflow/step_completion.rb
499
581
  - lib/smith/workflow/step_context.rb
582
+ - lib/smith/workflow/step_io.rb
583
+ - lib/smith/workflow/step_stream.rb
500
584
  - lib/smith/workflow/string_snapshot.rb
501
585
  - lib/smith/workflow/thread_context_snapshot.rb
502
586
  - lib/smith/workflow/transition.rb
503
587
  - lib/smith/workflow/transition_actionability.rb
504
588
  - lib/smith/workflow/usage_entry.rb
589
+ - lib/smith/workflow/wait_completion.rb
590
+ - lib/smith/workflow/wait_execution.rb
591
+ - lib/smith/workflow/wait_record.rb
505
592
  - lib/smith/workflow/worker_execution.rb
506
593
  - script/profile_tool_results.rb
507
594
  - sig/smith.rbs