ruby_llm-ag_ui 0.2.0 → 0.4.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +52 -0
  3. data/README.md +1 -1
  4. data/docs/_advanced/client-example.md +11 -0
  5. data/docs/_advanced/provider-verification.md +70 -0
  6. data/docs/_advanced/rails-integration.md +5 -2
  7. data/docs/_advanced/security-and-deployment.md +2 -2
  8. data/docs/_advanced/worker-recovery.md +104 -0
  9. data/docs/_core_features/approval-and-resume.md +9 -0
  10. data/docs/_core_features/cancellation.md +84 -0
  11. data/docs/_core_features/reconnects.md +22 -1
  12. data/docs/_core_features/streaming-runs.md +14 -0
  13. data/docs/_getting_started/configuration.md +7 -2
  14. data/docs/_getting_started/whats-new-in-0-4.md +57 -0
  15. data/docs/_reference/api-reference.md +2 -1
  16. data/docs/_reference/compatibility.md +121 -11
  17. data/docs/_reference/public-api.md +102 -0
  18. data/docs/_reference/release-history.md +3 -1
  19. data/docs/_reference/releasing.md +10 -0
  20. data/docs/_reference/upgrading.md +17 -16
  21. data/docs/{_getting_started → _reference}/whats-new-in-0-2.md +2 -1
  22. data/docs/_reference/whats-new-in-0-3.md +62 -0
  23. data/lib/ruby_llm/ag_ui/configuration.rb +14 -11
  24. data/lib/ruby_llm/ag_ui/emitter.rb +6 -2
  25. data/lib/ruby_llm/ag_ui/error.rb +13 -2
  26. data/lib/ruby_llm/ag_ui/error_sanitizer.rb +2 -1
  27. data/lib/ruby_llm/ag_ui/immutable.rb +34 -0
  28. data/lib/ruby_llm/ag_ui/input.rb +5 -4
  29. data/lib/ruby_llm/ag_ui/interrupt.rb +10 -10
  30. data/lib/ruby_llm/ag_ui/mapper.rb +8 -0
  31. data/lib/ruby_llm/ag_ui/message_parser.rb +1 -1
  32. data/lib/ruby_llm/ag_ui/persistence.rb +18 -0
  33. data/lib/ruby_llm/ag_ui/rails/active_record_store.rb +21 -11
  34. data/lib/ruby_llm/ag_ui/rails/record.rb +8 -3
  35. data/lib/ruby_llm/ag_ui/rails/streaming.rb +3 -3
  36. data/lib/ruby_llm/ag_ui/reconnect.rb +1 -1
  37. data/lib/ruby_llm/ag_ui/resume.rb +9 -5
  38. data/lib/ruby_llm/ag_ui/resume_entry.rb +3 -3
  39. data/lib/ruby_llm/ag_ui/run.rb +18 -18
  40. data/lib/ruby_llm/ag_ui/run_record.rb +27 -14
  41. data/lib/ruby_llm/ag_ui/sse_writer.rb +16 -4
  42. data/lib/ruby_llm/ag_ui/store/base.rb +24 -1
  43. data/lib/ruby_llm/ag_ui/store/memory_store.rb +6 -10
  44. data/lib/ruby_llm/ag_ui/validation.rb +1 -1
  45. data/lib/ruby_llm/ag_ui/version.rb +1 -1
  46. metadata +31 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8529d394d1ef5d52bc73952e047ee5303634af7aa7738cc894acc8dde378f8b
4
- data.tar.gz: ed676da00af762d17fbf6d1a743b995f03d1e7744aba9afb985b95c20bedf93f
3
+ metadata.gz: 7e2fef2885431f82e496f0e1682bbd6d11ed036a6dcda941353e5f70d22e9589
4
+ data.tar.gz: 06d1631a5e98ecfea25a53dd9ea9f40c235f2fea871fcc7d4fb9e2b707596439
5
5
  SHA512:
