rubik 0.15.0 → 0.15.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: 9a391892bea3be5bbf6d2102c6800ed7c728c253e4f6f003a7765e6b727b51ef
4
- data.tar.gz: cf65a2aa159ce1c0ce5765a1aeedda43467a46e918ac7bb4e921e812fbd4edf5
3
+ metadata.gz: '08ead4917c80a160b0885ec8475ae49f868e7ddca67cff0882b2de186004e191'
4
+ data.tar.gz: '05881ac194a5a4ce290edbec35a0cebe604bb1582cc4c16dedde96945c499978'
5
5
  SHA512:
6
- metadata.gz: 44fc9d447ea49d37e7c6483a61b69755aa882acaf8b446fd660e6a60d973566be865675dd49f555a2795ce2d6f3e09ceb990da67c514a9f4aebff4b28bf86f14
7
- data.tar.gz: 5c65c0f28f82e7e8feac9cc4b7f849192c48ed81a4a256f17db687d0eb780783593ba00bc25e21e4f3902d7e47e9bed4df56671508ff3e38bfd0a236980c7e16
6
+ metadata.gz: 0ba7c80941d3dfa029e68833ebed20f6a0f52f86a9650d96d911ec034b30898aac728838908220e207fa00a66761f057e5b9aec9092f1911f7aba8480b8e3091
7
+ data.tar.gz: eb26e26a2ce8aea909f10b3c3589064bc3bde609e766863bc7234c521ecae9bdfc46825323aff2ddbca736dc0a8fee869f2058a2abc64613c58acc13de0c6c5d
data/CHANGELOG.md CHANGED
@@ -8,6 +8,25 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
8
8
 
9
9
  ## [Unreleased]
10
10
 
