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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1414bffbf49921cf9e575ea1a8998cfc435b77325d80d55ed76e6564d63311c5
4
- data.tar.gz: b707010a75d56d65a8c42b50a874807e0f529da6b5878246aa9b34239493c808
3
+ metadata.gz: 65b5ce6ebcf250ec7e01df324936827625c658d9639d7cc14fff4985d7e8592a
4
+ data.tar.gz: 93b7a9b2f4b11a63e2ab029de79e32cf43971162c3a13efdf32ab25ca433303f
5
5
  SHA512:
6
- metadata.gz: b7781114db5365b8ce899af9ab50b8eaf2279979d8110a282d54a4fb3187a2576fc94821c3ddb550e9af3da8052ad64b14310c5136d3a064044aee57418c209b
7
- data.tar.gz: d87fb8db281d3c6cedaea995054723f4f15d62e5268384393e16d655dfd45ba714e4b276c73c378307e8b3314ecec1108b3d320578edd659d77e6d07a8e34e2f
6
+ metadata.gz: e966dac1b902303251f670a10f984c89e7f68030de3b39c55fedaf1a4a91e50e967dc1bed4775e2ecaeda7fccce177d72409fa14084b3d004404ecfa11767c81
7
+ data.tar.gz: fd1cb52c50a358aa04df8c96988e0d436ea369398b2f0a08e4524494ad1224f14966397555549e88119eca24436c80098f6c52abe5c22fdf232f5914b1b36595
data/CHANGELOG.md CHANGED
@@ -1,10 +1,361 @@
1
1
  # Changelog
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
5
+ and Mistri follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
6
+ from 0.x: a minor release can change a contract, and `UPGRADING.md` says what
7
+ a host must do.
5
8
 
6
9
  ## [Unreleased]
7
10
 