6
- metadata.gz: 34df865e3f9dd71cbf573ad7a89d19259d16931685cb153df6aab6e989d92be68407f6207e654fc44f615b625a840a90a44e6c4e725e5781e976e253d6744457
7
- data.tar.gz: 40c5c7fd607e2ce6ccd54e53e6e6e8c2482bf7645d3155e4cdf0eedb95c58f3337bb481650a44c902863629a52bc70cd03dd4224ecaad2ab0546a947f633a0e1
6
+ metadata.gz: bc183b5b76a8f3f92a27feb731a879780b454425a95c024bfc5ebba2c23f006ec2da5c2682c1c2074dcb4a946650d3941aa0482915c3987873c5bcc420613f3e
7
+ data.tar.gz: 19da3e02abe3806802bbe4efee68138a3a8b7e31477ae43a7085511f748dd88df59c71ba12398bf84310a74c7e57fca8ee25581e26d9ce797816ca95f5b5f3db
data/CHANGELOG.md CHANGED
@@ -6,6 +6,58 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.4.0] - 2026-10-21
10
+
11
+ ### Added
12
+
13
+ - A proposed public application and custom-store contract, with orchestration
14
+ internals excluded from generated API documentation.
15
+ - Explicit RubyLLM 2.1.0 and 2.1.1 CI matrices, and a shared intercepted/live
16
+ OpenRouter harness for text, approval, result association, and reconnect.
17
+ - Client-state assertions for one original tool call and one associated result.
18
+
19
+ ### Changed
20
+
21
+ - Remove the unused `allow_client_history` configuration and diagnostic key.
22
+ Client messages remain untrusted data under host-controlled history policy.
23
+ - Reject unsupported `protocol_version` configuration instead of accepting a
24
+ setting that cannot change the producer's fixed 1.0 output.
25
+
26
+ ### Fixed
27
+
28
+ - Expose the returned reconnect outcome through `Run#record`, without executing
29
+ the chat again. Verify real RubyLLM denial and installed result association.
30
+ - Resume real RubyLLM approval without repeating the original tool-call start
31
+ and arguments. Its result keeps the original call id; new calls still stream.
32
+ - Isolate and freeze nested input, identity, interrupt, and JSON record values.
33
+ Editing caller-owned data cannot mutate memory-store indexes or bypass a
34
+ record revision; editing published values raises `FrozenError`.
35
+
36
+ ## [0.3.0] - 2026-10-20
37
+
38
+ ### Added
39
+
40
+ - Explicit stopped-worker recovery with a `worker_lost` outcome, retaining run
41
+ identity and exposing unknown tool effects for host reconciliation.
42
+ - Atomic storage revisions and independent-process SQLite reservation,
43
+ approval redemption, conflicting-write, and worker-death tests.
44
+ - Exact-run, actor-scoped cancellation and HTTP abort workflows in the offline
45
+ browser example, plus real RubyLLM HTTP timeout and cancellation checkpoints
46
+ verified without a provider connection.
47
+
48
+ ### Fixed
49
+
50
+ - Continue a live run after its response transport disconnects, preserving the
51
+ real outcome and side-effect identity instead of failing the run on a write.
52
+ - Reject stale record writes and preserve uncertain database-write outcomes.
53
+ Disable callbacks even when a producer cannot persist its final record.
54
+ - Keep uncertain reservation and approval acknowledgements separate from run
55
+ failures, without executing a provider turn or guessing whether a decision committed.
56
+ - Recognize Puma connection failures as disconnected transports and classify
57
+ Faraday timeouts as `transport_timeout` instead of generic transport errors.
58
+ - Require JSON 2.x so Rails 8.0 can load a real RubyLLM chat without passing
59
+ a removed `quirks_mode` option to JSON 3.
60
+
9
61
  ## [0.2.0] - 2026-10-19
10
62
 
11
63
  ### Added
data/README.md CHANGED
@@ -19,7 +19,7 @@ RubyLLM and AG-UI maintainers.
19
19
  ## Install
20
20
 
21
21
  ```ruby
22
- gem 'ruby_llm-ag_ui', '~> 0.2.0'
22
+ gem 'ruby_llm-ag_ui', '~> 0.4.0'
23
23
  ```
24
24
 
25
25
  Requires Ruby >= 3.2, RubyLLM >= 2.1 and < 3.0, and `ag-ui-protocol` 0.2.x.
