mistri 0.6.1 → 0.8.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 (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +355 -2
  3. data/CONTRIBUTING.md +17 -3
  4. data/NOTICE +11 -0
  5. data/README.md +145 -226
  6. data/UPGRADING.md +810 -0
  7. data/assets/vendors/README.md +12 -0
  8. data/assets/vendors/claude-mark.svg +3 -0
  9. data/assets/vendors/gemini-mark.svg +10 -0
  10. data/assets/vendors/openai-mark-dark.svg +1 -0
  11. data/assets/vendors/openai-mark.svg +1 -0
  12. data/docs/README.md +2 -1
  13. data/docs/context-and-workspaces.md +84 -13
  14. data/docs/logging.md +90 -0
  15. data/docs/mcp.md +762 -21
  16. data/docs/reliability.md +210 -24
  17. data/docs/sessions.md +415 -36
  18. data/docs/sub-agents.md +85 -7
  19. data/docs/tool-contracts.md +528 -13
  20. data/examples/approval.rb +7 -7
  21. data/examples/browser.rb +1 -1
  22. data/examples/page_editor.rb +2 -2
  23. data/examples/quickstart.rb +1 -1
  24. data/lib/generators/mistri/install/templates/migration.rb.tt +4 -2
  25. data/lib/generators/mistri/mcp/mcp_generator.rb +2 -2
  26. data/lib/generators/mistri/mcp/templates/model.rb.tt +21 -8
  27. data/lib/mistri/agent.rb +839 -141
  28. data/lib/mistri/call_order.rb +137 -0
  29. data/lib/mistri/child.rb +69 -13
  30. data/lib/mistri/compaction.rb +200 -35
  31. data/lib/mistri/compactor/text.rb +91 -0
  32. data/lib/mistri/compactor.rb +474 -117
  33. data/lib/mistri/console.rb +44 -11
  34. data/lib/mistri/content.rb +70 -3
  35. data/lib/mistri/definition.rb +2 -2
  36. data/lib/mistri/edit.rb +13 -7
  37. data/lib/mistri/errors.rb +37 -0
  38. data/lib/mistri/event.rb +20 -9
  39. data/lib/mistri/locks/rails_cache.rb +16 -2
  40. data/lib/mistri/locks.rb +12 -3
  41. data/lib/mistri/mcp/client.rb +247 -61
  42. data/lib/mistri/mcp/conversation.rb +161 -0
  43. data/lib/mistri/mcp/egress.rb +5 -4
  44. data/lib/mistri/mcp/mirror.rb +90 -0
  45. data/lib/mistri/mcp/negotiation.rb +222 -0
  46. data/lib/mistri/mcp/oauth/client_identity.rb +53 -0
  47. data/lib/mistri/mcp/oauth/tolerance.rb +61 -0
  48. data/lib/mistri/mcp/oauth.rb +303 -82
  49. data/lib/mistri/mcp/results.rb +97 -0
  50. data/lib/mistri/mcp/sdk_client.rb +47 -0
  51. data/lib/mistri/mcp/wires.rb +325 -52
  52. data/lib/mistri/mcp.rb +304 -55
  53. data/lib/mistri/memory.rb +1 -1
  54. data/lib/mistri/message.rb +45 -8
  55. data/lib/mistri/models.rb +146 -24
  56. data/lib/mistri/partial_json.rb +5 -5
  57. data/lib/mistri/providers/anthropic/assembler.rb +40 -3
  58. data/lib/mistri/providers/anthropic/serializer.rb +154 -22
  59. data/lib/mistri/providers/anthropic.rb +77 -12
  60. data/lib/mistri/providers/fake.rb +4 -1
  61. data/lib/mistri/providers/gemini/assembler.rb +63 -3
  62. data/lib/mistri/providers/gemini/serializer.rb +27 -16
  63. data/lib/mistri/providers/gemini.rb +56 -11
  64. data/lib/mistri/providers/openai/assembler.rb +36 -5
  65. data/lib/mistri/providers/openai/serializer.rb +76 -22
  66. data/lib/mistri/providers/openai.rb +91 -14
  67. data/lib/mistri/reminder.rb +35 -3
  68. data/lib/mistri/result.rb +6 -4
  69. data/lib/mistri/result_limit.rb +164 -0
  70. data/lib/mistri/sandbox/quickjs.rb +345 -0
  71. data/lib/mistri/sandbox.rb +18 -0
  72. data/lib/mistri/schema.rb +26 -2
  73. data/lib/mistri/scratchpad.rb +107 -0
  74. data/lib/mistri/session/log.rb +137 -0
  75. data/lib/mistri/session.rb +405 -75
  76. data/lib/mistri/sinks/logger.rb +407 -0
  77. data/lib/mistri/skills.rb +10 -4
  78. data/lib/mistri/spawner.rb +43 -12
  79. data/lib/mistri/sse.rb +3 -2
  80. data/lib/mistri/stores/active_record.rb +30 -6
  81. data/lib/mistri/stores/jsonl.rb +26 -7
  82. data/lib/mistri/stores/memory.rb +6 -2
  83. data/lib/mistri/sub_agent/execution.rb +11 -3
  84. data/lib/mistri/sub_agent/runtime.rb +11 -1
  85. data/lib/mistri/sub_agent.rb +13 -4
  86. data/lib/mistri/tool.rb +71 -7
  87. data/lib/mistri/tool_arguments.rb +10 -11
  88. data/lib/mistri/tool_context.rb +15 -3
  89. data/lib/mistri/tool_executor.rb +49 -26
  90. data/lib/mistri/tool_result.rb +8 -2
  91. data/lib/mistri/tool_search/index.rb +193 -0
  92. data/lib/mistri/tool_search.rb +200 -0
  93. data/lib/mistri/tools/delete_file.rb +22 -0
  94. data/lib/mistri/tools/edit_file.rb +24 -14
  95. data/lib/mistri/tools/find_in_file.rb +1 -0
  96. data/lib/mistri/tools/grep.rb +212 -0
  97. data/lib/mistri/tools/list_files.rb +38 -5
  98. data/lib/mistri/tools/read_file.rb +83 -21
  99. data/lib/mistri/tools/read_memory.rb +2 -1
  100. data/lib/mistri/tools/run_code.rb +167 -0
  101. data/lib/mistri/tools/write_file.rb +66 -9
  102. data/lib/mistri/tools.rb +72 -1
  103. data/lib/mistri/transport/streamable_http.rb +140 -0
  104. data/lib/mistri/transport.rb +53 -63
  105. data/lib/mistri/usage.rb +33 -4
  106. data/lib/mistri/version.rb +1 -1
  107. data/lib/mistri/workspace/active_record.rb +22 -10
  108. data/lib/mistri/workspace/directory.rb +5 -1
  109. data/lib/mistri/workspace/memory.rb +4 -0
  110. data/lib/mistri/workspace/path_space.rb +56 -0
  111. data/lib/mistri/workspace/single.rb +6 -1
  112. data/lib/mistri.rb +28 -4
  113. metadata +30 -2
data/README.md CHANGED
@@ -18,15 +18,25 @@
18
18
  <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
19
19
  </p>
20
20
 
21
+ Mistri runs AI agents inside your own Ruby application, on your models, your
22
+ database, your authorization, and your queue. A run can stop and wait for a
23
+ human to approve a tool call, then finish hours later in a different process.
24
+ The gem declares zero runtime dependencies.
25
+
21
26
  A mistri (Urdu: مستری) is the fixer: the skilled tradesperson who actually
22
- gets it done. Mistri is an application-embedded agent runtime for Ruby. It owns
23
- the model loop, safe tool boundary, event stream, and append-only session
24
- record. Your application owns authorization, policy, presentation, and the
25
- semantics of its side effects.
27
+ gets it done. Mistri works in plain Ruby, Rails, Sinatra, Hanami, jobs, and
28
+ services.
26
29
 
27
- Mistri works in plain Ruby applications, including Rails, Sinatra, Hanami, jobs,
28
- and services. Rails integrations are optional. The gem declares zero runtime
29
- dependencies.
30
+ <p align="center">
31
+ <img src="assets/vendors/claude-mark.svg" height="30" alt="Claude">&nbsp;&nbsp;&nbsp;&nbsp;
32
+ <picture>
33
+ <source media="(prefers-color-scheme: dark)" srcset="assets/vendors/openai-mark-dark.svg">
34
+ <img src="assets/vendors/openai-mark.svg" height="30" alt="OpenAI">
35
+ </picture>&nbsp;&nbsp;&nbsp;&nbsp;
36
+ <img src="assets/vendors/gemini-mark.svg" height="30" alt="Gemini">
37
+ </p>
38
+
39
+ <p align="center">Anthropic, OpenAI, and Gemini, each through its own native protocol.</p>
30
40
 
31
41
  ## Start in sixty seconds
32
42
 
@@ -48,7 +58,7 @@ weather = Mistri::Tool.define(
48
58
  { city: args.fetch("city"), forecast: "34 C and clear" }
49
59
  end
50
60
 
51
- agent = Mistri.agent("claude-opus-4-8", tools: [weather])
61
+ agent = Mistri.agent("claude-opus-5-5", tools: [weather])
52
62
 
53
63
  result = agent.run("What should I wear in Lahore today? One sentence.") do |event|
54
64
  print event.delta if event.type == :text_delta
@@ -57,163 +67,117 @@ puts
57
67
  ```
58
68
 
59
69
  `Mistri.agent` infers the provider from the model ID and reads
60
- `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, or `GEMINI_API_KEY`. Pass `api_key:`
61
- explicitly when the host resolves credentials another way. A normally
62
- completed invocation returns a `Mistri::Result` with status
63
- predicates, final text, usage, and structured task output when requested.
64
- Host-contract failures raise as documented in [Reliability](docs/reliability.md).
65
-
66
- Runnable examples live in [`examples/`](examples).
67
-
68
- ## Why Mistri
69
-
70
- - **One session model.** The same append-only log runs over memory, JSONL,
71
- Active Record, or a host store. With a persistent store, runs can suspend,
72
- reload, resume, steer, and compact without inventing a second state model. See
73
- [Sessions and control](docs/sessions.md).
74
- - **Human approval does not hold a thread.** A gated tool parks the request and
75
- returns. With a shared store, another process can record the decision later;
76
- `resume` revalidates the exact call before execution.
77
- - **Provider semantics survive the abstraction.** Anthropic, OpenAI, and
78
- Gemini stream through direct implementations that retain each provider's
79
- reasoning, tool-pairing, and replay requirements. Unknown model IDs still
80
- pass through when their provider can be inferred.
81
- - **Tool input crosses a real boundary.** Completed model arguments are owned,
82
- bounded, validated, and deeply frozen before hooks, approval predicates, MCP,
83
- or handlers see them. See [Tool contracts](docs/tool-contracts.md).
84
- - **The runtime stays small.** The [gemspec](mistri.gemspec) declares no runtime
85
- gem dependencies. Optional Rails adapters load only when required.
86
- - **Real APIs are part of the test strategy.** The
87
- [live integration suite](CONTRIBUTING.md#setup)
88
- exercises critical control, persistence, delegation, MCP, and
89
- structured-output paths across all three providers when their keys are
90
- present. The default CI suite remains hermetic.
70
+ `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, or `GEMINI_API_KEY`. Runnable examples
71
+ live in [`examples/`](examples).
91
72
 
92
- ## Choose the right layer
73
+ ## Watch a run happen
93
74
 
94
- These projects solve different problems:
95
-
96
- | Need | Start with |
97
- | --- | --- |
98
- | A durable tool loop inside any Ruby application, with append-only sessions, approval, steering, compaction, linked workers, and provider-neutral MCP | **Mistri** |
99
- | Broad model access plus media, embeddings, image generation, and Rails-backed chat | [RubyLLM](https://github.com/crmne/ruby_llm) |
100
- | Agents expressed through Rails controllers, actions, callbacks, views, and Active Job | [Active Agent](https://github.com/activeagents/activeagent) |
101
-
102
- Mistri is deliberately not a terminal UI, hosted agent service, broad media
103
- client, policy engine, or exactly-once job system. The host application keeps
104
- its users, authorization rules, queues, database, UI, idempotency keys, and
105
- reconciliation policy. Mistri supplies the execution mechanism that connects
106
- them.
107
-
108
- ## How the loop works
75
+ ```ruby
76
+ Mistri.logger = Rails.logger # or any Logger-compatible object
77
+ ```
109
78
 
110
- 1. The input is appended to the session before the provider is called.
111
- 2. Provider events stream to the subscriber as the response arrives.
112
- 3. Completed tool calls cross Mistri's ownership and validation boundary.
113
- 4. Current host policy and approval rules run before a handler can start.
114
- 5. Tool results append to the same session, then the model continues until it
115
- answers, hands off the turn, suspends for approval, aborts, or reaches a
116
- budget.
79
+ ```text
80
+ [mistri 0a1b2c3d] run "What is 2 plus 3?" (gpt-6.1-sol, 3 tools)
81
+ [mistri 0a1b2c3d] turn 1 done tool_use (312 in / 48 out)
82
+ [mistri 0a1b2c3d] tool add#7f3a {"a":2,"b":3}
83
+ [mistri 0a1b2c3d] tool add#7f3a ok 12ms "5"
84
+ [mistri 0a1b2c3d] text "The sum is 5."
85
+ [mistri 0a1b2c3d] turn 2 done stop (410 in / 22 out)
86
+ [mistri 0a1b2c3d] done completed in 1.2s, 2 turns, 722 in / 70 out, $0.0042
87
+ ```
117
88
 
118
- Every completed message is appended to the chosen Session store before the next
119
- model-visible turn. Opaque reasoning and pairing metadata replay only to the
120
- provider that created them; the shared transcript stays provider-neutral.
89
+ One assignment, and every run tells its story in your ordinary log: inputs,
90
+ tools, durations, tokens, and dollar cost whenever pricing is known. Ship
91
+ those lines to your log platform and you have agent observability without a
92
+ dashboard. `content: false` keeps the story as metadata when payloads must
93
+ stay out. See [Logging](docs/logging.md).
121
94
 
122
- ## Tools and approval
95
+ ## Pause for a human
123
96
 
124
- A tool has a name, description, JSON Schema object, and handler. Independent
125
- calls in one model turn execute concurrently up to `max_concurrency`.
97
+ A tool can require approval. The run parks the call and returns immediately;
98
+ no thread waits for the decision.
126
99
 
127
100
  ```ruby
128
- book_hotel = Mistri::Tool.define(
129
- "book_hotel", "Books the selected hotel.",
130
- schema: lambda {
131
- string :hotel_id, "Hotel ID", required: true
132
- number :total_usd, "Quoted total", required: true
133
- },
134
- needs_approval: ->(args) { args.fetch("total_usd") > 500 },
135
- ) do |args, context|
136
- Bookings.create!(
137
- hotel_id: args.fetch("hotel_id"),
138
- traveler: context.app.fetch(:traveler),
139
- )
140
- end
101
+ issue_refund = Mistri::Tool.define(
102
+ "issue_refund", "Refunds an order.",
103
+ schema: -> { number :amount_usd, "Refund amount", required: true },
104
+ needs_approval: ->(args) { args.fetch("amount_usd") > 500 },
105
+ ) { |args| Refunds.issue!(args) }
141
106
 
142
- agent = Mistri.agent(
143
- "claude-opus-4-8",
144
- tools: [book_hotel],
145
- context: { traveler: current_traveler },
146
- )
147
- ```
148
-
149
- Validation runs before the approval predicate, so policy never receives a
150
- string where the schema promised a number. Invalid calls return a bounded,
151
- model-readable error and valid siblings still run. Mistri never coerces model
152
- input implicitly.
107
+ agent = Mistri.agent("claude-opus-5-5", tools: [issue_refund])
153
108
 
154
- When a gated call arrives:
155
-
156
- ```ruby
157
- result = agent.run("Book the corner suite for the Lisbon trip")
109
+ result = agent.run("Refund all 640 dollars of order 1042.")
158
110
  result.awaiting_approval? # => true; the handler did not run
159
111
 
160
112
  call = result.pending.fetch(0)
161
113
  agent.session.approve(call.id, note: "Approved by finance")
162
- result = agent.resume
114
+ agent.resume
163
115
  ```
164
116
 
165
- That is the smallest in-process flow. With a durable store, a controller,
166
- route, mutation, job, or console can append the decision using only the Session
167
- ID and call ID; a later process rebuilds current tools and policy before
168
- resuming. See [Sessions and control](docs/sessions.md#human-approval).
117
+ With a durable store, the decision can come from a controller, a job, or a
118
+ console in a different process, days later, using only the session ID and the
119
+ call ID. A later process builds a fresh Agent with its current tools and
120
+ policy; `resume` then revalidates the exact call and carries on. See
121
+ [Sessions and control](docs/sessions.md#human-approval).
169
122
 
170
- Tool results can also carry host-only UI data or an explicit failure fact. See
171
- [Tool contracts](docs/tool-contracts.md) for schemas, validators, normalizers,
172
- `Mistri::ToolResult`, hooks, and `ends_turn`.
123
+ ## Why Mistri
173
124
 
174
- ## Sessions and control
125
+ - **Pause for a human, resume days later.** A gated call parks and the run
126
+ returns; any process can record the decision and resume.
127
+ - **One durable session model.** The same append-only log runs over memory,
128
+ JSONL, Active Record, or your own store: reload, resume, steer, and
129
+ compact without a second state model.
130
+ - **Three providers, no lowest common denominator.** Anthropic, OpenAI, and
131
+ Gemini keep their own reasoning, tool-pairing, and replay rules.
132
+ - **Tools cross a real boundary.** Model arguments are validated and frozen
133
+ before your policy or handlers see them; invalid calls fail loudly.
134
+ - **Your Gemfile.lock grows by one line.** Zero runtime gem dependencies;
135
+ Rails adapters load only when required.
136
+ - **Tested against the real APIs.** The live suite runs the control,
137
+ persistence, delegation, MCP, and structured-output paths against actual
138
+ Anthropic, OpenAI, and Gemini endpoints; the default CI suite is hermetic.
175
139
 
176
- The default memory store is useful for one process. JSONL persists the complete
177
- append-only record on local disk without a database:
140
+ ## Choose the right layer
178
141
 
179
- ```ruby
180
- store = Mistri::Stores::JSONL.new("tmp/mistri-sessions")
181
- session = Mistri::Session.new(store: store)
142
+ These projects solve different problems:
182
143
 
183
- agent = Mistri.agent("claude-opus-4-8", session: session)
184
- agent.run("Start a haiku about the sea.")
144
+ | Need | Start with |
145
+ | --- | --- |
146
+ | A durable, approvable agent loop in any Ruby application, on a session store you own, with no runtime dependencies | **Mistri** |
147
+ | A full AI framework: many providers, media, embeddings, and agents persisted through Rails | [RubyLLM](https://github.com/crmne/ruby_llm) |
148
+ | Agents expressed through Rails controllers, actions, callbacks, views, and Active Job | [Active Agent](https://github.com/activeagents/activeagent) |
185
149
 
186
- # A later process can reload the same session by ID.
187
- reloaded = Mistri::Session.new(store: store, id: session.id)
188
- Mistri.agent("claude-opus-4-8", session: reloaded).run("Now finish it.")
189
- ```
150
+ Mistri is deliberately not a terminal UI, hosted agent service, media client,
151
+ or job system. It owns the model loop, the tool boundary, the event stream,
152
+ and the session record; your application owns authorization, policy,
153
+ presentation, and the meaning of its side effects.
190
154
 
191
- For a database-backed store, implement `append(id, entry)` and `load(id)`, or
192
- use the optional Active Record adapter:
155
+ ## Sessions, steering, and stores
193
156
 
194
- ```console
195
- $ bin/rails generate mistri:install AgentEntry
196
- ```
157
+ Sessions persist every message as it completes, so a crash or an abort leaves
158
+ a resumable record with no repair step. Any process can append to a live
159
+ session:
197
160
 
198
161
  ```ruby
199
- require "mistri/stores/active_record"
162
+ store = Mistri::Stores::JSONL.new("tmp/mistri-sessions")
163
+ session = Mistri::Session.new(store: store)
200
164
 
201
- store = Mistri::Stores::ActiveRecord.new(AgentEntry)
202
- ```
165
+ Mistri.agent("claude-opus-5-5", session: session).run("Start a haiku about the sea.")
203
166
 
204
- Steering is another append, so a request handler or worker can redirect a live
205
- exchange without sharing its Agent object:
167
+ # A later process reloads the same session by ID and continues it.
168
+ reloaded = Mistri::Session.new(store: store, id: session.id)
169
+ Mistri.agent("claude-opus-5-5", session: reloaded).run("Now finish it.")
206
170
 
207
- ```ruby
208
- Mistri::Session.new(store: store, id: session_id).steer(
209
- "Make the headline blue instead."
210
- )
171
+ # Steering queues a redirect from anywhere, without the Agent object; a
172
+ # run in flight folds it at its next turn.
173
+ reloaded.steer("Make it about the mountains instead.")
211
174
  ```
212
175
 
213
- Only one Agent may actively call `run` or `resume` for a session at a time.
214
- Approvals, steering, and worker reports may append concurrently. Read the
215
- [reliability contract](docs/reliability.md) before connecting tools with
216
- external side effects.
176
+ For a database-backed store, run `bin/rails generate mistri:install AgentEntry`
177
+ and use the Active Record adapter, or implement `append(id, entry)` and
178
+ `load(id)` on anything. Only one Agent may run a session at a time; approvals,
179
+ steering, and worker reports may append concurrently. See
180
+ [Sessions and control](docs/sessions.md).
217
181
 
218
182
  ## Streaming into any Ruby application
219
183
 
@@ -226,35 +190,27 @@ sink = Mistri::Sinks::Coalesced.new(sse) # merge token bursts to UI speed
226
190
  agent.run(input, &sink)
227
191
  ```
228
192
 
229
- `Mistri::Sinks::ActionCable` is available for Rails, but no Railtie is required.
230
- The same event stream works in Sinatra, Rack, a WebSocket server, a background
231
- job, or a test. Event types form an extensible union; consumers should handle
232
- the types they use and ignore the rest.
193
+ `Mistri::Sinks::ActionCable` is available for Rails, but no Railtie is
194
+ required. The same event stream works in Sinatra, Rack, a WebSocket server, a
195
+ background job, or a test.
233
196
 
234
197
  ## Long conversations and structured tasks
235
198
 
236
- Compaction is on by default for catalogued models. When a session enters the
237
- model's safe headroom, Mistri asks the provider for a visible structured
238
- summary, appends it, and continues from the summary plus a recent tail. The
239
- exact history remains in the store for transcripts.
199
+ Compaction is on by default for models with a known context window: near the
200
+ limit, a summary takes the place of the earlier turns and the run continues
201
+ from it, while the exact history stays in the store. On Claude and GPT the
202
+ provider's own compaction writes it, and elsewhere Mistri asks for it. Task
203
+ mode requires a final JSON value matching a schema, validated locally whenever
204
+ the run completes normally.
240
205
 
241
206
  ```ruby
242
207
  agent.context_usage
243
- # => { tokens: 141_000, window: 1_000_000, fraction: 0.141 }
244
-
245
- agent.compact # explicit checkpoint; returns nil when nothing should compact
246
- ```
247
-
248
- Task mode requires a final JSON value matching a schema. Providers use native
249
- constraints only when they can represent the contract; Mistri validates the
250
- answer locally in every case.
208
+ # => { tokens: 141_000, window: 1_000_000, fraction: 0.141, estimated: 0,
209
+ # threshold: 867_904, remaining: 726_904 }
251
210
 
252
- ```ruby
253
211
  schema = {
254
212
  type: "object",
255
- properties: {
256
- "tiers" => { type: "array", items: { type: "string" } },
257
- },
213
+ properties: { "tiers" => { type: "array", items: { type: "string" } } },
258
214
  required: ["tiers"],
259
215
  }
260
216
 
@@ -262,41 +218,34 @@ result = agent.task("Extract the pricing tiers.", schema: schema)
262
218
  result.output # parsed and validated
263
219
  ```
264
220
 
265
- Task validation applies when that invocation completes normally. An approval
266
- suspension or `ends_turn` handoff returns with `output` nil; after settlement or
267
- the human answer, call `task` again if structured output is still required.
268
-
269
221
  See [Sessions and control](docs/sessions.md) for compaction boundaries,
270
- cross-provider replay, stores, approvals, and transcripts.
222
+ cross-provider replay, and transcripts.
271
223
 
272
224
  ## Sub-agents
273
225
 
274
- Delegate work into a child session so exploration does not consume the parent's
275
- context. Only the report returns to the parent, while the full child transcript
276
- remains linked and inspectable.
226
+ Delegate work into a child session so exploration does not consume the
227
+ parent's context. Only the report returns; the full child transcript stays
228
+ linked and inspectable.
277
229
 
278
230
  ```ruby
279
231
  researcher = Mistri::SubAgent.new(
280
232
  name: "researcher",
281
233
  description: "Reads pages and answers factual questions.",
282
- provider: Mistri.provider("claude-haiku-4-5"),
283
- system: "Research the question. Return findings and sources.",
234
+ provider: Mistri.provider("claude-haiku-5-5"),
284
235
  tools: [fetch_page],
285
236
  )
286
237
 
287
- agent = Mistri.agent("claude-opus-4-8", tools: [researcher.tool])
238
+ agent = Mistri.agent("claude-opus-5-5", tools: [researcher.tool])
288
239
  ```
289
240
 
290
- Mistri also provides a host-bounded spawn tool, named worker types, background
291
- dispatch with worker-side runtime reconstruction, exact capability grants,
292
- reports, steering, stopping, and a management console. See
293
- [Sub-agents](docs/sub-agents.md), including the runtime, concurrency, and lease
294
- limits a production dispatcher must understand.
241
+ Mistri also provides an open spawn tool, background dispatch through your own
242
+ queue, worker reports, steering, stopping, and a management console. See
243
+ [Sub-agents](docs/sub-agents.md).
295
244
 
296
245
  ## Model Context Protocol
297
246
 
298
- Bridge tools over Streamable HTTP or stdio, then apply the same local approval
299
- and validation boundary:
247
+ Bridge tools over Streamable HTTP or stdio, then apply the same local
248
+ approval and validation boundary:
300
249
 
301
250
  ```ruby
302
251
  client = Mistri::MCP::Client.new(
@@ -304,58 +253,33 @@ client = Mistri::MCP::Client.new(
304
253
  token: -> { connection.bearer_token },
305
254
  )
306
255
 
307
- tools = Mistri::MCP.tools(
308
- client,
309
- prefix: "linear",
310
- gates: { "create_issue" => true },
311
- )
256
+ tools = Mistri::MCP.tools(client, prefix: "linear", gates: { "create_issue" => true })
312
257
  ```
313
258
 
314
- Remote URLs default to public HTTPS with validated, pinned DNS answers. Inbound
315
- records are size-bounded. An unconfirmed `tools/call` is never replayed
316
- automatically because the server may already have committed its side effect.
317
- OAuth services are storage-agnostic; the Rails connection generator is one
318
- optional host adapter.
319
-
320
- Read [MCP](docs/mcp.md) for stdio, OAuth, private-network policy, schema
321
- authority, response limits, and large-result resource links.
259
+ Remote URLs default to public HTTPS with validated, pinned DNS answers, and
260
+ an unconfirmed tool call is never replayed automatically. A server with a long
261
+ tool list can be bridged with `deferred: true`, and the model then finds and
262
+ loads the tools it needs. See [MCP](docs/mcp.md).
322
263
 
323
264
  ## Skills, definitions, and workspaces
324
265
 
325
- - **Skills** expose one-line descriptions until the model requests the full
266
+ - **Skills** expose one-line descriptions until the model asks for the full
326
267
  `SKILL.md`, keeping the system prompt small.
327
- - **Definitions** load an agent's model, tool names, and prompt from Markdown
328
- with YAML frontmatter and checked placeholders.
268
+ - **Definitions** load an agent's model, tools, and prompt from Markdown with
269
+ YAML frontmatter.
329
270
  - **Workspaces** give the built-in read, write, edit, find, and list tools a
330
- directory, memory value, Active Record table, or single host-owned value.
331
-
332
- The edit engine refuses ambiguous matches and, when a workspace supports
333
- conditional writes, rebases anchored edits without losing unrelated concurrent
334
- changes. A Directory workspace rejects lexical escape and traversal through
335
- existing symlinks in a stable, host-controlled tree; it is not an
336
- operating-system sandbox. See
337
- [Context and workspaces](docs/context-and-workspaces.md) and the runnable
271
+ directory, a memory value, an Active Record table, or a single host-owned
272
+ value; the edit engine refuses ambiguous matches.
273
+
274
+ See [Context and workspaces](docs/context-and-workspaces.md) and the runnable
338
275
  [`page_editor.rb`](examples/page_editor.rb) example.
339
276
 
340
277
  ## Reliability contract
341
278
 
342
279
  Mistri makes failures explicit, but it does not pretend distributed side
343
- effects are exactly once:
344
-
345
- - Provider requests retry transient failures with backoff. The MCP client never
346
- replays an ambiguous tool call; the Agent bridge returns the uncertainty as
347
- an error-marked tool result.
348
- - A process can crash after a handler commits an external write but before the
349
- result reaches the session. Tools with side effects must be idempotent or
350
- reconcilable.
351
- - Budgets are checked between model-visible turns, so they are soft ceilings.
352
- - Provider and MCP records default to an 8 MiB per-record limit; streaming has
353
- no total-size limit while each record remains safe.
354
- - `Mistri::AbortSignal` is an in-process cooperative signal. Cross-process
355
- worker control uses the configured lock adapter and is also cooperative.
356
-
357
- The complete operational contract, event lifecycle, retry behavior, pricing
358
- rules, and sink guidance live in [Reliability](docs/reliability.md).
280
+ effects are exactly once: tools with external side effects must be idempotent
281
+ or reconcilable, and budgets are soft ceilings checked between turns. The
282
+ complete operational contract lives in [Reliability](docs/reliability.md).
359
283
 
360
284
  ## Documentation
361
285
 
@@ -367,6 +291,7 @@ GitHub:
367
291
  | [Documentation index](docs/README.md) | The complete task-oriented map |
368
292
  | [Tool contracts](docs/tool-contracts.md) | Schemas, validation, approval, hooks, results, and handoff |
369
293
  | [Sessions and control](docs/sessions.md) | Stores, replay, approvals, steering, compaction, and transcripts |
294
+ | [Logging](docs/logging.md) | The run log, its options, and its operational guarantees |
370
295
  | [Context and workspaces](docs/context-and-workspaces.md) | Skills, definitions, context transforms, host-owned memory, and editable documents |
371
296
  | [Sub-agents](docs/sub-agents.md) | Specialists, spawning, dispatch, locks, reports, and control |
372
297
  | [MCP](docs/mcp.md) | HTTP and stdio, OAuth, egress policy, limits, and schema handling |
@@ -383,29 +308,23 @@ $ bundle exec rake test
383
308
  $ bundle exec rubocop
384
309
  ```
385
310
 
386
- Live tests read provider keys from the gitignored
387
- `.env.development.local` file:
311
+ Live tests read provider keys from the gitignored `.env.development.local`:
388
312
 
389
313
  ```console
390
- $ MISTRI_LIVE=1 bundle exec rake test
314
+ $ bundle exec rake live
391
315
  $ bundle exec rake integration
392
- $ MISTRI_INTEGRATION_MODELS=claude-opus-4-8 bundle exec rake integration
393
316
  ```
394
317
 
395
- The integration matrix exercises critical end-to-end scenarios against one
396
- Anthropic, OpenAI, and Gemini model by default when the corresponding keys are
397
- present. See
398
- [CONTRIBUTING.md](CONTRIBUTING.md) for the project contract.
318
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the project contract.
399
319
 
400
320
  ## Compatibility and support
401
321
 
402
322
  Mistri supports Ruby 3.2 and newer. It is pre-1.0: minor releases may include
403
- intentional contract changes with an explicit migration path. Read
404
- [UPGRADING.md](UPGRADING.md) and [CHANGELOG.md](CHANGELOG.md) before upgrading.
405
-
406
- Use [GitHub issues](https://github.com/mcheemaa/mistri/issues) for reproducible
407
- bugs and focused feature proposals. Report vulnerabilities privately as
408
- described in [SECURITY.md](SECURITY.md).
323
+ intentional contract changes with an explicit migration path; read
324
+ [UPGRADING.md](UPGRADING.md) before upgrading. Use
325
+ [GitHub issues](https://github.com/mcheemaa/mistri/issues) for reproducible
326
+ bugs and focused proposals, and report vulnerabilities privately as described
327
+ in [SECURITY.md](SECURITY.md).
409
328
 
410
329
  ## Credits
411
330