Class: Xeno::Configuration
- Inherits:
-
Object
- Object
- Xeno::Configuration
- Defined in:
- lib/xeno/configuration.rb
Overview
Instance Attribute Summary collapse
-
#authenticate ⇒ Object
Fail-closed HTTP auth lambda.
-
#compaction_context_window ⇒ Object
Fallback context window (tokens) for models the registry doesn't know (assume_model_exists).
-
#compaction_tail_turns ⇒ Object
How many of the most recent user-message-anchored turns survive a compaction verbatim (the "recent tail").
-
#compaction_threshold ⇒ Object
Compaction triggers when the last model call's context usage crosses this fraction of the model's context window.
- #heartbeat_interval ⇒ Object
-
#max_input_tokens_per_session ⇒ Object
Per-session token budgets, enforced before each model call from the persisted usage counts, independently per axis.
-
#max_output_tokens_per_session ⇒ Object
Per-session token budgets, enforced before each model call from the persisted usage counts, independently per axis.
-
#max_steps ⇒ Object
Per-turn model-call budget: a turn must bound its model calls.
-
#max_turn_attempts ⇒ Object
A turn whose claim ledger reaches this many attempts is poison — it fails instead of retrying forever.
-
#stopping_check ⇒ Object
Optional lambda answering "is the worker shutting down?", probed between steps.
-
#stream_catch_up_batch ⇒ Object
How many events one stream poll reads at most.
-
#stream_max_duration ⇒ Object
Optional hard cap on how long one SSE connection is served (seconds).
-
#stream_poll_interval ⇒ Object
How often the SSE stream polls for new events, in seconds.
-
#stream_shutdown_check ⇒ Object
Optional lambda answering "is the server shutting down?" — when true, open SSE streams close themselves so a graceful stop doesn't wait out the in-flight-request window (Ctrl-C stays near-instant with tabs open).
-
#turn_stale_after ⇒ Object
A running turn whose heartbeat is older than this is presumed dead and reclaimable.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/xeno/configuration.rb', line 73 def initialize @max_steps = 20 @max_turn_attempts = 5 @turn_stale_after = 5 * 60 # seconds @heartbeat_interval = nil @max_input_tokens_per_session = nil @max_output_tokens_per_session = nil @compaction_threshold = 0.9 @compaction_context_window = nil @compaction_tail_turns = 2 @stopping_check = nil @authenticate = nil @stream_poll_interval = 0.25 @stream_catch_up_batch = 500 @stream_max_duration = nil @stream_shutdown_check = nil end |
Instance Attribute Details
#authenticate ⇒ Object
Fail-closed HTTP auth lambda. Receives the request; a falsy return is a 401; a truthy return becomes the request principal.
54 55 56 |
# File 'lib/xeno/configuration.rb', line 54 def authenticate @authenticate end |
#compaction_context_window ⇒ Object
Fallback context window (tokens) for models the registry doesn't know (assume_model_exists). nil = automatic compaction never triggers for unknown-window models.
40 41 42 |
# File 'lib/xeno/configuration.rb', line 40 def compaction_context_window @compaction_context_window end |
#compaction_tail_turns ⇒ Object
How many of the most recent user-message-anchored turns survive a compaction verbatim (the "recent tail"). Everything earlier is summarized and replaced.
44 45 46 |
# File 'lib/xeno/configuration.rb', line 44 def compaction_tail_turns @compaction_tail_turns end |
#compaction_threshold ⇒ Object
Compaction triggers when the last model call's context usage crosses this fraction of the model's context window. nil/false disables automatic compaction (manual stays available).
36 37 38 |
# File 'lib/xeno/configuration.rb', line 36 def compaction_threshold @compaction_threshold end |
#heartbeat_interval ⇒ Object
95 96 97 |
# File 'lib/xeno/configuration.rb', line 95 def heartbeat_interval @heartbeat_interval || turn_stale_after / 4.0 end |
#max_input_tokens_per_session ⇒ Object
Per-session token budgets, enforced before each model call from the persisted usage counts,
independently per axis. The call that crosses a cap finishes; the next call fails the turn
with a budget.exceeded event, and the session recovers via reset. nil = unlimited. Per-agent
override: limits in agent.rb.
32 33 34 |
# File 'lib/xeno/configuration.rb', line 32 def max_input_tokens_per_session @max_input_tokens_per_session end |
#max_output_tokens_per_session ⇒ Object
Per-session token budgets, enforced before each model call from the persisted usage counts,
independently per axis. The call that crosses a cap finishes; the next call fails the turn
with a budget.exceeded event, and the session recovers via reset. nil = unlimited. Per-agent
override: limits in agent.rb.
32 33 34 |
# File 'lib/xeno/configuration.rb', line 32 def max_output_tokens_per_session @max_output_tokens_per_session end |
#max_steps ⇒ Object
Per-turn model-call budget: a turn must bound its model calls.
12 13 14 |
# File 'lib/xeno/configuration.rb', line 12 def max_steps @max_steps end |
#max_turn_attempts ⇒ Object
A turn whose claim ledger reaches this many attempts is poison — it fails instead of retrying forever.
16 17 18 |
# File 'lib/xeno/configuration.rb', line 16 def max_turn_attempts @max_turn_attempts end |
#stopping_check ⇒ Object
Optional lambda answering "is the worker shutting down?", probed between steps. When true the
turn releases its claim and re-enqueues itself, so a deploy-style stop resumes on the next
worker instead of waiting out stale-heartbeat reclaim. nil = ask the queue adapter's
stopping? (Solid Queue implements it; adapters that don't return false).
50 51 52 |
# File 'lib/xeno/configuration.rb', line 50 def stopping_check @stopping_check end |
#stream_catch_up_batch ⇒ Object
How many events one stream poll reads at most. Bounds the catch-up read on long sessions (a reconnect from index 0 pages through history in batches instead of loading every row in one query).
62 63 64 |
# File 'lib/xeno/configuration.rb', line 62 def stream_catch_up_batch @stream_catch_up_batch end |
#stream_max_duration ⇒ Object
Optional hard cap on how long one SSE connection is served (seconds). nil = until the session reaches a terminal status.
66 67 68 |
# File 'lib/xeno/configuration.rb', line 66 def stream_max_duration @stream_max_duration end |
#stream_poll_interval ⇒ Object
How often the SSE stream polls for new events, in seconds.
57 58 59 |
# File 'lib/xeno/configuration.rb', line 57 def stream_poll_interval @stream_poll_interval end |
#stream_shutdown_check ⇒ Object
Optional lambda answering "is the server shutting down?" — when true, open SSE streams close themselves so a graceful stop doesn't wait out the in-flight-request window (Ctrl-C stays near-instant with tabs open). nil = detect Puma's graceful stop automatically.
71 72 73 |
# File 'lib/xeno/configuration.rb', line 71 def stream_shutdown_check @stream_shutdown_check end |
#turn_stale_after ⇒ Object
A running turn whose heartbeat is older than this is presumed dead and reclaimable. Checkpoint replay makes takeover safe; a too-short window risks overlap with a live-but-slow owner, a too-long one stalls the session after a hard crash.
21 22 23 |
# File 'lib/xeno/configuration.rb', line 21 def turn_stale_after @turn_stale_after end |