@@ -45,6 +45,17 @@ redacted by default. Approved tools also publish synthetic progress counts;
45
45
  the host policy withholds progress messages. The text, sanitized failure, and cancelled scenarios show
46
46
  the other run outcomes.
47
47
 
48
+ During approved progress, **Cancel server run** requests cancellation for the
49
+ exact fixture actor, thread, and run. The host rejects another actor, an old
50
+ run id, or a completed run. The synthetic tool checks cancellation before its
51
+ effect. This does not establish cancellation latency for a real provider or
52
+ arbitrary tool.
53
+
54
+ **Disconnect stream** calls the client's HTTP abort. The producer keeps running
55
+ and records its actual outcome. Reconnect after it finishes to read that result
56
+ without repeating the tool. An early reconnect is refused while the host still
57
+ owns the active chat. The timeout scenario produces a sanitized recorded failure.
58
+
48
59
  Use **Reconnect completed run** after a successful turn. The client sends the
49
60
  original input and receives the recorded outcome and snapshot; no new model
50
61
  turn or text delta is produced.
@@ -0,0 +1,70 @@
1
+ ---
2
+ layout: default
3
+ title: Provider Verification
4
+ nav_order: 6
5
+ description: Run opt-in provider checks separately from offline client and protocol tests.
6
+ ---
7
+
8
+ # {{ page.title }}
9
+
10
+ {{ page.description }}
11
+ {: .fs-6 .fw-300 }
12
+
13
+ After reading this guide, you will know:
14
+
15
+ * How to run the maintained live checks with synthetic input.
16
+ * What the checks verify and which calls can reach a provider.
17
+ * How to keep credentials and provider results out of shared evidence.
18
+
19
+ ## Run the Opt-in Checks
20
+
21
+ From the repository, with `OPENROUTER_API_KEY` already configured:
22
+
23
+ ```sh
24
+ RUBY_LLM_LIVE=1 bundle exec rspec spec/live
25
+ ```
26
+
27
+ The harness uses OpenRouter with `openai/gpt-4.1-mini`. Set
28
+ `RUBY_LLM_LIVE_MODEL` to choose another OpenRouter model; record its name and
29
+ result separately. A successful model does not verify every model on the gateway.
30
+ These calls can incur provider charges. Default offline tests never run them.
31
+
32
+ If you use an environment file, keep it untracked and load it through dotenv:
33
+
34
+ ```sh
35
+ RUBY_LLM_LIVE=1 bundle exec dotenv -f .env.live rspec spec/live
36
+ ```
37
+
38
+ Set the key in that file or your existing credential manager. Do not put keys
39
+ in command arguments, inline exports, screenshots, or committed fixtures.
40
+ The repository ignores `.env*` files except `.env.example`.
41
+
42
+ ## Understand the Checks
43
+
44
+ One example streams a short text response. Another forces a synthetic lookup
45
+ that requires approval, verifies no tool execution before approval, resumes the
46
+ original call, and reconnects the completed resume. The tool only returns a
47
+ fixture value; it does not access a database, file, or business service.
48
+ Its result is redacted and retains the original tool-call id.
49
+
50
+ The provider configuration disables retries, caps output at 128 tokens, uses
51
+ a 30-second request timeout, and discards provider logs. The live network
52
+ allowlist permits only the OpenRouter HTTPS chat-completions endpoint. This
53
+ allowlist is a test guard, not an operating-system firewall.
54
+
55
+ An offline test drives the same setup through intercepted HTTP. It verifies
56
+ the bounded request and reproduces the real RubyLLM approval callbacks without
57
+ credentials. Browser tests continue to use the maintained synthetic host; they
58
+ verify the official client's message and tool-result association separately.
59
+
60
+ ## Record Evidence Without Secrets
61
+
62
+ Record the date, Ruby and RubyLLM versions, provider route, model, pass/fail
63
+ result, and any fixed regression. Keep generated evidence under ignored `tmp/`.
64
+ Do not save raw HTTP headers or provider traces. A failed assertion, intercepted
65
+ request, or schema-valid event is not proof that a live request completed.
66
+
67
+ For the recorded results and unverified paths, read
68
+ [Compatibility]({% link _reference/compatibility.md %}). Live cancellation,
69
+ timeouts, and network-loss timing require separate provider evidence; offline
70
+ fault injection does not establish those provider behaviors.
@@ -106,8 +106,11 @@ what makes run identity survive a worker:
106
106
 
