composable_agents 3.0.0 → 3.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0ee11ea2faf7acea0c666c5dda07d94ba31eca150153c07c5ed8b8a8f408195
4
- data.tar.gz: f5385011f38ce4ce3968e2b67f1866fe0134c94432dcc9c58d6373a8421af901
3
+ metadata.gz: aee730a3031c19e5b24bdd00a7a1fea08e590ff99916b61d4d20caa1c6f5d6db
4
+ data.tar.gz: 38195f2c530d077d429d5e3c253c96d0b41d4660b159aea68cf610fb26f3c10b
5
5
  SHA512:
6
- metadata.gz: 21967310c2483efc63f164ca2a2c46f9d96c5965253bcd6fc036a4717d2ad0ce46536001a172ea440476df0e6c0039134d98baed9e8d359b429130882837f83b
7
- data.tar.gz: 93d7d8bea59ec3a9a6aa7a7a021948a7af38a9292566418de1387dfc35ef22b98cad4bd56d4bee7c607e5591f1050bab6cb576488ba444db62184839572cc46b
6
+ metadata.gz: bc150e2714463ef82f7dbdac5a90716b06643728ea839c1c8b60643d2175730efdfbe10ee855d5536dc268a654678a470757e16e3a3fea169bbb44dffde6e1cb
7
+ data.tar.gz: 992a6ef86a797cdd5110a0398e22a223d93e0bb7c0b4ec531ec25ec98466edc99cf20b3521f8118194cd32ecb1c02d1de898ea0ad5c8a9a1f5f92ea31a4345e4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ # [v3.2.0](https://github.com/Muriel-Salvan/composable_agents/compare/v3.1.0...v3.2.0) (2026-11-02 16:54:36)
2
+
3
+ ## Global changes
4
+ ### Patches
5
+
6
+ * [feat(Retriable): enhance retry policy options with new_input_artifacts, altering retried input artifacts](https://github.com/Muriel-Salvan/composable_agents/commit/e4ee0fe4105bdddb87670817006aedee6a7f3840)
7
+
8
+ ## Changes for Retriable
9
+ ### Features
10
+
11
+ * [feat(Retriable): enhance retry policy options with new_input_artifacts, altering retried input artifacts](https://github.com/Muriel-Salvan/composable_agents/commit/e4ee0fe4105bdddb87670817006aedee6a7f3840)
12
+
13
+ # [v3.1.0](https://github.com/Muriel-Salvan/composable_agents/compare/v3.0.0...v3.1.0) (2026-11-01 13:55:18)
14
+
15
+ ## Global changes
16
+ ### Patches
17
+
18
+ * [feat(cline): introduce ClineError and extract MissingSkillError](https://github.com/Muriel-Salvan/composable_agents/commit/ba02df7d666c96c7cfc23a1b5a7eb92274a9e496)
19
+
20
+ ## Changes for cline
21
+ ### Features
22
+
23
+ * [feat(cline): introduce ClineError and extract MissingSkillError](https://github.com/Muriel-Salvan/composable_agents/commit/ba02df7d666c96c7cfc23a1b5a7eb92274a9e496)
24
+
1
25
  # [v3.0.0](https://github.com/Muriel-Salvan/composable_agents/compare/v2.2.0...v3.0.0) (2026-11-01 12:34:56)
2
26
 
3
27
  ## Global changes
data/README.md CHANGED
@@ -48,6 +48,7 @@ Whether you're building a code review assistant, a document summarizer, or a mul
48
48
  - [`ComposableAgents::AiAgents::Agent < PromptDrivenAgent`](#composableagentsaiagentsagent--promptdrivenagent)
49
49
  - [`ComposableAgents::Cline::Agent < PromptDrivenAgent`](#composableagentsclineagent--promptdrivenagent)
50
50
  - [`ComposableAgents::Cline::MissingSkillError < RuntimeError`](#composableagentsclinemissingskillerror--runtimeerror)
51
+ - [`ComposableAgents::Cline::ClineError < RuntimeError`](#composableagentsclineerror--runtimeerror)
51
52
  - [Mixins](#mixins)
52
53
  - [`ComposableAgents::Logger < ::Logger`](#composableagentslogger--logger)
53
54
  - [`ComposableAgents::Mixins::Resumable`](#composableagentsmixinsresumable)
@@ -363,6 +364,11 @@ The project is a Ruby library (not a CLI) — users install the gem and use its
363
364
  - **Description:** Raised by `Cline::Agent` when a referenced skill is not found in the global or project Cline configuration.
364
365
  - **Full documentation:** [cline/agent.rb on GitHub](https://github.com/Muriel-Salvan/composable_agents/blob/main/lib/composable_agents/cline/agent.rb)
365
366
 
367
+ #### `ComposableAgents::Cline::ClineError < RuntimeError`
368
+
369
+ - **Description:** Raised by `Cline::Agent` when a Cline CLI run fails.
370
+ - **Full documentation:** [cline/cline_error.rb on GitHub](https://github.com/Muriel-Salvan/composable_agents/blob/main/lib/composable_agents/cline/cline_error.rb)
371
+
366
372
  ---
367
373
 
368
374
  ### Mixins
@@ -457,11 +463,14 @@ Mixins are `prepend`-ed into an agent class to add specific capabilities.
457
463
 
458
464
  #### `ComposableAgents::Mixins::Retriable`
459
465
 
460
- - **Description:** Adds conditional retry capabilities to agents. Retry condition procs are registered with `#retry_on` (or `#with_retry_on` for temporary activation) and are evaluated at the end of each run. A proc receives the agent instance and the exception raised by `run` (or `nil` if none) and returns either `nil` (no retry) or a policy hash with `:wait_secs` and optional `:modifier` keys. When a proc returns a policy, the agent waits `wait_secs` seconds, optionally calls the policy's `modifier`, and re-runs. If `run` raised an exception and no proc returned a retry policy, the exception is re-raised to the caller.
466
+ - **Description:** Adds conditional retry capabilities to agents. Retry condition procs are registered with `#retry_on` (or `#with_retry_on` for temporary activation) and are evaluated at the end of each run. A proc receives the agent instance and the exception raised by `run` (or `nil` if none) and returns either `nil` (no retry) or a policy hash with optional keys to describe the policy:
467
+ - `:wait_secs` — Wait time in seconds before retrying (defaults to 0).
468
+ - `:modifier` — Proc called with the agent before retrying ( defaults to doing nothing).
469
+ - `:new_input_artifacts` — Hash of input artifacts to add to the retried run (defaults to `{}`).
470
+ When a proc returns a policy, the agent waits `wait_secs` seconds, applies the `modifier` proc (if any), merges the `new_input_artifacts` into the retry input, and re-runs. If `run` raised an exception and no proc returned a retry policy, the exception is re-raised to the caller.
461
471
  - **Public methods:**
462
- - `#retry_on(proc)` — Register a retry condition proc. Returns `self` so calls can be chained.
472
+ - `#retry_on(proc)` — Register a retry condition proc.
463
473
  - `#with_retry_on(proc, &block)` — Register a retry proc for the duration of a block, then unregister it when the block returns (even if it raises).
464
- - policy hash — Configuration with optional `:wait_secs` (seconds to wait before retrying, defaults to 0) and optional `:modifier` (proc called with the agent before retrying).
465
474
  - **Usage example:**
466
475
  ```ruby
467
476
  class MyAgent < ComposableAgents::Agent
@@ -3,10 +3,6 @@ require 'cline'
3
3
  module ComposableAgents
4
4
  # All agents from this module work with the awesome cline-rb Rubygem
5
5
  module Cline
6
- # Missin skill error
7
- class MissingSkillError < RuntimeError
8
- end
9
-
10
6
  # Agent implementation that uses an ai-agent's AgentRunner.
11
7
  # This agent publishes the following run information:
12
8
  # - usage [Hash] Cumulative usage of the API requests (cost and tokens) made during the run.
@@ -168,7 +164,7 @@ module ComposableAgents
168
164
  end,
169
165
  **@cli_options
170
166
  )
171
- raise "Error: #{extract_error_message(result[:error])}".strip if result[:error]
167
+ raise ClineError, "Error: #{extract_error_message(result[:error])}".strip if result[:error]
172
168
 
173
169
  # Keep the context in case we need to resume it
174
170
  if cline_cli.session&.messages
@@ -0,0 +1,7 @@
1
+ module ComposableAgents
2
+ module Cline
3
+ # Error raised when a Cline CLI run fails.
4
+ class ClineError < RuntimeError
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module ComposableAgents
2
+ module Cline
3
+ # Missing skill error
4
+ class MissingSkillError < RuntimeError
5
+ end
6
+ end
7
+ end
@@ -17,14 +17,13 @@ module ComposableAgents
17
17
  # * Each registered proc is kept in an internal array, in registration order.
18
18
  # * A proc receives the agent's instance and the exception raised by `run`
19
19
  # (or `nil` if none) and returns either `nil` (no retry) or a policy hash
20
- # with optional `:wait_secs` and optional `:modifier` keys.
20
+ # (see Retriable#retry_on).
21
21
  # * The run method is wrapped: it calls the original run, then evaluates the
22
22
  # registered procs in order until one returns a non-nil policy hash.
23
23
  # * If `run` raised an exception and no proc returned a non-nil policy hash,
24
24
  # the exception is re-raised to the caller.
25
25
  # * If a proc decides to retry: wait for `wait_secs` seconds, then call the
26
- # `modifier` proc (if any), then call run again.
27
- #
26
+ # `modifier` proc (if any), merge the `new_input_artifacts` into the retry input, and call run again.
28
27
  module Retriable
29
28
  # @!group Public API
30
29
 
@@ -41,8 +40,9 @@ module ComposableAgents
41
40
  # - param exception [Exception, nil] The exception that was raised by the run, or nil if none.
42
41
  # - result [Hash\\{Symbol => Object}] Definition of the retry policy, with optional properties:
43
42
  # - wait_secs [Integer, Float] Wait time in seconds before retrying (defaults to 0).
44
- # - modifier [Proc] Code called to modify the agent's state before retrying (defaults to doing nothing).
43
+ # - modifier [#call(agent)] Code called to modify the agent's state before retrying (defaults to doing nothing).
45
44
  # - param agent [Agent] The agent for which the retry is considered.
45
+ # - new_input_artifacts [Hash\\{Symbol => Object}] New input artifacts that need to be added to the retried run (defaults to {}).
46
46
  # @return [self]
47
47
  def retry_on(proc)
48
48
  retry_policies << proc
@@ -78,12 +78,13 @@ module ComposableAgents
78
78
  # @param input_artifacts [Hash{Symbol => Object}] input artifacts
79
79
  # @return [Hash{Symbol => Object}] output artifacts from the last run
80
80
  def run(**input_artifacts)
81
+ retry_input_artifacts = input_artifacts.dup
81
82
  output_artifacts = nil
82
83
  retry_index = 0
83
84
  loop do
84
85
  exception = nil
85
86
  begin
86
- output_artifacts = super
87
+ output_artifacts = super(**retry_input_artifacts)
87
88
  rescue StandardError => e
88
89
  exception = e
89
90
  end
@@ -98,6 +99,7 @@ module ComposableAgents
98
99
  logger.debug "Retry ##{retry_index}: re-running in #{wait_secs}s#{" (exception #{exception})" if exception}"
99
100
  sleep(wait_secs) if wait_secs.positive?
100
101
  policy[:modifier]&.call(self)
102
+ retry_input_artifacts.merge!(policy[:new_input_artifacts] || {})
101
103
  else
102
104
  raise exception if exception
103
105
 
@@ -49,27 +49,12 @@
49
49
  "Maximum number of retries (#{max_retries}) exceeded. Missing or errored artifacts: #{artifact_keys.join(', ')}"
50
50
  else
51
51
  artifacts_errors_retries += 1
52
- { modifier: proc { @overridden_user_instructions = missing_output_user_instructions(missing) } }
52
+ { new_input_artifacts: { user_instructions: missing_output_user_instructions(missing) } }
53
53
  end
54
54
  end
55
55
  )
56
56
  end
57
57
 
58
- # Execute the agent to generate some output artifacts based on some input artifacts.
59
- # On retry, uses +@overridden_user_instructions+ (set by the retry policy's modifier)
60
- # instead of the original +user_instructions+.
61
- #
62
- # @param user_instructions [Object, nil] Instructions for the user prompt, that will be rendered.
63
- # @param input_artifacts [Hash{Symbol => Object}] The input artifacts content, per artifact name
64
- # @return [Hash{Symbol => Object}] The output artifacts
65
- def run(user_instructions: nil, **input_artifacts)
66
- if @overridden_user_instructions
67
- user_instructions = @overridden_user_instructions
68
- @overridden_user_instructions = nil
69
- end
70
- super
71
- end
72
-
73
58
  private
74
59
 
75
60
  # Compute the missing output artifacts with their descriptions and errors.
@@ -2,5 +2,5 @@ module ComposableAgents
2
2
  # @!group Public API
3
3
 
4
4
  # Gem version
5
- VERSION = '3.0.0'
5
+ VERSION = '3.2.0'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composable_agents
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan
@@ -82,6 +82,8 @@ files:
82
82
  - lib/composable_agents/ai_agents/tools/get_artifact_tool.rb
83
83
  - lib/composable_agents/artifacts_errors_max_retries_exceeded_error.rb
84
84
  - lib/composable_agents/cline/agent.rb
85
+ - lib/composable_agents/cline/cline_error.rb
86
+ - lib/composable_agents/cline/missing_skill_error.rb
85
87
  - lib/composable_agents/instructions.rb
86
88
  - lib/composable_agents/logger.rb
87
89
  - lib/composable_agents/logger/tagged.rb