riffer-rig 0.17.0 → 0.19.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: 9b1648704ba63c4826d30aec44988486557c4a2fccc5b3b527fef879fc407cef
4
- data.tar.gz: 574c73fcb0f3512f486d6d4c355b69add66d54de82c87ed170c8409821c4b3f1
3
+ metadata.gz: 5b0f1827ee6bf5b6da18e1d9cc02bb14b0473426cc407106c6c070260a6f3791
4
+ data.tar.gz: 560d5c945653ef3076271a3c767b8fdb6e08b3284dfbf915ebfe8e1f872ef195
5
5
  SHA512:
6
- metadata.gz: 0da1408916c461365dc8d61c07dca3b00ad5f2d22d77e42d036d379ce6231c5cff0ae3ade79a2d8f907439c8e70e33753ae3e5b91786905e5366bf414d0f3521
7
- data.tar.gz: 994802e5749d8708313eda67386af949ff4112b9b2275b6687a2078ea2f4332b8147916608cdbf8adb5f90c632bea9b395d5929b9024907f4811e2ecca75eff1
6
+ metadata.gz: 9a98f865e62d62f6feeda6303ba37757723c3ed22509bc7381d6029cd9426fc405cf1a7fe5bd79a18a3cebd1a6cbff63e8a1e01ed2069891d8d0d9165a578512
7
+ data.tar.gz: 84cb6adea8d80d6c96f93eb6c4b1d67ffba3085638f5b3c5eeeaf892a23f98389a39fcd3c91136717c3e70eb7ad6d8fd3fa28edf23260dadc0b3b0ae0b326ec2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.19.0](https://github.com/bottrall/riffer-rig/compare/v0.18.0...v0.19.0) (2026-11-07)
4
+
5
+
6
+ ### Features
7
+
8
+ * expand ~ in catalog file paths ([#623](https://github.com/bottrall/riffer-rig/issues/623)) ([99609b5](https://github.com/bottrall/riffer-rig/commit/99609b536634108aeb472a31c63dc5ae545752e4))
9
+
10
+ ## [0.18.0](https://github.com/bottrall/riffer-rig/compare/v0.17.0...v0.18.0) (2026-11-07)
11
+
12
+
13
+ ### Features
14
+
15
+ * add a max_tokens setting with a 64k Anthropic default ([#621](https://github.com/bottrall/riffer-rig/issues/621)) ([c3abf81](https://github.com/bottrall/riffer-rig/commit/c3abf81442f5761bab961b11b2e2e584d91687e7))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * show why a turn stopped early in the terminal ([#620](https://github.com/bottrall/riffer-rig/issues/620)) ([16c9928](https://github.com/bottrall/riffer-rig/commit/16c99283a41abfa384d6a2afe7971710582ceaf4)), closes [#619](https://github.com/bottrall/riffer-rig/issues/619)
21
+
3
22
  ## [0.17.0](https://github.com/bottrall/riffer-rig/compare/v0.16.0...v0.17.0) (2026-10-24)
4
23
 
5
24
 
@@ -24,4 +24,17 @@ module Riffer::Rig::Directories
24
24
  def riffer(root, *names)
25
25
  File.join(root, '.riffer', *names)
26
26
  end
27
+
28
+ # @rbs path: String
29
+ # @rbs home: String
30
+ # @rbs return: String
31
+ def expand_home(path, home)
32
+ if path == '~'
33
+ home
34
+ elsif path.start_with?('~/')
35
+ File.join(home, path.delete_prefix('~/'))
36
+ else
37
+ path
38
+ end
39
+ end
27
40
  end
@@ -88,7 +88,7 @@ class Riffer::Rig::Loader
88
88
  credentials = install_credentials(provider)
89
89
  raise ConfigurationError, credentials if credentials.is_a?(String)
90
90
 
91
- @riffer_config.catalog_files = document.catalog_files
91
+ @riffer_config.catalog_files = document.catalog_files.map { |path| Riffer::Rig::Directories.expand_home(path, @home) }
92
92
  stripped = { skills: options.skills, agents_md: options.agents_md }.reject { |_name, kept| kept }.keys
93
93
  discovered = options.extensions ? @source.discover(autoload: document.autoload) : [] #: Array[Riffer::Rig::Extension]
94
94
 
@@ -114,6 +114,7 @@ class Riffer::Rig::Loader
114
114
  riffer_config: @riffer_config,
115
115
  model_options: Riffer::Rig::Settings::ModelOptions.model_options(selected),
116
116
  native_tools: document.native_tools,
117
+ max_tokens: document.max_tokens,
117
118
  snapshot: saved
118
119
  )
119
120
  reloader = Riffer::Rig::Loader::Reloader.new(
@@ -4,7 +4,7 @@ class Riffer::Rig::Registrar
4
4
  class NameCollisionError < StandardError; end
5
5
 
6
6
  CORE_SETTINGS_KEYS = %w[
7
- model reasoning catalog_files reload extensions sessions providers tools
7
+ model reasoning max_tokens catalog_files reload extensions sessions providers tools
8
8
  ].freeze #: Array[String]
9
9
 
10
10
  EVENTS = %i[
@@ -55,6 +55,7 @@ class Riffer::Rig::Runtime
55
55
  # @rbs @mcp: Riffer::Rig::Runtime::McpRegistrar
56
56
  # @rbs @model_options: Hash[Symbol, untyped]
57
57
  # @rbs @native_tools: Hash[Symbol, untyped]
58
+ # @rbs @max_tokens: Integer?
58
59
  # @rbs @reload_check: (^(::Riffer::Rig::Runtime) -> void)?
59
60
  # @rbs @clock: ^() -> Float
60
61
  # @rbs @turn: Riffer::Rig::Runtime::Turn?
@@ -87,6 +88,7 @@ class Riffer::Rig::Runtime
87
88
  # @rbs max_steps: Integer?
88
89
  # @rbs model_options: Hash[Symbol, untyped]
89
90
  # @rbs native_tools: Hash[Symbol, untyped]
91
+ # @rbs max_tokens: Integer?
90
92
  # @rbs clock: ^() -> Float
91
93
  # @rbs snapshot: (Riffer::Rig::Runtime::Snapshot | Hash[Symbol, untyped])?
92
94
  # @rbs return: void
@@ -109,6 +111,7 @@ class Riffer::Rig::Runtime
109
111
  max_steps: DEFAULT_MAX_STEPS,
110
112
  model_options: {},
111
113
  native_tools: {},
114
+ max_tokens: nil,
112
115
  clock: -> { Process.clock_gettime(Process::CLOCK_MONOTONIC) },
113
116
  snapshot: nil
114
117
  )
@@ -142,7 +145,10 @@ class Riffer::Rig::Runtime
142
145
  @reasoning = (saved && Riffer::Rig::Settings::ModelOptions.reasoning_level(saved.reasoning)) || reasoning
143
146
  @tool_allowlist = tools
144
147
  @native_tools = native_tools
145
- @model_options = model_options.merge(Riffer::Rig::Settings::ModelOptions.native_options(model, native_tools))
148
+ @max_tokens = max_tokens
149
+ options = Riffer::Rig::Settings::ModelOptions
150
+ @model_options = options.max_tokens_options(model, max_tokens)
151
+ .merge(model_options, options.native_options(model, native_tools))
146
152
  @system_prompt = Riffer::Rig::Runtime::SystemPrompt.new(
147
153
  instructions || format(BASE_PROMPT_TEMPLATE, name: name), @cwd
148
154
  )
@@ -158,6 +164,8 @@ class Riffer::Rig::Runtime
158
164
  config = agent_config(assembly, hooks, max_steps)
159
165
  agent = saved ? restore(saved, model, config) : build_agent(model, config)
160
166
  install(assembly, hooks, agent)
167
+ restored = @model_override
168
+ rederive_options(restored) if restored && options.provider_for(restored) != options.provider_for(model)
161
169
  @mcp.retain(mcp_servers)
162
170
  @agent.session.on_message do |message|
163
171
  Thread.handle_interrupt(Riffer::Rig::Runtime::Abort::SHIELD) { observe_message(message) }
@@ -412,16 +420,19 @@ class Riffer::Rig::Runtime
412
420
  end
413
421
 
414
422
  # The options the settings built for the starting model are provider-shaped
415
- # (anthropic cache control), so a switch re-derives them; the reasoning level
416
- # is provider-agnostic and travels on the config. Runs after the successor is
417
- # built, so a failed build leaves the running agent's options alone; riffer
418
- # reads config.model_options per request, so the swap still reaches the new
419
- # agent through the shared config.
423
+ # (anthropic cache control, each provider's output limit parameter), so a
424
+ # switch, or a restore onto another provider's model, re-derives them; the
425
+ # reasoning level is provider-agnostic and travels on the config. Runs after
426
+ # the successor is built, so a failed build leaves the running agent's
427
+ # options alone; riffer reads config.model_options per request, so the swap
428
+ # still reaches the new agent through the shared config.
420
429
  # @rbs model: String
421
430
  # @rbs return: void
422
431
  def rederive_options(model)
423
432
  options = Riffer::Rig::Settings::ModelOptions
424
- @model_options = options.model_options(model).merge(options.native_options(model, @native_tools))
433
+ @model_options = options.model_options(model).merge(
434
+ options.max_tokens_options(model, @max_tokens), options.native_options(model, @native_tools)
435
+ )
425
436
  @agent.config.model_options = @model_options
426
437
  end
427
438
 
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Riffer::Rig::Settings::Document
4
- # @dynamic model, reasoning, catalog_files, providers, disabled, autoload, native_tools, save, reload
4
+ # @dynamic model, reasoning, max_tokens, catalog_files, providers, disabled, autoload, native_tools, save, reload
5
5
  attr_reader :model #: String?
6
6
  attr_reader :reasoning #: String?
7
+ attr_reader :max_tokens #: Integer?
7
8
  attr_reader :catalog_files #: Array[String]
8
9
  attr_reader :providers #: Hash[String, Hash[String, String]]
9
10
  attr_reader :disabled #: Array[String]
@@ -17,6 +18,8 @@ class Riffer::Rig::Settings::Document
17
18
  def initialize(source)
18
19
  @model = source[:model].is_a?(String) ? source[:model] : nil
19
20
  @reasoning = source[:reasoning].is_a?(String) ? source[:reasoning] : nil
21
+ max_tokens = source[:max_tokens]
22
+ @max_tokens = max_tokens.is_a?(Integer) && max_tokens.positive? ? max_tokens : nil
20
23
  paths = source[:catalog_files]
21
24
  no_files = [] #: Array[String]
22
25
  @catalog_files = paths.is_a?(Array) && paths.all?(String) ? paths.dup.freeze : no_files.freeze
@@ -14,6 +14,27 @@ module Riffer::Rig::Settings::ModelOptions
14
14
  web_search: { anthropic: true, openai: true, azure_openai: true, mock: true }.freeze
15
15
  }.freeze #: Hash[Symbol, Hash[Symbol, bool]]
16
16
 
17
+ # Upstream candidate: riffer passes model_options to each provider's API
18
+ # unchanged, so rig names every provider's own output limit parameter until
19
+ # riffer accepts a provider-neutral option and translates it, as it does for
20
+ # reasoning.
21
+ MAX_TOKENS_PARAMETERS = {
22
+ anthropic: %i[max_tokens].freeze,
23
+ openai: %i[max_output_tokens].freeze,
24
+ azure_openai: %i[max_output_tokens].freeze,
25
+ gemini: %i[maxOutputTokens].freeze,
26
+ openrouter: %i[max_tokens].freeze,
27
+ amazon_bedrock: %i[inference_config max_tokens].freeze,
28
+ mock: %i[max_tokens].freeze
29
+ }.freeze #: Hash[Symbol, Array[Symbol]]
30
+
31
+ # Every other provider's API falls back to the model's own limit, but riffer's
32
+ # Anthropic provider sends 4096 unless told otherwise, and thinking spends
33
+ # from that same budget.
34
+ MAX_TOKENS_REQUIRED = %i[anthropic].freeze #: Array[Symbol]
35
+
36
+ DEFAULT_MAX_TOKENS = 64_000
37
+
17
38
  # @rbs model: String
18
39
  # @rbs return: String?
19
40
  def provider_for(model)
@@ -51,6 +72,19 @@ module Riffer::Rig::Settings::ModelOptions
51
72
  {}
52
73
  end
53
74
 
75
+ # @rbs model: String
76
+ # @rbs max_tokens: Integer?
77
+ # @rbs return: Hash[Symbol, untyped]
78
+ def max_tokens_options(model, max_tokens)
79
+ provider = provider_for(model)&.to_sym
80
+ path = provider && MAX_TOKENS_PARAMETERS[provider]
81
+ limit = max_tokens || (DEFAULT_MAX_TOKENS if MAX_TOKENS_REQUIRED.include?(provider))
82
+ return {} unless path && limit
83
+
84
+ innermost = { path.fetch(-1) => limit } #: Hash[Symbol, untyped]
85
+ path.reverse.drop(1).reduce(innermost) { |nested, parent| { parent => nested } }
86
+ end
87
+
54
88
  # @rbs model: String
55
89
  # @rbs switches: Hash[Symbol, untyped]
56
90
  # @rbs return: Hash[Symbol, untyped]
@@ -1,23 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Riffer::Rig::Terminal::Replay::Turn
4
- # @dynamic heading, answer, stats
4
+ # @dynamic heading, answer, stats, stop_reason
5
5
  attr_reader :heading #: String
6
6
  attr_reader :answer #: String
7
7
  attr_reader :stats #: Riffer::Rig::Terminal::TurnBuffer::Stats
8
+ attr_reader :stop_reason #: Symbol?
8
9
 
9
10
  # @rbs heading: String
10
11
  # @rbs answer: String
11
12
  # @rbs stats: Riffer::Rig::Terminal::TurnBuffer::Stats
13
+ # @rbs stop_reason: Symbol?
12
14
  # @rbs return: void
13
- def initialize(heading:, answer:, stats:)
15
+ def initialize(heading:, answer:, stats:, stop_reason:)
14
16
  @heading = heading
15
17
  @answer = answer
16
18
  @stats = stats
19
+ @stop_reason = stop_reason
17
20
  freeze
18
21
  end
19
-
20
- # The record keeps no trace of how a turn ended.
21
- # @rbs return: bool
22
- def interrupted? = false
23
22
  end
@@ -44,7 +44,11 @@ module Riffer::Rig::Terminal::Replay
44
44
  steps: replies.size,
45
45
  wall_time: ended - started,
46
46
  usage: Riffer::Rig::Runtime::Usage.sum(replies)
47
- )
47
+ ),
48
+ # The record keeps only the provider's finish reason, which riffer takes
49
+ # as the stop reason of a turn the provider cut short; a cancel or the
50
+ # step limit replays as a turn that ran to its end.
51
+ stop_reason: replies.last&.finish_reason
48
52
  )
49
53
  end
50
54
 
@@ -8,13 +8,13 @@ class Riffer::Rig::Terminal::TurnBuffer
8
8
  # @rbs @answers: Array[String]
9
9
  # @rbs @steps: Integer
10
10
  # @rbs @in_request: bool
11
- # @rbs @interrupted: bool
12
11
  # @rbs @settled_usage: Riffer::Providers::TokenUsage?
13
12
  # @rbs @request_usage: Riffer::Providers::TokenUsage?
14
13
 
15
- # @dynamic ghost, tool
14
+ # @dynamic ghost, tool, stop_reason
16
15
  attr_reader :ghost #: String?
17
16
  attr_reader :tool #: String?
17
+ attr_reader :stop_reason #: Symbol?
18
18
 
19
19
  # @rbs clock: ^() -> Float
20
20
  # @rbs return: void
@@ -25,7 +25,6 @@ class Riffer::Rig::Terminal::TurnBuffer
25
25
  @answers = []
26
26
  @steps = 0
27
27
  @in_request = false
28
- @interrupted = false
29
28
  end
30
29
 
31
30
  # @rbs event: ::Riffer::StreamEvents::Base | Riffer::Rig::Events::_Event
@@ -54,15 +53,13 @@ class Riffer::Rig::Terminal::TurnBuffer
54
53
  # A blocked tool call skips BeforeToolCall.
55
54
  settle(:tool_calls)
56
55
  @tool = nil
57
- when Riffer::Rig::Events::JobExit
58
- # A turn the Runtime continues for a job exit has no tool call between
59
- # its replies to end the first request.
60
- settle(:stop)
61
- when Riffer::StreamEvents::Interrupt
62
- @interrupted = true
56
+ when Riffer::Rig::Events::JobExit, Riffer::StreamEvents::Interrupt
57
+ # A turn the Runtime continues for a job exit, or one cut short, has no
58
+ # tool call or finish reason to end the open request.
63
59
  settle(:stop)
64
60
  when Riffer::Rig::Events::TurnEnd
65
61
  settle(:stop)
62
+ @stop_reason = event.stop_reason
66
63
  @ended_at = @clock.call
67
64
  end
68
65
  end
@@ -77,11 +74,6 @@ class Riffer::Rig::Terminal::TurnBuffer
77
74
  @prose.dup
78
75
  end
79
76
 
80
- # @rbs return: bool
81
- def interrupted?
82
- @interrupted
83
- end
84
-
85
77
  # @rbs return: bool
86
78
  def ended?
87
79
  !@ended_at.nil?
@@ -7,6 +7,16 @@ module Riffer::Rig::Terminal::TurnReport
7
7
 
8
8
  INTERRUPTED = 'interrupted'
9
9
 
10
+ INTERRUPTIONS = [Riffer::Rig::Runtime::StopReason::INTERRUPT_CANCELLED, :interrupted].freeze #: Array[Symbol]
11
+
12
+ STOPPED = {
13
+ max_steps: 'step limit',
14
+ context_window: 'context window full',
15
+ length: 'output token limit',
16
+ content_filter: 'content filter',
17
+ malformed_output: 'malformed output'
18
+ }.freeze #: Hash[Symbol, String]
19
+
10
20
  COLUMN_HEAD = /\A.*\S {2,}(?=\S)/ #: Regexp
11
21
 
12
22
  VISIBLE = /\S/ #: Regexp
@@ -17,13 +27,7 @@ module Riffer::Rig::Terminal::TurnReport
17
27
  # @rbs width: Integer?
18
28
  # @rbs return: String
19
29
  def call(turn, session, theme:, width:)
20
- closing =
21
- if turn.interrupted?
22
- theme.dim(wrap(INTERRUPTED, width))
23
- else
24
- footer(turn.stats, session, theme: theme, width: width)
25
- end
26
- blocks = [*answer(turn.answer, theme: theme, width: width), closing]
30
+ blocks = [*answer(turn.answer, theme: theme, width: width), closing(turn, session, theme: theme, width: width)]
27
31
  blocks.map { |block| "\n#{block}\n" }.join
28
32
  end
29
33
 
@@ -73,6 +77,20 @@ module Riffer::Rig::Terminal::TurnReport
73
77
  body.gsub(/^(?=.)/, ' ' * INDENT).chomp unless body.empty?
74
78
  end
75
79
 
80
+ # @rbs turn: Riffer::Rig::Terminal::TurnReport::_Turn
81
+ # @rbs session: Riffer::Providers::TokenUsage?
82
+ # @rbs theme: Riffer::Rig::Terminal::Theme
83
+ # @rbs width: Integer?
84
+ # @rbs return: String
85
+ def closing(turn, session, theme:, width:)
86
+ stop_reason = turn.stop_reason
87
+ return theme.dim(wrap(INTERRUPTED, width)) if INTERRUPTIONS.include?(stop_reason)
88
+
89
+ stat_line = footer(turn.stats, session, theme: theme, width: width)
90
+ stopped = stop_reason && STOPPED[stop_reason]
91
+ stopped ? "#{theme.dim(wrap("stopped: #{stopped}", width))}\n#{stat_line}" : stat_line
92
+ end
93
+
76
94
  # @rbs stats: Riffer::Rig::Terminal::TurnBuffer::Stats
77
95
  # @rbs session: Riffer::Providers::TokenUsage?
78
96
  # @rbs theme: Riffer::Rig::Terminal::Theme
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Riffer
4
4
  module Rig
5
- VERSION = '0.17.0'
5
+ VERSION = '0.19.0'
6
6
  end
7
7
  end
@@ -13,4 +13,9 @@ module Riffer::Rig::Directories
13
13
  # @rbs *names: String
14
14
  # @rbs return: String
15
15
  def riffer: (String root, *String names) -> String
16
+
17
+ # @rbs path: String
18
+ # @rbs home: String
19
+ # @rbs return: String
20
+ def expand_home: (String path, String home) -> String
16
21
  end
@@ -19,7 +19,7 @@ class Riffer::Rig::Runtime
19
19
  # harness.
20
20
  DEFAULT_MAX_STEPS: Integer?
21
21
 
22
- @settings_path: String
22
+ @model_observers: Array[^(String) -> void]
23
23
 
24
24
  @message_observers: Array[^(Riffer::Messages::Base) -> void]
25
25
 
@@ -53,6 +53,8 @@ class Riffer::Rig::Runtime
53
53
 
54
54
  @agent: Riffer::Agent
55
55
 
56
+ @settings_path: String
57
+
56
58
  @auth_path: String
57
59
 
58
60
  @env: Riffer::Rig::Env
@@ -63,6 +65,8 @@ class Riffer::Rig::Runtime
63
65
 
64
66
  @reload_check: (^(::Riffer::Rig::Runtime) -> void)?
65
67
 
68
+ @max_tokens: Integer?
69
+
66
70
  @native_tools: Hash[Symbol, untyped]
67
71
 
68
72
  @model_options: Hash[Symbol, untyped]
@@ -83,8 +87,6 @@ class Riffer::Rig::Runtime
83
87
 
84
88
  @reasoning_observers: Array[^(String) -> void]
85
89
 
86
- @model_observers: Array[^(String) -> void]
87
-
88
90
  # @dynamic agent, credentials, cwd, host, id
89
91
  attr_reader agent: Riffer::Agent
90
92
 
@@ -114,10 +116,11 @@ class Riffer::Rig::Runtime
114
116
  # @rbs max_steps: Integer?
115
117
  # @rbs model_options: Hash[Symbol, untyped]
116
118
  # @rbs native_tools: Hash[Symbol, untyped]
119
+ # @rbs max_tokens: Integer?
117
120
  # @rbs clock: ^() -> Float
118
121
  # @rbs snapshot: (Riffer::Rig::Runtime::Snapshot | Hash[Symbol, untyped])?
119
122
  # @rbs return: void
120
- def initialize: (String model, ?extensions: Array[Riffer::Rig::Extension], ?tools: Array[String]?, ?settings: Hash[Symbol, untyped], ?host: Riffer::Rig::Hosts::_Host, ?cwd: String?, ?name: String, ?instructions: String?, ?credentials: Hash[Symbol, Hash[Symbol, String]], ?env: Riffer::Rig::Env, ?auth_path: String, ?settings_path: String, ?reasoning: String?, ?riffer_config: Riffer::Config, ?mcp_registry: Riffer::Rig::Mcp::_Registry, ?max_steps: Integer?, ?model_options: Hash[Symbol, untyped], ?native_tools: Hash[Symbol, untyped], ?clock: ^() -> Float, ?snapshot: (Riffer::Rig::Runtime::Snapshot | Hash[Symbol, untyped])?) -> void
123
+ def initialize: (String model, ?extensions: Array[Riffer::Rig::Extension], ?tools: Array[String]?, ?settings: Hash[Symbol, untyped], ?host: Riffer::Rig::Hosts::_Host, ?cwd: String?, ?name: String, ?instructions: String?, ?credentials: Hash[Symbol, Hash[Symbol, String]], ?env: Riffer::Rig::Env, ?auth_path: String, ?settings_path: String, ?reasoning: String?, ?riffer_config: Riffer::Config, ?mcp_registry: Riffer::Rig::Mcp::_Registry, ?max_steps: Integer?, ?model_options: Hash[Symbol, untyped], ?native_tools: Hash[Symbol, untyped], ?max_tokens: Integer?, ?clock: ^() -> Float, ?snapshot: (Riffer::Rig::Runtime::Snapshot | Hash[Symbol, untyped])?) -> void
121
124
 
122
125
  # @rbs text: String
123
126
  # @rbs &: ?(::Riffer::StreamEvents::Base | Riffer::Rig::Events::_Event) -> void
@@ -240,11 +243,12 @@ class Riffer::Rig::Runtime
240
243
  def successor: (String model, Riffer::Agent::Config config) -> Riffer::Agent
241
244
 
242
245
  # The options the settings built for the starting model are provider-shaped
243
- # (anthropic cache control), so a switch re-derives them; the reasoning level
244
- # is provider-agnostic and travels on the config. Runs after the successor is
245
- # built, so a failed build leaves the running agent's options alone; riffer
246
- # reads config.model_options per request, so the swap still reaches the new
247
- # agent through the shared config.
246
+ # (anthropic cache control, each provider's output limit parameter), so a
247
+ # switch, or a restore onto another provider's model, re-derives them; the
248
+ # reasoning level is provider-agnostic and travels on the config. Runs after
249
+ # the successor is built, so a failed build leaves the running agent's
250
+ # options alone; riffer reads config.model_options per request, so the swap
251
+ # still reaches the new agent through the shared config.
248
252
  # @rbs model: String
249
253
  # @rbs return: void
250
254
  def rederive_options: (String model) -> void
@@ -1,11 +1,13 @@
1
1
  # Generated from lib/riffer/rig/settings/document.rb with RBS::Inline
2
2
 
3
3
  class Riffer::Rig::Settings::Document
4
- # @dynamic model, reasoning, catalog_files, providers, disabled, autoload, native_tools, save, reload
4
+ # @dynamic model, reasoning, max_tokens, catalog_files, providers, disabled, autoload, native_tools, save, reload
5
5
  attr_reader model: String?
6
6
 
7
7
  attr_reader reasoning: String?
8
8
 
9
+ attr_reader max_tokens: Integer?
10
+
9
11
  attr_reader catalog_files: Array[String]
10
12
 
11
13
  attr_reader providers: Hash[String, Hash[String, String]]
@@ -10,6 +10,19 @@ module Riffer::Rig::Settings::ModelOptions
10
10
  # tests and embedders can exercise the switches.
11
11
  NATIVE_TOOLS_BY_PROVIDER: Hash[Symbol, Hash[Symbol, bool]]
12
12
 
13
+ # Upstream candidate: riffer passes model_options to each provider's API
14
+ # unchanged, so rig names every provider's own output limit parameter until
15
+ # riffer accepts a provider-neutral option and translates it, as it does for
16
+ # reasoning.
17
+ MAX_TOKENS_PARAMETERS: Hash[Symbol, Array[Symbol]]
18
+
19
+ # Every other provider's API falls back to the model's own limit, but riffer's
20
+ # Anthropic provider sends 4096 unless told otherwise, and thinking spends
21
+ # from that same budget.
22
+ MAX_TOKENS_REQUIRED: Array[Symbol]
23
+
24
+ DEFAULT_MAX_TOKENS: ::Integer
25
+
13
26
  # @rbs model: String
14
27
  # @rbs return: String?
15
28
  def provider_for: (String model) -> String?
@@ -30,6 +43,11 @@ module Riffer::Rig::Settings::ModelOptions
30
43
  # @rbs return: Hash[Symbol, untyped]
31
44
  def model_options: (String model) -> Hash[Symbol, untyped]
32
45
 
46
+ # @rbs model: String
47
+ # @rbs max_tokens: Integer?
48
+ # @rbs return: Hash[Symbol, untyped]
49
+ def max_tokens_options: (String model, Integer? max_tokens) -> Hash[Symbol, untyped]
50
+
33
51
  # @rbs model: String
34
52
  # @rbs switches: Hash[Symbol, untyped]
35
53
  # @rbs return: Hash[Symbol, untyped]
@@ -1,20 +1,19 @@
1
1
  # Generated from lib/riffer/rig/terminal/replay/turn.rb with RBS::Inline
2
2
 
3
3
  class Riffer::Rig::Terminal::Replay::Turn
4
- # @dynamic heading, answer, stats
4
+ # @dynamic heading, answer, stats, stop_reason
5
5
  attr_reader heading: String
6
6
 
7
7
  attr_reader answer: String
8
8
 
9
9
  attr_reader stats: Riffer::Rig::Terminal::TurnBuffer::Stats
10
10
 
11
+ attr_reader stop_reason: Symbol?
12
+
11
13
  # @rbs heading: String
12
14
  # @rbs answer: String
13
15
  # @rbs stats: Riffer::Rig::Terminal::TurnBuffer::Stats
16
+ # @rbs stop_reason: Symbol?
14
17
  # @rbs return: void
15
- def initialize: (heading: String, answer: String, stats: Riffer::Rig::Terminal::TurnBuffer::Stats) -> void
16
-
17
- # The record keeps no trace of how a turn ended.
18
- # @rbs return: bool
19
- def interrupted?: () -> bool
18
+ def initialize: (heading: String, answer: String, stats: Riffer::Rig::Terminal::TurnBuffer::Stats, stop_reason: Symbol?) -> void
20
19
  end
@@ -5,8 +5,6 @@ class Riffer::Rig::Terminal::TurnBuffer
5
5
 
6
6
  @settled_usage: Riffer::Providers::TokenUsage?
7
7
 
8
- @interrupted: bool
9
-
10
8
  @in_request: bool
11
9
 
12
10
  @steps: Integer
@@ -21,11 +19,13 @@ class Riffer::Rig::Terminal::TurnBuffer
21
19
 
22
20
  @clock: ^() -> Float
23
21
 
24
- # @dynamic ghost, tool
22
+ # @dynamic ghost, tool, stop_reason
25
23
  attr_reader ghost: String?
26
24
 
27
25
  attr_reader tool: String?
28
26
 
27
+ attr_reader stop_reason: Symbol?
28
+
29
29
  # @rbs clock: ^() -> Float
30
30
  # @rbs return: void
31
31
  def initialize: (clock: ^() -> Float) -> void
@@ -40,9 +40,6 @@ class Riffer::Rig::Terminal::TurnBuffer
40
40
  # @rbs return: String
41
41
  def prose: () -> String
42
42
 
43
- # @rbs return: bool
44
- def interrupted?: () -> bool
45
-
46
43
  # @rbs return: bool
47
44
  def ended?: () -> bool
48
45
 
@@ -5,6 +5,10 @@ module Riffer::Rig::Terminal::TurnReport
5
5
 
6
6
  INTERRUPTED: ::String
7
7
 
8
+ INTERRUPTIONS: Array[Symbol]
9
+
10
+ STOPPED: Hash[Symbol, String]
11
+
8
12
  COLUMN_HEAD: Regexp
9
13
 
10
14
  VISIBLE: Regexp
@@ -39,6 +43,13 @@ module Riffer::Rig::Terminal::TurnReport
39
43
  # @rbs return: String?
40
44
  def answer: (String source, theme: Riffer::Rig::Terminal::Theme, width: Integer?) -> String?
41
45
 
46
+ # @rbs turn: Riffer::Rig::Terminal::TurnReport::_Turn
47
+ # @rbs session: Riffer::Providers::TokenUsage?
48
+ # @rbs theme: Riffer::Rig::Terminal::Theme
49
+ # @rbs width: Integer?
50
+ # @rbs return: String
51
+ def closing: (Riffer::Rig::Terminal::TurnReport::_Turn turn, Riffer::Providers::TokenUsage? session, theme: Riffer::Rig::Terminal::Theme, width: Integer?) -> String
52
+
42
53
  # @rbs stats: Riffer::Rig::Terminal::TurnBuffer::Stats
43
54
  # @rbs session: Riffer::Providers::TokenUsage?
44
55
  # @rbs theme: Riffer::Rig::Terminal::Theme
@@ -8,7 +8,7 @@ module Riffer::Rig::Terminal::TurnReport
8
8
  # Riffer::Rig::Terminal::Replay::Turn one read back from the record.
9
9
  interface _Turn
10
10
  def answer: () -> String
11
- def interrupted?: () -> bool
11
+ def stop_reason: () -> ::Symbol?
12
12
  def stats: () -> ::Riffer::Rig::Terminal::TurnBuffer::Stats
13
13
  end
14
14
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riffer-rig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Bottrall
@@ -541,7 +541,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
541
541
  - !ruby/object:Gem::Version
542
542
  version: '0'
543
543
  requirements: []
544
- rubygems_version: 4.0.16
544
+ rubygems_version: 4.0.20
545
545
  specification_version: 4
546
546
  summary: A dead-simple terminal coding agent built on riffer.
547
547
  test_files: []