107
107
  - `reserve` inserts; a `RecordNotUnique` means another worker won, and the
108
108
  existing row is attached or refused by digest.
109
- - `redeem_interrupt` runs under `row.with_lock`, so exactly one resume records a
110
- decision and the tool runs once.
109
+ - `redeem_interrupt` uses a conditional update and revalidates competing
110
+ decisions, so only one caller redeems an approval.
111
+ - `save` checks record revisions and refuses stale writers. Keep its returned
112
+ record for the next update. See [Worker Recovery]({% link _advanced/worker-recovery.md %})
113
+ before closing a run whose producer stopped.
111
114
  - `find_interrupt` is scoped by `(scope, thread_id, interrupt_id)`, so an
112
115
  interrupt id is not a global key.
113
116
 
@@ -43,8 +43,8 @@ responsibility.
43
43
  - **Choose the model, tools or system prompt.** `input.tools` is informational:
44
44
  `Input#tool_names` and `Input#client_tools?` report it, and nothing in the gem
45
45
  registers a client-supplied tool on the chat. `input.messages` is parsed and
46
- echoed, never appended to the chat as trusted turns; `config.allow_client_history`
47
- is off and documented as off.
46
+ echoed, never appended to the chat as trusted turns. The host owns history
47
+ reconciliation; this gem has no switch that imports client history.
48
48
  - **Reach another actor's run.** Every lookup is bounded by the scope the host
49
49
  supplies. The same `(threadId, runId)` under a different scope is a different