11
+ ## [0.15.1] - 2026-11-20
12
+
13
+ The subagent-report-rescue patch: a report turn whose reasoning spends the
14
+ whole output budget is no longer thrown away — the channel continues the
15
+ turn instead of counting it empty, and salvages partial text rather than
16
+ failing silently.
17
+
18
+ ### Fixed
19
+
20
+ - **Subagent reports survive output-budget truncation (#610):** the
21
+ subagent channel ignored `finish_reason=length`, so a report turn whose
22
+ reasoning spent the whole budget was counted as an empty response and
23
+ died on the second strike, losing the report. The channel now reuses
24
+ `ContinuationManager` to continue with a targeted nudge, stitches partial
25
+ text across continuations, raises the per-request output cap (bounded)
26
+ after a truncated turn, and salvages the last assistant message as a
27
+ clearly marked result when the continue ceiling is exhausted — instead of
28
+ an empty failure.
29
+
11
30
  ## [0.15.0] - 2026-11-20
12
31
 
13
32
  The diagnostics-and-hardening minor: the LSP client learns pull diagnostics
@@ -1939,7 +1958,8 @@ installation section.
1939
1958
  - Context: serialized index mutations, snapshot-outside-lock reconcile,
1940
1959
  streaming-first truncation.
1941
1960
 
1942
- [Unreleased]: https://github.com/ozgurulukir/rubik/compare/v0.15.0...HEAD
1961
+ [Unreleased]: https://github.com/ozgurulukir/rubik/compare/v0.15.1...HEAD
1962
+ [0.15.1]: https://github.com/ozgurulukir/rubik/compare/v0.15.0...v0.15.1
1943
1963
  [0.15.0]: https://github.com/ozgurulukir/rubik/compare/v0.14.0...v0.15.0
1944
1964
  [0.14.0]: https://github.com/ozgurulukir/rubik/compare/v0.13.0...v0.14.0
1945
1965
  [0.13.0]: https://github.com/ozgurulukir/rubik/compare/v0.12.0...v0.13.0
@@ -50,6 +50,15 @@ module Rubik
50
50
  :context_limit, :max_output_tokens, :config, :pause_facts, :prompt_reconstructible,
51
51
  :run_seq, :journal, :operations
52
52
 
53
+ # Grows the per-request output cap after a truncated turn (issue
54
+ # #610) so reasoning + the final report can both fit. Monotonic and
55
+ # bounded by `ceiling`; never lowers a cap the operator set higher.
56
+ def raise_max_output_tokens!(ceiling)
57
+ grown = [@max_output_tokens * 2, ceiling].min
58
+ @max_output_tokens = grown if grown > @max_output_tokens
59
+ @max_output_tokens
60
+ end
61
+
53
62
  # Budget delegation: step counters live in Subagent::Budget (reader contract preserved).
54
63
  def current_step = @budget.current_step
55
64
  def max_steps = @budget.max_steps
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "../tool_call_id"
4
4
  require_relative "../tool_history"
5
+ require_relative "../continuation_manager"
5
6
 
6
7
  module Rubik
7
8
  module Orchestrator
@@ -11,6 +12,14 @@ module Rubik
11
12
  # the channel never holds @monitor and never emits on the bus under
12
13
  # it (the same discipline as the StepRunner methods it replaces).
13
14
  class SubagentChannel < Channel
15
+ # Prefixed to results rebuilt from history after the model went silent.
16
+ SALVAGE_NOTICE = "[Salvaged: the model returned no final report. This is the last assistant " \
17
+ "message from the run; see the transcript for the full work.]"
18
+
19
+ # Output-cap growth bound for truncated turns (issue #610); the
20
+ # operator's own llm.default_max_output_tokens still wins if higher.
21
+ MAX_OUTPUT_TOKENS_CEILING = 16_384
22
+
14
23
  def initialize(instance)
15
24
  super()
16
25
  @inst = instance
@@ -63,8 +72,37 @@ module Rubik
63
72
  @inst.journal&.record_token_usage(run: @inst.run_seq, usage: usage)
64
73
  end
65
74
 
66
- # Deferred: subagent continuation is future work.
67
- def handle_truncation(_res, _text, _tool_calls, _finish_reason) = nil
75
+ # Stitches the continuation buffer (partial texts from earlier
76
+ # finish_reason=length cycles) in front of the current text, so a
77
+ # long final report cut off mid-way is delivered whole (issue #610).
78
+ def final_text(res, text)
79
+ return text if continuation_manager.continuation_buffer.empty?
80
+
81
+ raw = res.respond_to?(:text) ? res.text : text
82
+ continuation_manager.stitch_and_reset(Platform.safe_utf8(raw).to_s, history: @inst.history)
83
+ end
84
+
85
+ # Same truncation flow as the user channel (issue #610): reasoning
86
+ # that spent the whole output budget gets a targeted continuation
87
+ # nudge instead of the generic empty-response strike. When the
88
+ # auto-continue ceiling is exhausted (or disabled) the partial text
89
+ # already produced is salvaged as the result; with nothing to
90
+ # salvage the turn fails with the actionable diagnostic.
91
+ def handle_truncation(res, text_resp, tool_calls, finish_reason)
92
+ cm = continuation_manager
93
+ return nil unless cm.truncation?(finish_reason)
94
+
95
+ raw_text = res.respond_to?(:text) ? res.text : text_resp
96
+ safe_text = Platform.safe_utf8(raw_text).to_s
97
+ action = cm.handle_truncation(
98
+ finish_reason: finish_reason, text_resp: safe_text, tool_calls: tool_calls, res: res,
99
+ max_tokens: @inst.max_output_tokens || 4096
100
+ )
101
+ return continue_truncated(action) if action[:continue]
102
+ return nil unless action[:error]
103
+
104
+ salvage_or_fail(cm, safe_text, action[:error])
105
+ end
68
106
 
69
107
  # ── announce ──
70
108
  def announce_compaction(reason, layer)
@@ -74,12 +112,27 @@ module Rubik
74
112
  def announce_llm_thought(_text, **) = nil
75
113
 
76
114
  # ── terminals & dispatch ──
115
+ def continuation_manager
116
+ @continuation_manager ||= ContinuationManager.new(config: @inst.config)
117
+ end
118
+
77
119
  # The shared two-strike nudge policy (Channel#empty_response_turn)
78
120
  # now governs empty, tool-less responses: one standard nudge row,
79
121
  # then the terminal below on the second consecutive strike. The
80
122
  # subagent can no longer "complete" with an empty result — the
81
123
  # declared Phase 4 delta.
124
+ #
125
+ # Second consecutive empty strike: the run's work is already in
126
+ # history, so deliver the last assistant text as a clearly marked
127
+ # salvaged result instead of an empty failure (issue #610). With
128
+ # nothing to salvage the turn still fails.
82
129
  def empty_response_failure
130
+ salvaged = last_assistant_text
131
+ if salvaged
132
+ continuation_manager.reset!
133
+ return final_text_result("#{SALVAGE_NOTICE}\n\n#{salvaged}")
134
+ end
135
+
83
136
  @inst.fail_turn!("Empty response from model (2 consecutive)")
84
137
  { ok: false, completed: false }
85
138
  end
@@ -119,6 +172,42 @@ module Rubik
119
172
  @inst.execute_subagent_tool_call(tool_call)
120
173
  nil
121
174
  end
175
+
176
+ private
177
+
178
+ def last_assistant_text
179
+ row = @inst.history.reverse_each.find do |m|
180
+ m.is_a?(Hash) && m[:role] == "assistant" && !m[:content].to_s.strip.empty?
181
+ end
182
+ row && row[:content].to_s.strip
183
+ end
184
+
185
+ def continue_truncated(action)
186
+ nudge_policy.reset!
187
+ if [:thinking_exhausted, :text_truncated].include?(action[:scenario]) && @inst.respond_to?(:raise_max_output_tokens!)
188
+ @inst.raise_max_output_tokens!(MAX_OUTPUT_TOKENS_CEILING)
189
+ end
190
+ if action[:thought]
191
+ @inst.history << { role: "assistant", content: nil, thought: Platform.safe_utf8(action[:thought]) }
192
+ elsif action[:partial_text]
193
+ @inst.history << { role: "assistant", content: action[:partial_text] }
194
+ end
195
+ @inst.history << { role: "user", content: action[:nudge] }
196
+ :consumed
197
+ end
198
+
199
+ def salvage_or_fail(manager, current_text, error)
200
+ accumulated = manager.continuation_buffer + current_text
201
+ if accumulated.strip.empty?
202
+ manager.reset!
203
+ @inst.fail_turn!(error)
204
+ return { ok: false, completed: false }
205
+ end
206
+
207
+ manager.absorb_partial_rows!(@inst.history)
208
+ manager.reset!
209
+ final_text_result(accumulated.strip)
210
+ end
122
211
  end
123
212
  end
124
213
  end
data/lib/rubik/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rubik
4
- VERSION = "0.15.0"
4
+ VERSION = "0.15.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubik
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Özgür Ulukır