11
+ ## [0.8.0] - 2026-11-30
12
+
13
+ On Claude and GPT the provider now compacts a session itself, and the context
14
+ level is the provider's own count. GPT-6.2 and Gemini 4 are supported. Tools
15
+ can be loaded on demand, a large tool result stays out of the context, and an
16
+ agent can run code the model writes. The MCP client speaks the 2026-07-28
17
+ revision and keeps a server through a slow call.
18
+
19
+ An entry under Changed can need work in a host, and `UPGRADING.md` says what to
20
+ do for each. The guides under `docs/` describe how each feature works.
21
+
22
+ ### Changed
23
+
24
+ - **Compaction:** On Claude and GPT the provider writes the summary in its own
25
+ compaction, so the kept turns keep their thinking and reasoning. This holds
26
+ on the vendor's own origin, and a request to Anthropic for it sends the beta
27
+ header `compact-2026-09-04`. `Compaction.new(native: false)` asks for
28
+ Mistri's own summary, which stays the fallback and the only way on Gemini.
29
+ (#157)
30
+ - **Compaction:** Nobody can read a GPT compaction. `event.content`, the
31
+ entry's `"summary"` and `result[:summary]` are nil for it, and
32
+ `instructions:` do not reach it. (#157)
33
+ - **Compaction:** A session whose latest compaction a provider wrote runs only
34
+ on that provider. Another provider refuses it with `ConfigurationError`.
35
+ (#157)
36
+ - **Compaction:** Mistri's own summary is a handoff in seven fixed sections,
37
+ asked for with the conversation itself. The request reads the session's
38
+ prompt cache and every tool result whole, and has its own output limit,
39
+ `Compaction.new(max_tokens:)`, 16,384 by default. On OpenAI that summary
40
+ stands after the turns it leaves. (#64, #68, #157)
41
+ - **Compaction:** A summary that is empty or cut short is rejected. A manual
42
+ compaction raises `CompactionError`. An automatic one keeps the context,
43
+ appends a `compaction_failed` entry, emits `:compaction_failed`, and stops
44
+ after three failures in a row. (#63, #64)
45
+ - **Compaction:** The context level is the provider's own count wherever one
46
+ can be had, and `keep_recent:` is measured in it. Before, a compaction asked
47
+ to keep 20,000 tokens kept 39,462 on GPT and 52,960 on Gemini. The level
48
+ reads higher than the old estimate, so a compaction starts earlier. (#157)
49
+ - **Compaction:** A compaction keeps no turn that the one before it kept, and
50
+ at most half of the room under its threshold, so it can keep less than
51
+ `keep_recent:`. No automatic compaction starts when nothing was stored since
52
+ the last one. (#157)
53
+ - **Agent:** A turn that a provider refuses as longer than the model's window
54
+ is compacted and sent once more, with the reason `:overflow`. The refusal has
55
+ the new type `ContextTooLongError`, a kind of `InvalidRequestError`, on all
56
+ three providers. (#157)
57
+ - **Agent:** `run` and `Session#steer` raise `ArgumentError` for text that is
58
+ only whitespace. (#77)
59
+ - **Tools:** The calls of one turn run in the order the model wrote them. A
60
+ tool runs alone, on the calling thread, unless it is defined with
61
+ `parallel: true`. When a call fails or is refused, the calls after it answer
62
+ `Not run`, and a call that waits for approval holds back the calls after it.
63
+ (#149)
64
+ - **Tools:** A tool result is stored with 50,000 bytes at most, and the results
65
+ of one turn share 200,000. A cut result ends with its true size.
66
+ `result_limit:` on the agent sets other numbers, or `false` for none. (#147)
67
+ - **Tools:** `Tools.files` returns `read_file`, `write_file`, `edit_file`,
68
+ `grep`, `list_files` and `delete_file`, and no longer `find_in_file`.
69
+ `read_file` and `grep` answer in parts, and `write_file` takes `if_version`.
70
+ (#147)
71
+ - **Tools:** A path from the model is refused before any workspace is asked
72
+ unless it is relative, with no empty part, `.`, `..` or backslash. (#147)
73
+ - **Tools:** The description a model sees for a tool with `needs_approval` says
74
+ that a person reviews the call. `Tool#description` is unchanged. (#78)
75
+ - **Images:** A GPT or Gemini model is sent the image a tool returns, where it
76
+ was sent a line that said a block was left out. Such a request now costs the
77
+ image's tokens. (#148)
78
+ - **Events:** The `:retry` note names what failed, as in
79
+ `attempt 1 failed (OverloadedError 529)`. (#147)
80
+ - **Sessions:** A session can hold a system message: a reminder Mistri wrote,
81
+ such as the list of deferred tools or an MCP server's instructions. A custom
82
+ provider receives it as a user message unless it answers `system_messages?`
83
+ with true. (#137, #143, #145)
84
+ - **Sessions:** A session reads from its newest compaction on, and from the
85
+ store only what was appended since its last read. The built-in stores support
86
+ it. A custom store opts in with `load(id, from:)`, `settled?`, `size` and
87
+ `load(id, to:)`. (#82, #86, #93, #96)
88
+ - **Sessions:** `approve` and `deny` raise `ConfigurationError` for a call that
89
+ was settled before the newest compaction, where they returned nil. A tool
90
+ call id is unique from the newest compaction on, not over the whole session.
91
+ (#93)
92
+ - **Sessions:** A session's string id is fixed when the session is built.
93
+ Changing the string afterwards no longer redirects the session. (#87)
94
+ - **Stores:** With `Mistri.locks` set, `run`, `resume`, `task` and `compact`
95
+ lease the session, and a second runner raises `SessionBusyError` before it
96
+ appends. `Agent.new(lease: false)` takes no lease. (#83, #91)
97
+ - **Stores:** `Locks::RailsCache` raises `Mistri::Error` when a cache write
98
+ fails, where an outage read as a held lease. (#83)
99
+ - **Stores:** The JSONL store raises `ArgumentError` for a session id outside
100
+ `[A-Za-z0-9_-]{1,249}`, where it rewrote the id and two ids could share a
101
+ file. (#76, #81)
102
+ - **Stores:** The install generator creates the session table with one index.
103
+ An existing table is unaffected. (#85)
104
+ - **Sub-agents:** `read_agent` reads a worker's log a page at a time, with
105
+ `offset` and `limit`. It showed the last 200 entries. (#107)
106
+ - **Catalog:** Provider defaults are `claude-opus-5-5`, `gpt-6.1-sol` and
107
+ `gemini-3.8-flash`. They were `claude-opus-4-8`, `gpt-5.5` and
108
+ `gemini-2.5-flash`. (#78)
109
+ - **Catalog:** Prices follow the vendors' current pages. `gpt-5.6-terra` and
110
+ `gpt-5.6-luna` cost less, `gpt-5.6-sol` holds its promotional price through
111
+ 2026-11-30, and `claude-sonnet-5` no longer rises from September 2026, an
112
+ increase Anthropic cancelled. (#78, #155)
113
+ - **OpenAI:** On OpenAI's own origin the system prompt is sent as a developer
114
+ message at the start of the input, which GPT-6.2 caches. Another origin still
115
+ receives `instructions`. (#155)
116
+ - **Usage:** A `Usage` dumped with Marshal by this release is not read by an
117
+ earlier one. (#155)
118
+ - **MCP:** A bridged tool call ends after 300 seconds. `timeout:` on
119
+ `MCP.tools` and `MCP.bridge` sets another number, or `nil` for none. (#153)
120
+ - **MCP:** A bridged tool's description is cut at 4,096 characters.
121
+ `description_limit:` sets another number, or `nil` for none. (#153)
122
+ - **MCP:** A server's instructions are appended to the conversation.
123
+ `instructions: false` on `MCP.tools` leaves them out, and a string sends the
124
+ host's own text in their place. (#134, #140)
125
+ - **MCP:** `MCP.tools` returns one more tool, `read_resource`, for a server
126
+ that has resources. `resources: false` leaves it out. (#153)
127
+ - **MCP:** `MCP.tools` leaves out a tool it cannot bridge, with a warning or a
128
+ call to its block, and keeps the rest of the server. It raised for the whole
129
+ list. (#104)
130
+ - **MCP:** A bridged tool whose name a provider would refuse gets a safe name
131
+ that ends in a short hash. `MCP.local_name` returns it, and `MCP.bridge`
132
+ takes `name:`. (#103)
133
+ - **MCP:** A key of `gates:` that names no tool of the server raises
134
+ `ConfigurationError`. It matched nothing, so the tool ran with no approval.
135
+ (#154)
136
+ - **MCP:** An error names the MCP server: `the MCP server answered HTTP 400`
137
+ where it read `provider request failed`, and a 401 or 403 no longer reads as
138
+ a missing API key. Classes, `status` and `body` are unchanged. (#116, #153)
139
+ - **MCP:** A list request that times out over HTTP raises `Mistri::MCP::Error`,
140
+ where it raised `Mistri::ProviderError`. `headers:` no longer takes
141
+ `Last-Event-ID`, `Mcp-Method` or `Mcp-Name`. (#153)
142
+ - **MCP sign-in:** After a 403 that asks for more scope the client raises at
143
+ once, where it asked the token callable again. (#153)
144
+
145
+ ### Added
146
+
147
+ - **Catalog:** `gpt-6.2-sol`, `gpt-6.2-astra`, `gpt-6.1-sol`, `gpt-6.1-terra`,
148
+ `gpt-6-sol`, `gpt-6-astra`, `gpt-6-luna`, `gemini-4-carbon`,
149
+ `gemini-4-argon`, `gemini-4-neon`, `gemini-4-hydrogen`, `gemini-3.8-flash`,
150
+ `gemini-3.6-flash`, `gemini-3.5-flash-lite`, `claude-fable-5-2`,
151
+ `claude-fable-5-1`, `claude-opus-5-5`, `claude-opus-5`, `claude-sonnet-5-5`
152
+ and `claude-haiku-5-5`, each with its window and prices.
153
+ (#57, #62, #78, #155)
154
+ - **Gemini:** A Gemini 4 answer longer than the 65,536 tokens of one request is
155
+ continued in the same message, up to 32 requests. Input, thinking and output
156
+ share the window of a Gemini 4 model, so compaction starts at 978,944 tokens
157
+ there. (#155)
158
+ - **Gemini:** The provider takes `max_tokens:`. (#155)
159
+ - **Usage:** `Usage#context` and `Usage#context_tokens` give what sits in the
160
+ model's context after a turn that took more than one request. (#155)
161
+ - **Events:** `:thinking_dropped` says that the API removed replayed thinking
162
+ or reasoning, on Anthropic and OpenAI. (#78, #155)
163
+ - **Compaction:** `Compaction.new(threshold:)` starts a compaction at a number
164
+ of tokens or a share of the window. (#157)
165
+ - **Compaction:** `Compaction.new(fallback:)` names a second summarizer that
166
+ gets one try when the session's provider cannot write a usable summary. (#65)
167
+ - **Agent:** `context_usage` returns `estimated`, `threshold` and `remaining`,
168
+ and `context_usage(count: true)` asks the provider to count the next request.
169
+ (#157)
170
+ - **Agent:** `compact(instructions:)` gives one summary a focus. (#157)
171
+ - **Events:** The compaction events carry `reason`, `tokens_before`,
172
+ `tokens_after` and `duration`, and `status` says `:native` or `:own`. A
173
+ compaction entry stores its `"trigger"`, its `"duration"` and the `"usage"`
174
+ of its own requests. (#157)
175
+ - **Providers:** `count_tokens(messages:, system:, tools:)` returns the
176
+ provider's own count of a request, on all three providers. A custom provider
177
+ may answer it, and `compacts?` and `summary_after_kept?` as well. (#157)
178
+ - **Content:** `Content::Compaction` holds a provider's own summary: the block
179
+ as it came, and its text where it can be read. (#157)
180
+ - **Sessions:** For a host that builds its own loop: `Session#context_level`,
181
+ `#tail_tokens`, `#compacted_at`, `#grown_since_compaction?`, `#checkpoint`
182
+ and `#open_from`, and `Compaction.level`, `.count`, `#ceiling` and
183
+ `#keep_within`. (#93, #157)
184
+ - **Sub-agents:** A worker that runs inline takes its parent's `threshold:`
185
+ unless it has a `compaction:` of its own. A tool reads its agent's setting
186
+ from `context.compaction`. (#157)
187
+ - **Sub-agents:** `Child#transcript` takes `from:` and `to:`, and `Child#size`
188
+ counts a worker's log. (#107)
189
+ - **Tools:** Tools on demand. A tool marked `deferred: true`, or a whole MCP
190
+ server bridged with `deferred: true`, stays out of the prompt until the model
191
+ finds it with `tool_search`. A load keeps the prompt cache on Anthropic and
192
+ OpenAI, and a sub-agent pool may hold deferred tools. (#106 to #133)
193
+ - **Agent:** `scratchpad:` saves the whole of a tool result over its limit,
194
+ where the model reads it in parts. `ToolContext#scratchpad` has `save_binary`
195
+ for bytes a tool cannot show. (#147, #153)
196
+ - **Agent:** `sandbox:` adds `run_code`: JavaScript the model writes, run by
197
+ `Sandbox::QuickJS` on the optional `wasmtime` gem. The code reads and writes
198
+ the agent's documents and calls its tools. (#147, #150)
199
+ - **Agent:** `files:` takes the host's workspace. Documents and the scratchpad
200
+ are one path space, and workers share it. (#147)
201
+ - **Tools:** `grep` and `delete_file` are new document tools. A tool takes
202
+ `result_limit:` and `save_result:`, and reads the limit in force from
203
+ `context.result_limit`. (#147)
204
+ - **Tools:** A tool schema may declare JSON Schema draft-07 as well as 2020-12.
205
+ (#105)
206
+ - **Images:** `Content::Image#detected_mime_type` answers the type the bytes
207
+ show. (#151)
208
+ - **MCP:** The client speaks the 2026-07-28 revision, and asks a server which
209
+ revisions it speaks before its first request. An older server gets the
210
+ handshake of 2025-11-25. (#153)
211
+ - **MCP:** `Mistri::MCP::SDKClient` wraps a client of the official MCP Ruby
212
+ SDK. (#153)
213
+ - **MCP:** `Client#read_resource` and `Client#resources?` read a server's
214
+ resources. (#153)
215
+ - **MCP:** A client can be built from a stored listing. `Client#listing`
216
+ returns a server's tools and instructions for a host to store, and a client
217
+ built with `listing:` connects only when a tool is called. (#119)
218
+ - **MCP:** `on_notification:` passes on each notification a server sends,
219
+ `progress: true` asks for progress, and `Client#state` and `Client#failure`
220
+ say whether a server can be used. (#153)
221
+ - **MCP:** `instructions_as: :user`, `trust_hints: false`, `MCP.digest` and
222
+ `MCP.changes` give a host more say over what a server's text can do. (#153)
223
+ - **MCP:** A stream that a server ended before its answer is asked for again
224
+ once, with `Last-Event-ID`. (#153)
225
+ - **MCP sign-in:** `OAuth.complete(iss:)` checks the issuer of a callback.
226
+ `OAuth.start(client_metadata_url:)` uses a client ID metadata document,
227
+ `OAuth.discover` reads how a server signs in, and `OAuth.revoke` ends a
228
+ token. (#153)
229
+ - **MCP sign-in:** `tolerant: true` accepts three common departures from the
230
+ spec, and `offline_access: true` adds that scope. Both are off by default.
231
+ (#153)
232
+ - **MCP sign-in:** `OAuth::IssuerChanged`, `OAuth::TokenError` and
233
+ `OAuth::InvalidGrantError` are kinds of `Mistri::MCP::Error`.
234
+ `AuthenticationError#challenge` carries the `WWW-Authenticate` header, and a
235
+ token callable that takes `refused:` is given the token a server refused.
236
+ (#153)
237
+
238
+ ### Fixed
239
+
240
+ - **Agent:** An empty completion after the model has answered ends the turn. It
241
+ was sent again up to three times. `result.text` and the new `result.said`
242
+ read what the model wrote. (#147)
243
+ - **Images:** An image in base64 with line breaks, without padding or in the
244
+ URL-safe alphabet no longer gets every later request refused. (#152)
245
+ - **Images:** An image that Anthropic or OpenAI does not take, such as a BMP,
246
+ an SVG or a JPEG labelled as a PNG, no longer ends the session. It is sent
247
+ with the type its bytes show, or as a line of text. (#151)
248
+ - **Anthropic:** A changed system prompt, tool definition or context transform
249
+ no longer ends a session on current Claude models. The API is asked to drop
250
+ thinking it cannot verify. (#78)
251
+ - **Anthropic:** A compaction no longer fails on a model that binds thinking to
252
+ the prefix, such as Fable 5.2. (#62, #78)
253
+ - **Anthropic:** Text that is only whitespace is no longer sent, and a session
254
+ that stored some answers again. (#78)
255
+ - **Anthropic:** A failed tool result that holds an image no longer ends the
256
+ request. (#148)
257
+ - **OpenAI:** Tools are sent with `strict: false`. Left unset, the API made
258
+ each schema strict, and the model invented a value for every optional field.
259
+ (#78)
260
+ - **OpenAI:** A stream failure keeps its code and message. A refusal under a
261
+ content policy fails at once, where it was retried. (#108)
262
+ - **OpenAI:** A large tool list no longer ends every run. (#98)
263
+ - **Gemini:** A skill the model loaded is also sent in the system instruction.
264
+ Gemini ignored it in a tool result about half the time. (#78)
265
+ - **Gemini:** A turn that calls a tool no longer stores an empty text block.
266
+ (#155)
267
+ - **Providers:** A request that a host ends early with `Timeout` no longer
268
+ leaves its bytes for the next request on the same connection. (#153)
269
+ - **Compaction:** A compaction is no longer declined when the recent turns end
270
+ on a tool call with no recorded result. (#94)
271
+ - **Skills:** `read_skill` marks an unknown skill name as a failed result.
272
+ (#78)
273
+ - **Files:** Files are read as UTF-8 wherever the process runs, also in one
274
+ with no UTF-8 locale. (#97, #102)
275
+ - **Files:** A fuzzy edit keeps the final line separator. (#61)
276
+ - **Streaming:** A partial JSON preview drops an overflowing number without a
277
+ Ruby warning. (#78)
278
+ - **Stores:** The JSONL store loads a session whose last line a crash left
279
+ partial. (#76)
280
+ - **Stores:** The Active Record workspace no longer keeps a database connection
281
+ checked out. (#84)
282
+ - **Stores:** A failed lease renewal warns and retries. It stopped renewing.
283
+ (#83)
284
+ - **MCP:** A JSON-RPC error from a server no longer closes its connection.
285
+ (#153)
286
+ - **MCP:** A call over Streamable HTTP returns when its answer arrives, keeps
287
+ its session after a failure, and applies `read_timeout` to each message.
288
+ `Client#close` ends the session with a DELETE. (#153)
289
+ - **MCP:** A timeout no longer ends a stdio server. The call is cancelled and
290
+ the server is kept, with whatever it holds. (#153)
291
+ - **MCP:** A stdio server's own requests are answered, ids it sends back as
292
+ strings are matched, a line that is not JSON is skipped, and a call to a
293
+ server that stopped reading ends at `read_timeout`. (#153)
294
+ - **MCP:** A call that was never sent is reported as a tool that did not run,
295
+ and names the server. The result said it may have completed.
296
+ `Client#call_tool` raises an error tagged `MCP::NotSent` for it. (#122, #153)
297
+ - **MCP:** An embedded resource with bytes is no longer dropped. (#153)
298
+ - **MCP:** An answer that arrives as an SSE stream is no longer held to 20,001
299
+ JSON tokens. (#101)
300
+ - **MCP sign-in:** With `client_secret_basic` the client id is sent only in the
301
+ Basic header. (#99)
302
+ - **MCP sign-in:** A dynamic registration that returns a secret and names no
303
+ method is accepted. (#153)
304
+ - **MCP sign-in:** The generated connection model locks its row for a token
305
+ refresh. Two processes that refreshed at once lost the sign-in. (#153)
306
+
307
+ ### Removed
308
+
309
+ - **Catalog:** `gemini-2.5-pro` and `gemini-2.5-flash`, which Google retired. A
310
+ cost-budgeted agent that names one fails at construction. (#78)
311
+ - **Compaction:** `Compaction::IMAGE_CHARS` and `Compactor::FORMAT`.
312
+ (#68, #157)
313
+ - **Tools:** `Mistri::Tools.numbered_window` and
314
+ `Mistri::Tools::MAX_READ_CHARS`. (#147)
315
+
316
+ ### Security
317
+
318
+ - **MCP:** A stdio server no longer inherits the host's environment, which
319
+ holds provider keys. It gets the client's `env:` and a fixed list of
320
+ variables that `docs/mcp.md` names. (#75, #79)
321
+ - **Stores:** The JSONL store creates session files with mode 0600. (#76)
322
+ - **Stores:** `Locks::RailsCache` warns when it is given a null cache store.
323
+ Such a store grants every lease, so two runs could write one session at once.
324
+ (#147)
325
+
326
+ ## [0.7.0] - 2026-07-30
327
+
328
+ - `Mistri.logger` and `Mistri::Sinks::Logger`: assign any Logger-compatible
329
+ object and every run logs its story as one scannable line per beat, tagged
330
+ by session (sub-agents get their worker label): the input, each tool call
331
+ and result with a short pairing id, arguments, duration, and result size,
332
+ each turn's token usage with cached prompt tokens called out, retries,
333
+ compaction, approvals (carrying the full call id `Session#approve` takes),
334
+ worker reports wherever a sink watched the spawn, and a closing line with
335
+ the run's outcome, elapsed time, turn count, and dollar cost whenever
336
+ pricing is known, a known $0.0000 included. `task` logs one frame around
337
+ all its fix passes, and the frame covers the whole public method, so store
338
+ and audit failures get a crash line too. Payloads log in full by default;
339
+ `content: false` keeps the same story as metadata only, error, crash, and
340
+ retry free text included, since exception messages can echo payloads. `level:` floors
341
+ the ordinary lines (warnings and errors keep their own levels, and
342
+ expected stops such as cancels and budget ceilings log calmly), `color:`
343
+ and `truncate:` are per-sink options, and a preconfigured `Sinks::Logger`
344
+ (subclasses included) can be assigned directly; wrong assignments and
345
+ options raise at configuration time. Sinks the Agent builds skip origin-tagged events so every agent, in
346
+ any process, logs its own events exactly once; a sink composed directly
347
+ per run renders forwarded child events with their origin instead. Logging
348
+ never breaks a run: sink construction and every write are contained,
349
+ failures warn once per run and the run's sink goes quiet, host exceptions
350
+ are never replaced (invalid byte sequences included), and hidden bytes in
351
+ payloads, names, ids, and labels render as visible escapes so untrusted
352
+ output cannot forge lines or steer a terminal. With no logger assigned
353
+ the event path is untouched (one nil check per run, nothing per event);
354
+ with one assigned, delta events short-circuit without allocating,
355
+ formatting is skipped when the floor level is disabled, and per-line
356
+ string work, tool argument keys and values included, is bounded by the
357
+ truncation limit, not the payload.
358
+
8
359
  ## [0.6.1] - 2026-07-21
9
360
 
10
361
  - The ActiveRecord store and workspace read past the host's query cache.
@@ -882,7 +1233,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
882
1233
 
883
1234
  - Reserved the gem name.
884
1235
 
885
- [Unreleased]: https://github.com/mcheemaa/mistri/compare/v0.6.1...HEAD
1236
+ [Unreleased]: https://github.com/mcheemaa/mistri/compare/v0.8.0...HEAD
1237
+ [0.8.0]: https://github.com/mcheemaa/mistri/compare/v0.7.0...v0.8.0
1238
+ [0.7.0]: https://github.com/mcheemaa/mistri/compare/v0.6.1...v0.7.0
886
1239
  [0.6.1]: https://github.com/mcheemaa/mistri/compare/v0.6.0...v0.6.1
887
1240
  [0.6.0]: https://github.com/mcheemaa/mistri/compare/v0.5.0...v0.6.0
888
1241
  [0.5.0]: https://github.com/mcheemaa/mistri/compare/v0.4.1...v0.5.0
data/CONTRIBUTING.md CHANGED
@@ -14,12 +14,19 @@ The live suites need provider keys in a gitignored `.env.development.local`
14
14
  (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY`):
15
15
 
16
16
  ```console
17
- $ MISTRI_LIVE=1 bundle exec rake test # gated live tests
18
- $ bundle exec rake integration # critical end-to-end scenarios, per model
17
+ $ bundle exec rake live # gated live tests
18
+ $ bundle exec rake live:compaction # the compaction eval cell and the thinking replay
19
+ $ bundle exec rake integration # critical end-to-end scenarios, per model
19
20
  ```
20
21
 
22
+ These tests wait on the network, so they run on threads, and `rake integration`
23
+ starts one process for each model. `rake live` leaves out the two files of
24
+ `rake live:compaction`, which are most of a live run's cost: run that task when a
25
+ change touches the compactor or how thinking is replayed.
26
+
21
27
  Missing keys skip their provider. Read the output before treating a live run as
22
- three-provider coverage.
28
+ three-provider coverage. Each live run ends with a report per model: calls,
29
+ seconds, tokens and their cost at catalog prices, then the slowest tests.
23
30
 
24
31
  ## The rules that keep the gem what it is
25
32
 
@@ -50,3 +57,10 @@ and honest reliability boundaries. Put detailed contracts in the task-oriented
50
57
  Markdown guides under `docs/`, and put required host migrations in
51
58
  `UPGRADING.md`. Link repository files relatively so links work on branches and
52
59
  pull requests. Do not duplicate the changelog into a guide.
60
+
61
+ ## Compaction prompts
62
+
63
+ The compactor's prompts are measured, not argued about. A change to
64
+ `Mistri::Compactor`'s prompt constants comes with a run of the compaction eval
65
+ (`script/compaction_eval.rb`, see `eval/README.md`) against the committed
66
+ baseline in `eval/baselines/`, and the comparison goes in the pull request.
data/NOTICE CHANGED
@@ -4,6 +4,17 @@ Copyright (c) 2026 Muhammad Ahmed Cheema
4
4
  Mistri's architecture is informed by pi (https://github.com/badlogic/pi-mono),
5
5
  the agent harness by Mario Zechner, MIT licensed:
6
6
  Copyright (c) 2025 Mario Zechner
7
+ The ranking in lib/mistri/tool_search.rb follows pi's tool search.
7
8
 
8
9
  Mistri also draws on lessons from truffle-rb, an earlier Ruby port of pi by the
9
10
  same author as Mistri.
11
+
12
+ Parts of Mistri's MCP sign-in are adapted from the Model Context Protocol Ruby
13
+ SDK (https://github.com/modelcontextprotocol/ruby-sdk), licensed under the
14
+ Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0):
15
+ the rules for application_type and for the address of a client ID metadata
16
+ document in lib/mistri/mcp/oauth/client_identity.rb, the rule for a resource
17
+ that covers a path in lib/mistri/mcp/oauth/tolerance.rb, and the cases for
18
+ them and for the issuer of a callback in test/test_mcp_oauth_checks.rb. The
19
+ rules were rewritten for Mistri's own sign-in calls, which take no class of
20
+ the SDK.