50
50
  run (`spec/ruby_llm/ag_ui/run_spec.rb`: "does not let one scope attach to
@@ -0,0 +1,104 @@
1
+ ---
2
+ layout: default
3
+ title: Worker Recovery
4
+ nav_order: 4
5
+ description: Close a run after confirmed worker loss without repeating unknown tool effects.
6
+ ---
7
+
8
+ # {{ page.title }}
9
+
10
+ {{ page.description }}
11
+ {: .fs-6 .fw-300 }
12
+
13
+ After reading this guide, you will know:
14
+
15
+ * How to close a run whose worker has stopped.
16
+ * How record revisions prevent stale writes.
17
+ * Why recovery cannot prove or undo tool effects.
18
+
19
+ ## Recover a Stopped Worker
20
+
21
+ First confirm through your process manager that the producer has stopped.
22
+ Then load its record using an authorized scope and exact identity:
23
+
24
+ ```ruby
25
+ record = store.find(scope: authenticated_scope, thread_id: thread_id, run_id: run_id)
26
+ raise 'Run not found' unless record
27
+
28
+ # The host has confirmed that the producer and its tool threads have stopped.
29
+ recovered = store.recover(record)
30
+ recovered.status # => :failed
31
+ recovered.failure.fetch('code') # => 'worker_lost'
32
+ ```
33
+
34
+ Use `ActiveRecordStore` when the record must survive a process exit. Recovery
35
+ changes a reserved or started record to failed. It retains the identity,
36
+ snapshot, and input digest. The original request can reconnect to a sanitized
37
+ `RUN_ERROR` with code `worker_lost`; it cannot execute the run again.
38
+
39
+ Recovery does not stop a worker. A timeout, disconnected browser, or old
40
+ `updated_at` value does not prove the worker is dead. Confirm that all producer
41
+ and tool activity has stopped before calling this method. The gem does not
42
+ provide leases, worker discovery, or automatic recovery.
43
+
44
+ ## Keep the Latest Record
45
+
46
+ Each successful store write increments `RunRecord#revision`. Keep the record
47
+ returned by `save` if you write it again:
48
+
49
+ ```ruby
50
+ record = store.save(record.start(now: Time.now))
51
+ record = store.save(record.finish(:succeeded, now: Time.now))
52
+ ```
53
+
54
+ `save` and `recover` raise `StaleRecordError` when the stored revision changed
55
+ since you read it. This error is a `RunConflictError`. Reload and inspect the
56
+ current outcome before making another decision. A terminal outcome cannot be
57
+ replaced by recovery. The revision is separate from event sequence numbers.
58
+
59
+ The memory store checks revisions under its mutex. The ActiveRecord store uses
60
+ a conditional database update against the observed payload. Competing approval
61
+ redemptions reload and revalidate after a conflict; a repeated decision is a
62
+ replay, and a disagreeing decision is refused.
63
+
64
+ ## Handle an Uncertain Database Write
65
+
66
+ `Run#stream` raises `PersistenceError` if storage fails without a reliable
67
+ acknowledgement. It does not attempt another terminal write or send a guessed
68
+ `RUN_ERROR`. The first write may already have committed. When storage becomes
69
+ available, reload the exact identity. Reconnect if it ended; confirm the worker
70
+ has stopped before recovering a non-terminal record.
71
+
72
+ This applies to identity reservation and approval redemption as well as status
73
+ writes. If approval acknowledgement is lost, the decision may already be stored
74
+ even though the chat never received it. Inspect both records and reconcile the
75
+ chat; do not issue a new resume or execute the tool on the assumption that the
76
+ decision failed.
77
+
78
+ A stale or failed producer disables its mapper callbacks before returning, so
79
+ reusing its chat cannot append events to that old stream.
80
+
81
+ ## Reconcile External Effects
82
+
83
+ A tool may complete its external change before the worker dies. A recovered
84
+ record says that execution ended without a recorded outcome; it does not say
85
+ that the tool failed or that no effect occurred. Inspect the external system
86
+ and use host-owned idempotency keys before starting another run. Never delete
87
+ the reservation to retry an uncertain effect. The gem does not promise
88
+ exactly-once external effects across crashes.
89
+
90
+ The host also serializes different run ids that share one mutable chat. Run
91
+ identity and approval redemption do not lock an entire conversation.
92
+
93
+ ## Upgrade the Store Contract
94
+
95
+ The revision lives in the JSON payload, so the shipped table needs no new
96
+ migration. Records written before 0.3 load with revision zero. Drain old workers
97
+ before upgrading: a 0.2 writer does not honor the new conditional-write contract.
98
+ Custom stores must implement atomic revision checks, return the incremented
99
+ record from `save`, and provide the same recovery semantics as `Store::Base`.
100
+
101
+ ## Next Steps
102
+
103
+ * [Reconnects and Run Identity]({% link _core_features/reconnects.md %}) - report a recorded outcome.
104
+ * [Security and Deployment]({% link _advanced/security-and-deployment.md %}) - keep authorization in the host.
@@ -60,3 +60,12 @@ The interrupt must still be pending and unexpired. The tool call id and argument
60
60
  * [Streaming Runs]({% link _core_features/streaming-runs.md %}) - follow the event and outcome sequence.
61
61
  * [Reconnects and Run Identity]({% link _core_features/reconnects.md %}) - understand stored run identity.
62
62
  * [Security and Deployment]({% link _advanced/security-and-deployment.md %}) - keep approval separate from authorization.
63
+
64
+
65
+ ## Keep the Original Tool Call
66
+
67
+ RubyLLM fires its before-tool callback when an approved call executes. The
68
+ resume run does not repeat the original `TOOL_CALL_START`, arguments, or end.
69
+ Its `TOOL_CALL_RESULT` uses the original `toolCallId`. A later new tool call
70
+ still emits its own start and arguments. Keep the client conversation across
71
+ both runs so the result can attach to the call shown before the interrupt.
@@ -0,0 +1,84 @@
1
+ ---
2
+ layout: default
3
+ title: Cancellation and Timeouts
4
+ nav_order: 5
5
+ description: Request cancellation on the authorized producer and distinguish it from a disconnected stream or provider timeout.
6
+ ---
7
+
8
+ # {{ page.title }}
9
+
10
+ {{ page.description }}
11
+ {: .fs-6 .fw-300 }
12
+
13
+ After reading this guide, you will know:
14
+
15
+ * How to request cancellation on the producer's chat.
16
+ * Why aborting a browser request does not cancel server work.
17
+ * How provider timeouts become recorded failures.
18
+
19
+ ## Request Cancellation in the Host
20
+
21
+ Resolve the active chat through your host's authenticated registry, using the
22
+ exact actor, thread, and run identity. The lookup below is application code:
23
+
24
+ ```ruby
25
+ chat = authorized_active_chat_for(current_actor, thread_id: thread_id, run_id: run_id)
26
+ chat.cancel
27
+ ```
28
+
29
+ RubyLLM checks cancellation cooperatively. When it raises `CancelledError`,
30
+ `Run` closes open content and persists a cancelled outcome. The client receives
31
+ `RUN_FINISHED` with `outcome.type` equal to `cancelled`. A cancellation request
32
+ is not proof that the run has stopped; wait for its recorded outcome.
33
+
34
+ Reject a cancellation for another actor, a previous run, or an inactive chat.
35
+ Otherwise a delayed cancellation can stop a later turn. The host serializes
36
+ operations on a mutable chat and delivers cancellation to the worker that owns
37
+ it. Calling `cancel` on a newly loaded chat in another process does not cancel
38
+ the original in-memory object. The gem supplies no cross-worker message broker.
39
+
40
+ ## Keep HTTP Abort Separate
41
+
42
+ `HttpAgent#abortRun()` stops the browser's HTTP subscription. It does not call
43
+ `Chat#cancel`. While the producer remains alive, the gem detaches its failed
44
+ writer and continues to record the actual outcome. Reconnect with the same
45
+ input and run id after completion to read that result.
46
+
47
+ Wire an explicit, authorized cancellation endpoint when your application needs
48
+ server cancellation. The maintained client example shows both actions. See
49
+ [Client Example]({% link _advanced/client-example.md %}).
50
+
51
+ ## Bound Provider Requests
52
+
53
+ Set provider transport limits through RubyLLM's context:
54
+
55
+ ```ruby
56
+ context = RubyLLM.context do |config|
57
+ config.request_timeout = 30
58
+ config.max_retries = 0
59
+ end
60
+ chat = context.chat(model: 'gpt-4o-mini')
61
+ ```
62
+
63
+ A provider request timeout ends the AG-UI run as failed, with a sanitized
64
+ `RUN_ERROR` code `transport_timeout`. Reconnecting reports the same failure
65
+ without a new provider request. A timeout is not a cancelled outcome.
66
+
67
+ The request timeout does not bound an entire multi-request turn or a local
68
+ tool. Provider retries can extend elapsed time. Put deadlines and cancellation
69
+ checkpoints in your tools and reconcile external effects before retrying an
70
+ uncertain action. Cancellation cannot undo a tool that already changed an
71
+ external system.
72
+
73
+ ## Check the Offline Evidence
74
+
75
+ `spec/integration/provider_lifecycle_spec.rb` runs the real RubyLLM chat with an
76
+ intercepted HTTP request. It verifies timeout classification and cancellation
77
+ before a provider request. It uses synthetic configuration and makes no live
78
+ provider call. Browser fixtures separately exercise host cancellation and
79
+ HTTP abort; they do not establish a provider's cancellation latency.
80
+
81
+ ## Next Steps
82
+
83
+ * [Streaming Runs]({% link _core_features/streaming-runs.md %}) - understand terminal outcomes.
84
+ * [Worker Recovery]({% link _advanced/worker-recovery.md %}) - close a run after confirmed worker death.
@@ -37,12 +37,33 @@ run id is a conflict.
37
37
 
38
38
  ## Choose a Store
39
39
 
40
- `MemoryStore` is suitable for tests and a single process. Its records disappear on restart and are not shared between workers. The Rails adapter's `ActiveRecordStore` persists records and redeems interrupts under a database lock.
40
+ `MemoryStore` is suitable for tests and a single process. Its records disappear on restart and are not shared between workers. The Rails adapter's `ActiveRecordStore` persists records and redeems interrupts with atomic conditional updates.
41
41
 
42
42
  The store boundary is `RubyLLM::AgUI::Store::Base`. Configure a compatible store globally or pass it to `Run.new`. For multi-process deployments, the database must enforce unique run identity and serialize interrupt redemption.
43
43
 
44
+ Store writes check `RunRecord#revision` and refuse stale snapshots. A run whose
45
+ worker died remains non-terminal until the host confirms the worker stopped
46
+ and explicitly recovers it. See
47
+ [Worker Recovery]({% link _advanced/worker-recovery.md %}) before changing a
48
+ stuck record; deleting its reservation can repeat unknown tool effects.
49
+
44
50
  ## Next Steps
45
51
 
46
52
  * [Configuration]({% link _getting_started/configuration.md %}) - set the default store.
47
53
  * [Rails Integration]({% link _advanced/rails-integration.md %}) - install the durable ActiveRecord store.
48
54
  * [Protocol Coverage]({% link _reference/protocol-coverage.md %}) - inspect reconnect events.
55
+
56
+
57
+ ## Keep Request and Record Values Read-only
58
+
59
+ Parsed input, run identity, and JSON snapshots are isolated from the objects
60
+ supplied by the caller. Nested strings, arrays, hashes, and parsed SDK message
61
+ models are frozen. Editing them raises `FrozenError`; it cannot change the
62
+ reserved digest or bypass a store revision check. Constructors copy JSON values
63
+ rather than freezing the host's original state. Keep snapshots JSON-compatible.
64
+
65
+ Create a new input with `Input.parse` for a new request. Use `RunRecord`
66
+ transitions and retain `store.save`'s returned record when updating storage.
67
+
68
+ After `Run#stream` returns a recorded outcome, `Run#record` exposes that same
69
+ record, including on a reconnect. Reading it never executes the chat.
@@ -42,9 +42,23 @@ An assistant message opens on its first non-empty chunk and closes before a tool
42
42
 
43
43
  The run record reaches a terminal state before the terminal event is written. If the connection closes in the middle, the record remains available for a later reconnect.
44
44
 
45
+ ## When the Client Disconnects
46
+
47
+ The producer detaches a failed transport and continues the same chat turn while
48
+ its worker stays alive. A broken connection does not cancel the provider or
49
+ undo a tool. The store retains the real success, failure, approval pause, or
50
+ cancelled outcome. A retry while the turn is running is refused; after it ends,
51
+ the same input and run id receive the recorded outcome without execution.
52
+
53
+ This also applies when the first write or a flush fails. A terminal write
54
+ failure cannot replace an outcome that is already persisted. `SSEWriter` used
55
+ directly raises `TransportError`, a subclass of `StreamError`; `Run` handles
56
+ that transport error. Mapping and persistence errors are separate failures.
57
+
45
58
  ## Next Steps
46
59
 
47
60
  * [Validating Input]({% link _core_features/input-validation.md %}) - parse untrusted request data.
48
61
  * [Tool Progress]({% link _core_features/tool-progress.md %}) - publish local tool updates.
62
+ * [Cancellation and Timeouts]({% link _core_features/cancellation.md %}) - connect host cancellation to the active chat.
49
63
  * [Approval and Resume]({% link _core_features/approval-and-resume.md %}) - answer an interrupt on a new run.
50
64
  * [Reconnects and Run Identity]({% link _core_features/reconnects.md %}) - serve a completed run again.
@@ -40,14 +40,19 @@ The global configuration supplies defaults. `Run.new` can override the store, lo
40
40
  | `redact` | `Redaction.default` | Transform tool results before they reach the stream. |
41
41
  | `emit_tool_progress` | `false` | Publish tool progress as redacted activity snapshots. |
42
42
  | `logger` | `nil` | Receive host-side diagnostics without prompts or raw tool payloads. |
43
- | `protocol_version` | `"1.0"` | Value reported by `RUN_STARTED`. |
43
+ | `protocol_version` | `"1.0"` | Fixed supported version reported by `RUN_STARTED`; setting another value raises `ConfigurationError`. |
44
44
  | `max_input_bytes` | `256_000` | Maximum request body size. |
45
45
  | `max_messages` | `500` | Maximum messages in one request. |
46
46
  | `max_tools` | `64` | Maximum tool definitions in one request. |
47
47
  | `max_context` | `64` | Maximum context entries in one request. |
48
48
  | `interrupt_ttl` | `900` seconds | How long an approval interrupt can be answered. |
49
49
  | `clock` | `Time.now.utc` | Clock used to set interrupt expiry. |
50
- | `allow_client_history` | `false` | Reserved for future history behavior; client history is not trusted in this release. |
50
+
51
+ `Configuration#protocol_version=` accepts only `"1.0"`. Its value describes the
52
+ producer; it does not select another event schema.
53
+
54
+ Client history stays under host control. There is no configuration switch that
55
+ trusts or imports it into a chat.
51
56
 
52
57
  Provider keys and model selection are configured through RubyLLM and the host app. This gem does not read credentials when it loads.
53
58
 
@@ -0,0 +1,57 @@
1
+ ---
2
+ layout: default
3
+ title: "What's New in 0.4"
4
+ nav_order: -1
5
+ description: Review the public integration contract and verified compatibility boundaries.
6
+ ---
7
+
8
+ # {{ page.title }}
9
+
10
+ {{ page.description }}
11
+ {: .fs-6 .fw-300 }
12
+
13
+ After reading this guide, you will know:
14
+
15
+ * Which configuration changes need an application update.
16
+ * Where to find the proposed public API and compatibility evidence.
17
+
18
+ ## Use Effective Configuration
19
+
20
+ ```ruby
21
+ RubyLLM::AgUI.configure do |config|
22
+ config.protocol_version = '1.0'
23
+ end
24
+ ```
25
+
26
+ Other protocol versions raise `ConfigurationError`. The unused
27
+ `allow_client_history` setting is removed. Client history remains the host's
28
+ responsibility. See [Upgrading]({% link _reference/upgrading.md %}).
29
+
30
+ ## Preserve Immutable Request and Store Values
31
+
32
+ Parsed input and JSON record values now copy and freeze their nested members.
33
+ Changing a caller's original state cannot change a stored snapshot or identity.
34
+ Use new inputs and record transitions instead of editing nested values. See
35
+ [Reconnects]({% link _core_features/reconnects.md %}).
36
+
37
+ The [Public API Contract]({% link _reference/public-api.md %}) identifies
38
+ application and custom-store APIs and separates orchestration internals.
39
+
40
+ ## Associate Resumed Tool Results Once
41
+
42
+ Real RubyLLM approval resumes now emit the result of the original call without
43
+ repeating its start and arguments. The offline real-chat and opt-in provider
44
+ checks use the same harness. `Run#record` also exposes the recorded outcome
45
+ after a reconnect, matching the return value from `stream`. See
46
+ [Approval and Resume]({% link _core_features/approval-and-resume.md %}).
47
+
48
+ ## Verify the Provider Separately
49
+
50
+ The opt-in harness checks OpenRouter text and a synthetic approval/resume
51
+ without external business effects. The same real RubyLLM chat setup has offline
52
+ HTTP tests. See [Provider Verification]({% link _advanced/provider-verification.md %})
53
+ for credential handling, request limits, and the scope of the results.
54
+
55
+ Read
56
+ [Compatibility]({% link _reference/compatibility.md %}) for recorded results
57
+ and limits; an intended matrix is not a completed verification.
@@ -11,7 +11,8 @@ description: Browse RDoc pages generated from classes and methods in the gem sou
11
11
  {{ page.description }}
12
12
  {: .fs-6 .fw-300 }
13
13
 
14
- The [API reference]({{ '/api/' | relative_url }}) opens on the `RubyLLM` module. The generated pages follow the RDoc comments in `lib/`.
14
+ Read the [Public API Contract]({% link _reference/public-api.md %}) before
15
+ depending on a class. The [API reference]({{ '/api/' | relative_url }}) opens on the `RubyLLM` module. The generated pages follow the RDoc comments in `lib/`.
15
16
 
16
17
  | Build with | Reference |
17
18
  | --- | --- |