composable_agents 3.3.1 → 3.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25ea65199c3a7cbc39d42a1fc130212564879ca21a790a2a153cffdb842aa2c7
4
- data.tar.gz: 68039d5cdcf0b94f31fcddf42900da77b8f5e8ce22c58f8b14aab706f284951b
3
+ metadata.gz: e8148fa849ff96e11a995eb6a0ad99f0b13d2628559b2beb45c2500e125c0318
4
+ data.tar.gz: fc1de0025450682dfbfe3088a75039af4497bb2575a0eda0dd31eca12d09582f
5
5
  SHA512:
6
- metadata.gz: 9a707773175fb27c18ea2e96185e94da06f92541ceaa09c75cdf015f4f6cb29c41e779579f2b672336c73e4a243fdd46fe190717f018070979624e46c7502676
7
- data.tar.gz: 4799b28d0665823cbca61eab7fd40714869475c9c817a1e8aa3e5e1518540cb41c36bb70a86d1bf4481e6b13378f6f410f5b7d5c594e90c54a2cac5e548e98b0
6
+ metadata.gz: c393a9e128304acda10e20d6e644515858c78ae643239e7bb4b40a96fc57a6758d186aab5701625bad811fec747d99b528341172da0d9a73c4a1ea9e3773cfb1
7
+ data.tar.gz: 0c31274bc54daa0023577f73c784533403e20bcfe8babc197beeb7a1b43a61455bb3b7c0cb456821e41472457dab99d0cabc17a41de214a1d2f9d22897c77b1b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # [v3.4.1](https://github.com/Muriel-Salvan/composable_agents/compare/v3.4.0...v3.4.1) (2026-11-03 17:18:14)
2
+
3
+ ### Patches
4
+
5
+ * [chore: update cline-rb to 2.2 and filter empty assistant messages](https://github.com/Muriel-Salvan/composable_agents/commit/7e166079df9bd949b86e7172dc06a4bc4f62d093)
6
+
7
+ # [v3.4.0](https://github.com/Muriel-Salvan/composable_agents/compare/v3.3.1...v3.4.0) (2026-11-03 13:46:46)
8
+
9
+ ### Features
10
+
11
+ * [feat: add optional artifact support to retriable artifacts](https://github.com/Muriel-Salvan/composable_agents/commit/df88d8b5e4f6ef377dfab34fb0e7a3feeccb1b15)
12
+
1
13
  # [v3.3.1](https://github.com/Muriel-Salvan/composable_agents/compare/v3.3.0...v3.3.1) (2026-11-02 20:20:46)
2
14
 
3
15
  ### Patches
data/README.md CHANGED
@@ -495,6 +495,18 @@ When a proc returns a policy, the agent waits `wait_secs` seconds, applies the `
495
495
  #### `ComposableAgents::Mixins::RetriableArtifacts`
496
496
 
497
497
  - **Description:** Automatically retries the run when output artifacts declared in contracts are missing or in error on prompt-driven agents. Requires both the ArtifactContract and Retriable mixins to be prepended, and must be prepended on an agent descending from PromptDrivenAgent.
498
+
499
+ - **Optional artifacts:** Artifacts can be marked as `optional: true` in their contract. When an optional artifact is missing, the run will not retry — it will complete successfully. This is useful for artifacts that are nice-to-have but not required for the agent to function.
500
+
501
+ Example contract with optional artifact:
502
+ ```ruby
503
+ output_artifacts_contracts: {
504
+ result: 'Final result', # required artifact
505
+ logs: { description: 'Execution logs', optional: true } # optional artifact
506
+ }
507
+ ```
508
+
509
+ - **Configuration:** Configurable via `artifacts_errors_max_retries` (default: 3); raises `ArtifactsErrorsMaxRetriesExceededError` when the limit is exceeded.
498
510
  - **Public methods:**
499
511
  - `#initialize(*args, artifacts_errors_max_retries: 3, **kwargs)` — Registers a retry policy that re-executes the run with a prompt asking for missing artifacts when output artifacts are missing or in error. The artifacts_errors_max_retries parameter (default: 3) sets the maximum number of retries before raising ArtifactsErrorsMaxRetriesExceededError.
500
512
  - **Usage example:**
@@ -170,32 +170,31 @@ module ComposableAgents
170
170
  if cline_cli.session&.messages
171
171
  @context.concat(
172
172
  cline_cli.session.messages.map.with_index do |message, idx_message|
173
- {
174
- role: message.role,
175
- content: message.content.map.with_index do |content, idx_content|
176
- {
177
- type: content.type,
178
- text: (
179
- if idx_message.zero? && idx_content.zero?
180
- # First message is the user prompt, but we don't want to include the context from it
181
- user_prompt
182
- else
183
- content.text
184
- end
185
- ),
186
- input:
187
- if content.input
188
- {
189
- question: content.input.question,
190
- # The options are a Shale collection that JSON can't serialize: keep them as a plain Array
191
- options: content.input.options&.to_a
192
- }.compact
193
- end,
194
- content: content.content
195
- }.compact
196
- end
197
- }
198
- end
173
+ curated_content = message.content.map.with_index do |content, idx_content|
174
+ curated_message = {
175
+ type: content.type,
176
+ text: (
177
+ if idx_message.zero? && idx_content.zero?
178
+ # First message is the user prompt, but we don't want to include the context from it
179
+ user_prompt
180
+ else
181
+ content.thinking || content.text
182
+ end
183
+ ),
184
+ input:
185
+ if content.input&.question
186
+ {
187
+ question: content.input.question,
188
+ # The options are a Shale collection that JSON can't serialize: keep them as a plain Array
189
+ options: content.input.options&.to_a
190
+ }.compact
191
+ end,
192
+ content: content.content
193
+ }.compact
194
+ curated_message.keys == [:type] ? nil : curated_message
195
+ end.compact
196
+ curated_content.empty? ? nil : { role: message.role, content: curated_content }
197
+ end.compact
199
198
  )
200
199
  end
201
200
 
@@ -64,7 +64,11 @@
64
64
  def missing_artifacts(output_artifacts_errors)
65
65
  output_artifacts = saved_output_artifacts
66
66
  normalized_output_artifacts_contracts
67
- .reject { |artifact_name, _artifact_description| output_artifacts.key?(artifact_name) }
67
+ .reject do |artifact_name, artifact_contract|
68
+ output_artifacts.key?(artifact_name) || (
69
+ artifact_contract[:optional] && !output_artifacts_errors[artifact_name]
70
+ )
71
+ end
68
72
  .to_h do |artifact_name, artifact_description|
69
73
  [
70
74
  artifact_name,
@@ -74,7 +74,6 @@ module ComposableAgents
74
74
  @input_artifacts = input_artifacts
75
75
  @system_prompt = render_system_prompt(render_instructions(@system_instructions))
76
76
  logger.debug "System prompt: #{@system_prompt}"
77
- # TODO: Merge converse and prompt directly here. No need for this extra complexity now that Retriable has been moved out.
78
77
  converse(user_instructions, input_artifacts: @input_artifacts, author: 'User')
79
78
  # Raise an exception if some output artifacts have errors.
80
79
  output_artifacts_errors = output_artifacts_errors_to_raise
@@ -212,13 +211,14 @@ module ComposableAgents
212
211
  # Track a message that is part of the conversation with this agent
213
212
  #
214
213
  # @param message [String, #to_hash, nil] The message content, as a String or an object that can be hashed, or nil if none.
214
+ # Nil attributes of the hashed message are not kept in the conversation.
215
215
  # @param author [String] Author of the message.
216
216
  # @param question [Boolean] Is this message a question expecting a reply?
217
217
  def track_message(message:, author: 'Orchestrator', question: false)
218
218
  @conversation << {
219
219
  at: Time.now.utc,
220
220
  author:,
221
- message: message.is_a?(String) ? message : message&.to_hash,
221
+ message: message.is_a?(String) ? message : message&.to_hash&.compact,
222
222
  question:
223
223
  }
224
224
  end
@@ -2,5 +2,5 @@ module ComposableAgents
2
2
  # @!group Public API
3
3
 
4
4
  # Gem version
5
- VERSION = '3.3.1'
5
+ VERSION = '3.4.1'
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.3.1
4
+ version: 3.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muriel Salvan
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: '2.1'
32
+ version: '2.2'
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '2.1'
39
+ version: '2.2'
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: commonmarker
42
42
  requirement: !ruby/object:Gem::Requirement