@animalabs/agent-framework 0.30.0 → 0.31.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 (179) hide show
  1. package/README.md +71 -8
  2. package/dist/src/agent.d.ts +29 -9
  3. package/dist/src/agent.d.ts.map +1 -1
  4. package/dist/src/agent.js +82 -17
  5. package/dist/src/agent.js.map +1 -1
  6. package/dist/src/api/mcp-server-core.d.ts.map +1 -1
  7. package/dist/src/api/mcp-server-core.js +10 -3
  8. package/dist/src/api/mcp-server-core.js.map +1 -1
  9. package/dist/src/code-execution/isolate/render.d.ts.map +1 -1
  10. package/dist/src/code-execution/isolate/render.js +7 -6
  11. package/dist/src/code-execution/isolate/render.js.map +1 -1
  12. package/dist/src/code-execution/isolate/scripts.d.ts.map +1 -1
  13. package/dist/src/code-execution/isolate/scripts.js +5 -4
  14. package/dist/src/code-execution/isolate/scripts.js.map +1 -1
  15. package/dist/src/framework.d.ts +129 -92
  16. package/dist/src/framework.d.ts.map +1 -1
  17. package/dist/src/framework.js +1115 -704
  18. package/dist/src/framework.js.map +1 -1
  19. package/dist/src/gate/event-gate.d.ts +24 -17
  20. package/dist/src/gate/event-gate.d.ts.map +1 -1
  21. package/dist/src/gate/event-gate.js +198 -144
  22. package/dist/src/gate/event-gate.js.map +1 -1
  23. package/dist/src/gate/recipe-reconcile.d.ts.map +1 -1
  24. package/dist/src/gate/recipe-reconcile.js +6 -5
  25. package/dist/src/gate/recipe-reconcile.js.map +1 -1
  26. package/dist/src/host-presentation.d.ts.map +1 -1
  27. package/dist/src/host-presentation.js +5 -7
  28. package/dist/src/host-presentation.js.map +1 -1
  29. package/dist/src/index.d.ts +1 -0
  30. package/dist/src/index.d.ts.map +1 -1
  31. package/dist/src/index.js +1 -0
  32. package/dist/src/index.js.map +1 -1
  33. package/dist/src/inference-bounds.d.ts +37 -0
  34. package/dist/src/inference-bounds.d.ts.map +1 -0
  35. package/dist/src/inference-bounds.js +84 -0
  36. package/dist/src/inference-bounds.js.map +1 -0
  37. package/dist/src/line-reader.d.ts +7 -1
  38. package/dist/src/line-reader.d.ts.map +1 -1
  39. package/dist/src/line-reader.js +17 -6
  40. package/dist/src/line-reader.js.map +1 -1
  41. package/dist/src/mcpl/errors.d.ts +1 -0
  42. package/dist/src/mcpl/errors.d.ts.map +1 -1
  43. package/dist/src/mcpl/errors.js +3 -0
  44. package/dist/src/mcpl/errors.js.map +1 -1
  45. package/dist/src/mcpl/inbound-source.d.ts +2 -2
  46. package/dist/src/mcpl/inbound-source.js +2 -2
  47. package/dist/src/mcpl/inference-router.d.ts +11 -1
  48. package/dist/src/mcpl/inference-router.d.ts.map +1 -1
  49. package/dist/src/mcpl/inference-router.js +65 -9
  50. package/dist/src/mcpl/inference-router.js.map +1 -1
  51. package/dist/src/mcpl/modern-connection.d.ts +10 -7
  52. package/dist/src/mcpl/modern-connection.d.ts.map +1 -1
  53. package/dist/src/mcpl/modern-connection.js +85 -74
  54. package/dist/src/mcpl/modern-connection.js.map +1 -1
  55. package/dist/src/mcpl/protocol-family.d.ts +1 -1
  56. package/dist/src/mcpl/protocol-family.d.ts.map +1 -1
  57. package/dist/src/mcpl/protocol-family.js +45 -3
  58. package/dist/src/mcpl/protocol-family.js.map +1 -1
  59. package/dist/src/mcpl/push-coalescer.d.ts +2 -7
  60. package/dist/src/mcpl/push-coalescer.d.ts.map +1 -1
  61. package/dist/src/mcpl/push-coalescer.js.map +1 -1
  62. package/dist/src/mcpl/references.d.ts +1 -2
  63. package/dist/src/mcpl/references.d.ts.map +1 -1
  64. package/dist/src/mcpl/references.js +3 -3
  65. package/dist/src/mcpl/references.js.map +1 -1
  66. package/dist/src/mcpl/server-connection.d.ts +14 -0
  67. package/dist/src/mcpl/server-connection.d.ts.map +1 -1
  68. package/dist/src/mcpl/server-connection.js +26 -22
  69. package/dist/src/mcpl/server-connection.js.map +1 -1
  70. package/dist/src/mcpl/tool-signature.d.ts +1 -0
  71. package/dist/src/mcpl/tool-signature.d.ts.map +1 -1
  72. package/dist/src/mcpl/tool-signature.js +16 -11
  73. package/dist/src/mcpl/tool-signature.js.map +1 -1
  74. package/dist/src/mcpl/transport.d.ts +44 -21
  75. package/dist/src/mcpl/transport.d.ts.map +1 -1
  76. package/dist/src/mcpl/transport.js +283 -64
  77. package/dist/src/mcpl/transport.js.map +1 -1
  78. package/dist/src/mcpl/types.d.ts +17 -1
  79. package/dist/src/mcpl/types.d.ts.map +1 -1
  80. package/dist/src/mcpl/types.js.map +1 -1
  81. package/dist/src/module-registry.d.ts +32 -4
  82. package/dist/src/module-registry.d.ts.map +1 -1
  83. package/dist/src/module-registry.js +189 -25
  84. package/dist/src/module-registry.js.map +1 -1
  85. package/dist/src/modules/discord/discord-js-client.d.ts.map +1 -1
  86. package/dist/src/modules/discord/discord-js-client.js +24 -16
  87. package/dist/src/modules/discord/discord-js-client.js.map +1 -1
  88. package/dist/src/modules/sender-name.d.ts +5 -4
  89. package/dist/src/modules/sender-name.d.ts.map +1 -1
  90. package/dist/src/modules/sender-name.js +7 -5
  91. package/dist/src/modules/sender-name.js.map +1 -1
  92. package/dist/src/modules/workspace/disk-agreement.d.ts +16 -8
  93. package/dist/src/modules/workspace/disk-agreement.d.ts.map +1 -1
  94. package/dist/src/modules/workspace/disk-agreement.js +33 -12
  95. package/dist/src/modules/workspace/disk-agreement.js.map +1 -1
  96. package/dist/src/modules/workspace/index.d.ts +6 -3
  97. package/dist/src/modules/workspace/index.d.ts.map +1 -1
  98. package/dist/src/modules/workspace/index.js +61 -15
  99. package/dist/src/modules/workspace/index.js.map +1 -1
  100. package/dist/src/modules/workspace/observe.d.ts +9 -1
  101. package/dist/src/modules/workspace/observe.d.ts.map +1 -1
  102. package/dist/src/modules/workspace/observe.js +50 -10
  103. package/dist/src/modules/workspace/observe.js.map +1 -1
  104. package/dist/src/modules/workspace/reconcile.d.ts +11 -1
  105. package/dist/src/modules/workspace/reconcile.d.ts.map +1 -1
  106. package/dist/src/modules/workspace/reconcile.js +19 -8
  107. package/dist/src/modules/workspace/reconcile.js.map +1 -1
  108. package/dist/src/modules/workspace/types.d.ts +8 -0
  109. package/dist/src/modules/workspace/types.d.ts.map +1 -1
  110. package/dist/src/modules/workspace/types.js.map +1 -1
  111. package/dist/src/modules/workspace/watcher.d.ts +7 -0
  112. package/dist/src/modules/workspace/watcher.d.ts.map +1 -1
  113. package/dist/src/modules/workspace/watcher.js +7 -5
  114. package/dist/src/modules/workspace/watcher.js.map +1 -1
  115. package/dist/src/recovery/discord-awareness-outbox.d.ts.map +1 -1
  116. package/dist/src/recovery/discord-awareness-outbox.js +1 -9
  117. package/dist/src/recovery/discord-awareness-outbox.js.map +1 -1
  118. package/dist/src/supplied-text.d.ts +2 -0
  119. package/dist/src/supplied-text.d.ts.map +1 -1
  120. package/dist/src/supplied-text.js +16 -7
  121. package/dist/src/supplied-text.js.map +1 -1
  122. package/dist/src/tool-result-guard.js +1 -1
  123. package/dist/src/tool-result-guard.js.map +1 -1
  124. package/dist/src/tune-out/coordinator.d.ts +2 -20
  125. package/dist/src/tune-out/coordinator.d.ts.map +1 -1
  126. package/dist/src/tune-out/coordinator.js +175 -70
  127. package/dist/src/tune-out/coordinator.js.map +1 -1
  128. package/dist/src/tune-out/tools.d.ts +14 -2
  129. package/dist/src/tune-out/tools.d.ts.map +1 -1
  130. package/dist/src/tune-out/tools.js.map +1 -1
  131. package/dist/src/types/agent.d.ts +2 -1
  132. package/dist/src/types/agent.d.ts.map +1 -1
  133. package/dist/src/types/framework.d.ts +54 -15
  134. package/dist/src/types/framework.d.ts.map +1 -1
  135. package/dist/src/types/module.d.ts +42 -3
  136. package/dist/src/types/module.d.ts.map +1 -1
  137. package/dist/src/types/trace.d.ts +4 -3
  138. package/dist/src/types/trace.d.ts.map +1 -1
  139. package/package.json +3 -3
  140. package/src/agent.ts +90 -25
  141. package/src/api/mcp-server-core.ts +10 -3
  142. package/src/code-execution/isolate/render.ts +7 -6
  143. package/src/code-execution/isolate/scripts.ts +5 -4
  144. package/src/framework.ts +1145 -723
  145. package/src/gate/event-gate.ts +220 -145
  146. package/src/gate/recipe-reconcile.ts +7 -5
  147. package/src/host-presentation.ts +4 -7
  148. package/src/index.ts +1 -0
  149. package/src/inference-bounds.ts +111 -0
  150. package/src/line-reader.ts +22 -5
  151. package/src/mcpl/errors.ts +4 -0
  152. package/src/mcpl/inbound-source.ts +2 -2
  153. package/src/mcpl/inference-router.ts +67 -10
  154. package/src/mcpl/modern-connection.ts +83 -68
  155. package/src/mcpl/protocol-family.ts +37 -4
  156. package/src/mcpl/push-coalescer.ts +2 -7
  157. package/src/mcpl/references.ts +3 -4
  158. package/src/mcpl/server-connection.ts +30 -21
  159. package/src/mcpl/tool-signature.ts +18 -11
  160. package/src/mcpl/transport.ts +261 -60
  161. package/src/mcpl/types.ts +18 -1
  162. package/src/module-registry.ts +178 -25
  163. package/src/modules/discord/discord-js-client.ts +33 -29
  164. package/src/modules/sender-name.ts +8 -5
  165. package/src/modules/workspace/disk-agreement.ts +39 -15
  166. package/src/modules/workspace/index.ts +65 -14
  167. package/src/modules/workspace/observe.ts +51 -10
  168. package/src/modules/workspace/reconcile.ts +22 -8
  169. package/src/modules/workspace/types.ts +5 -0
  170. package/src/modules/workspace/watcher.ts +8 -6
  171. package/src/recovery/discord-awareness-outbox.ts +1 -11
  172. package/src/supplied-text.ts +17 -6
  173. package/src/tool-result-guard.ts +1 -1
  174. package/src/tune-out/coordinator.ts +187 -85
  175. package/src/tune-out/tools.ts +14 -2
  176. package/src/types/agent.ts +2 -1
  177. package/src/types/framework.ts +55 -15
  178. package/src/types/module.ts +42 -3
  179. package/src/types/trace.ts +4 -3
package/README.md CHANGED
@@ -133,7 +133,7 @@ return {
133
133
  - **ApiModule** - WebSocket API event processing
134
134
  - **WorkspaceModule** - Mountable filesystem abstraction with Chronicle tree state, filesystem watching, and materialization
135
135
 
136
- DiscordModule and ApiModule store a sender's name that comes from outside the framework in a form marked with its source: a Discord author's username as `<name> (Discord)`, and the name on every `api:message` event, from an ApiServer caller or a host's own, as `<name> (API)`. An `api:message` whose `participant` isn't text, which its type doesn't allow, isn't stored, and starts no turn. Such a name is stored on one line: each run of line breaks (U+2028 and U+2029 included) and other control characters becomes one space. The generic name `user`, in any capitalization, is stored as given. Unless a host gives one of its own agents the name `user`, in any capitalization, or a name ending in ` (Discord)` or ` (API)`, such a message never carries an agent's name, so the agent's request never takes it as the agent's own turn. Where an agent's request shows senders' names, the agent sees the marked form, and the unmarked one in rows stored by earlier versions. A host that pushes an `api:message` in an agent's name records a user turn, not that agent's, with the same exception, and the ApiServer's message list returns each message's participant as stored, so a caller sees its own messages under `<name> (API)`. The ApiServer refuses a `participant` that isn't text, as it refuses content that isn't. The bot's own messages that a Discord history sync stores keep the name of the framework's first agent, as before. For a sender from outside, both modules also store the name as sent in `metadata.author` (with the author's Discord id), unless an `api:message` event's metadata already carries an `author` object, which is kept. History's author filter matches a row's `metadata.author` when it has one, and its participant otherwise. Code that tells senders apart should read a row's `metadata.author` (its `name`, and `id` for Discord) when it has one, and its participant otherwise, as the filter does: rows these modules stored in earlier versions have none, unless a host's `api:message` carried one.
136
+ DiscordModule and ApiModule store a sender's name that comes from outside the framework in a form marked with its source: a Discord author's username as `<name> (Discord)`, and the name on every `api:message` event, from an ApiServer caller or a host's own, as `<name> (API)`. An `api:message` whose `participant` isn't text, which its type doesn't allow, isn't stored, and starts no turn. Such a name is stored on one line: each run of line breaks (U+2028 and U+2029 included) and other control characters becomes one space. Each of the framework's notice openings in it is marked with a backslash, as in the text a participant or a server supplies. The generic name `user`, in any capitalization, is stored as given. Unless a host gives one of its own agents the name `user`, in any capitalization, or a name ending in ` (Discord)` or ` (API)`, such a message never carries an agent's name, so the agent's request never takes it as the agent's own turn. Where an agent's request shows senders' names, the agent sees the marked form, and the unmarked one in rows stored by earlier versions. A host that pushes an `api:message` in an agent's name records a user turn, not that agent's, with the same exception, and the ApiServer's message list returns each message's participant as stored, so a caller sees its own messages under its name's stored form, `<name> (API)`. The ApiServer refuses a `participant` that isn't text, as it refuses content that isn't. The bot's own messages that a Discord history sync stores keep the name of the framework's first agent, as before. For a sender from outside, both modules also store the name as sent in `metadata.author` (with the author's Discord id), unless an `api:message` event's metadata already carries an `author` object, which is kept. History's author filter matches a row's `metadata.author` when it has one, and its participant otherwise. Code that tells senders apart should read a row's `metadata.author` (its `name`, and `id` for Discord) when it has one, and its participant otherwise, as the filter does: rows these modules stored in earlier versions have none, unless a host's `api:message` carried one.
137
137
 
138
138
  ### Event Processing
139
139
 
@@ -148,6 +148,8 @@ Each agent has a `ContextManager` (from `@connectome/context-manager`) that main
148
148
  - **PassthroughStrategy** - No compression, raw message replay up to budget
149
149
  - **AutobiographicalStrategy** - Chunks old messages and summarizes them into diary entries, preserving recent context uncompressed
150
150
 
151
+ A turn keeps the messages it opened with whole: at a start that opens a turn, the framework pins raw (`pinRange`, named `agent-framework:turn-inputs`) the rows the agent sees that were stored after both the newest of its own messages that it sees and its consumed watermark, starting at the first such row that holds more than tool results, and removes the pin when the turn ends. The pinned rows' tokens count against the budget. If a committing compile refuses as over budget with the pin held, the pin is removed and the compile runs once more, so the turn goes on as it would have without it. A silent heartbeat tick pins nothing, and neither does a strategy without pins.
152
+
151
153
  Before inference, modules and MCPL hooks can inject additional context via `gatherContext()`. An `afterUser` injection is stored in the agent's window, as the message `compile()` would have placed after the last user message, so it stays where the agent saw it: the replies after it keep their thinking, and the cache keeps the turns before it. A source's unchanged content isn't stored again while the copy the agent will read as current has it whole: the one its last request held, or a newer one a start stored whose compile then didn't record (it threw, or the start failed before it); once a fold has summarized it or the strategy's window has passed it, it's stored again, as one more row. Where a changed one lands right after the agent's own latest message, with no one else's message between, `[Continue]` still ends the request, after it. A stored row is history to the strategy, capped, sharded, budgeted and folded like any message. Its metadata carries `system: true`, `kind: 'context-injection'` and `contextInjection: { agent, namespace, contentHash, part, parts }`, which `storedInjectionMarkOf` reads, and every other agent's view leaves it out. A module's injection can set `placedEachCompile: true` to be placed by `compile()` at each start instead, near the end, at the cost of the thinking of every reply after its old place.
152
154
 
153
155
  ### Persistence
@@ -336,6 +338,37 @@ stdio server; `'header'` is refused with a url that carries a `token`
336
338
  parameter or userinfo of its own, since whenever the Bearer header carries a
337
339
  credential it replaces the userinfo's Basic one.
338
340
 
341
+ Set `credentialRequired: true` for a fail-closed WebSocket dial. This requires
342
+ `tokenTransport: 'header'` and a host-attached `accessProvider`, called on every
343
+ dial including reconnects. A missing or throwing provider, or an empty or
344
+ non-sendable result, stops the dial without connecting or falling back. Credentials
345
+ must be printable ASCII with no space at either end; there is no minimum length.
346
+ The server's authentication scheme decides which credentials it accepts.
347
+
348
+ This mode forbids a static `token` (even empty), a URL `token` query parameter,
349
+ userinfo and fragments. It supports only WebSocket servers, not HTTP, stdio or
350
+ modern MCP. Cleartext `ws://` is allowed only to `localhost` or a literal loopback
351
+ address, not to a `*.localhost` name, which a resolver can send off this host;
352
+ use `wss://` for remote servers. These configuration mistakes are reported
353
+ descriptively when the server is configured, and checked again before the
354
+ provider runs at dial time.
355
+
356
+ Strict dial errors have the fixed form `MCPL server "<id>": <code>`:
357
+
358
+ | Code | Meaning |
359
+ | --- | --- |
360
+ | `provider-failed` | The provider is absent, throws, or returns an empty or non-sendable value. No connection is made. |
361
+ | `credential-rejected` | The server answers the WebSocket upgrade with HTTP 401 or 403. |
362
+ | `engine-unsupported` | A refused upgrade has no finite numeric status available from the client runtime. |
363
+ | `connection-failed` | Any other upgrade status, socket/TLS error, open timeout, cancellation, or strict configuration refusal at dial time. |
364
+
365
+ Redirects are not followed. Refused upgrades are classified only by the
366
+ `unexpected-response` event's numeric `statusCode`, never by error text or response
367
+ bodies; runtime support is determined by that capability, not a version list.
368
+ Leaving `credentialRequired` out, or setting it to `false` or `null`, keeps optional
369
+ credential behavior. Diagnostic filtering and credential retention are unchanged;
370
+ this option controls dialing, not a guarantee that all diagnostics hide secrets.
371
+
339
372
  A modern server's tools get the same prefix, `enabledTools`/`disabledTools`,
340
373
  class overrides and dispatch as an MCPL server's, and `listMcplServers()`
341
374
  shows its `family`, `protocolVersion` and `transport`. Its config differs in
@@ -420,10 +453,10 @@ above the agent's consumed watermark (set when the agent is created, and
420
453
  advanced at every compile of a request it sends, which a preview isn't, and at
421
454
  a tool boundary that injects messages into a stream declaring it carries them,
422
455
  as membrane's native path does from 0.6.0), on the current branch, not a
423
- sharded message, and not folded into a summary by compression. A message
424
- injected at a tool boundary whose stream doesn't say whether it carries
425
- injections, as no membrane 0.5.x stream does, stays unread though the model
426
- may have seen it. On any doubt — restart, branch switch, eviction — the host
456
+ sharded message, and not folded into a summary by compression. A stream that
457
+ doesn't say whether it carries injections is taken as one that doesn't: at a
458
+ tool boundary nothing is injected into it, and what's queued waits for the
459
+ turn's end. On any doubt — restart, branch switch, eviction — the host
427
460
  appends, as it does today. There is no per-subject cap: a busy channel's unread
428
461
  backlog is simply its unread backlog. Receipts and subject history are kept in
429
462
  the `mcpl/coalescing` state (retry window 1 h); audit lines are
@@ -591,9 +624,39 @@ static tools are listed like any server's.
591
624
  2. **Drive**: Framework iterates stream events (tokens, tool-calls, complete, error)
592
625
  3. **Tool yield**: Stream yields tool calls → framework dispatches concurrently → collects results
593
626
  4. **Resume**: All results in → stream resumes with tool results
594
- 5. **Budget restart**: If input tokens exceed `maxStreamTokens`, the stream is cancelled, context is recompressed, and a fresh stream starts. An agent whose model binds its thinking (`thinkingBinding.binds`) with `physicalWindowTokens` set skips this, and the window projection restarts it instead before a request the window can't hold
627
+ 5. **Budget restart**: If input tokens exceed `maxStreamTokens`, the stream is cancelled, context is recompressed (the turn's opening messages kept whole, as Context Management says), and a fresh stream starts. An agent whose model binds its thinking (`thinkingBinding.binds`) with `physicalWindowTokens` set skips this, and the window projection restarts it instead before a request the window can't hold
595
628
  6. **Complete**: Final response saved to context, agent returns to idle
596
629
 
630
+ ### Inference bounds
631
+
632
+ A model call that stops making progress is cut, so an agent isn't held by a provider that has gone quiet, or that keeps its connection open with keepalives (an Anthropic stream's pings, SSE comments) and never answers.
633
+
634
+ - **A resident's streamed call**, and an MCPL server's streamed inference request, get membrane's progress bounds where the adapter's stream reports content (`AnthropicAdapter`, `BedrockAdapter`). Before content, a call ends 60 s after its send, or, once a thinking block has started, at the later of that and the block's allowance, its `max_tokens` at 87 tokens a second. Once content has begun, it ends after 150 s without a provider event, or after the block's allowance when the last event was a thinking block's start and the allowance is longer. Membrane's README gives the rules whole.
635
+ - **Every streamed call the framework makes** also gets a flat bound from its last provider event: the larger of a setup term plus that allowance and 1,862 s (`FLAT_MINIMUM_MS`). The setup term is the larger of the before-content and between-events bounds, 150 s by default. So on an adapter with progress bounds the flat bound never runs out first. On one without, such as `OpenAICompatibleAdapter`, it's the only progress bound, and an SSE keepalive comment doesn't restart it, though a data frame that parses as an event does, a provider's own ping object included.
636
+ - **A whole non-streamed call**, a compression's, the reply judge's, or an MCPL server's non-streamed inference request, ends the setup term plus its allowance after its send, or, when it names no `max_tokens`, at the larger of the setup term and the flat minimum, unless its caller passed a `progressTimeoutMs` of its own. Its caller gets the `timeout` error. The event gate's own 20 s judge timeout ends the reply judge's call first at the defaults. Context-manager takes a cut compression call as a transient failure: the lane pauses and tries again, so compression that never lands within its bound shows as a lane that keeps pausing, not as a failed turn, and is a reason to raise the bound. On an adapter whose `complete()` streams under the hood, such as membrane's OpenAI Responses adapter in subscription mode, membrane renews the bound at each parsed provider event, so there it runs from the last event, as a stream's flat bound does.
637
+ - **A turn's call a bound cuts** fails as a `timeout`, and `DefaultErrorPolicy` gives it one fresh call, 1 s later, whatever other failures its turn had, except in a turn sent again after its retries ran out, before one of its rounds has run or had its tool calls cut off, whose failures get no retries. A fresh call that's cut too, with no other failure between, ends the turn, and its `[inference-failed]` note says the call timed out, that the call was made again and timed out again, and the reason. For a bound's cut the reason names the bound that ran out and the host's setting for it. A deadline expiry membrane throws (the Anthropic adapter's own watchdogs, the SDK's request timeout, a runtime's fetch timeout on a silent connection) counts the same toward the fresh call and the turn's end, and its reason is its own message, which names no setting. A bound's cut isn't `retryable`, so a host's own `errorPolicy` that retries only retryable errors gives it no fresh call; an expiry membrane throws stays `retryable`, as membrane made it.
638
+ - **A stream that keeps sending content** isn't ended by any of these, since content is progress.
639
+
640
+ These bounds don't replace the deadlines below them: a silent connection still meets the runtime's own fetch timeout (360 s on Bun 1.4.4) and, on `AnthropicAdapter`, the adapter's 600 s first-event and idle watchdogs, so on a silent connection a bound raised past those is met by them first.
641
+
642
+ The phase bounds, and a reason that names the bound that ran out, need the `Membrane` a host passes in to come from membrane 0.8.0 or later. An older one ignores `progressBounds`, so only the flat bound acts, and a cut's reason names no bound.
643
+
644
+ The flat and whole-call bounds read the request's `maxTokens`. A `max_tokens` set through `providerParams` or a hook isn't read, where membrane's own allowance reads what's sent, so a larger one set that way can let the flat bound run out before membrane's.
645
+
646
+ Where the values come from: membrane's README gives its progress bounds' measurements, on a production router's streamed Anthropic calls to `claude-opus-5-5` and `claude-haiku-5-5`. The flat minimum is the longest silence between frames of any completed call in that router's OpenAI calls (the Responses API over a WebSocket), standing in for an OpenAI-compatible stream, which wasn't measured. The whole-call bound's setup term is five times the longest wait from the send to content or a thinking block's start in those calls (a wait that router cuts at 30 s and sends again, so a longer one is unseen), and its allowance is generation at 87 tokens a second, the 1st percentile of Opus's thinking speed over its thinking blocks of 30 seconds or more. No completed streamed call in that record ran past the whole-call bound. Bedrock, other models (`claude-opus-4-6` among them), OpenAI-compatible streams and calls that aren't streamed, compression's among them, weren't measured, so a host whose calls run slower raises the bounds with `inferenceBounds`. Membrane's README also reports the wait for content growing with the prompt, so a resident near a full context window is the likeliest to meet the before-content bound first.
647
+
648
+ `inferenceBounds` sets them: `progressBounds` takes membrane's three values, from which the flat and whole-call bounds also derive, and `flatMinimumMs` the flat bound's least. `false` sets none. One setting covers every agent, so a host with one slower model or adapter raises them for all of its agents. A stream cut's reason is membrane's message, naming the bound that ran out, followed by the host setting for that bound, as in ``(the host's setting for this bound: `inferenceBounds.progressBounds.beforeContentMs`)``. A whole call's caller gets membrane's message alone. Each reason's opening and its setting:
649
+
650
+ | The reason begins | The setting | Default |
651
+ |---|---|---|
652
+ | `No content within …s of the send` | `progressBounds.beforeContentMs` | 60,000 ms |
653
+ | `No provider event within …s` | `progressBounds.betweenEventsMs` | 150,000 ms |
654
+ | `No content within …s of a thinking block's start` (or `No provider event within …s of a thinking block's start`) | `progressBounds.thinkTokensPerSecond`: a lower rate allows a slower think | 87 |
655
+ | `No provider progress within …ms`, on a stream | `flatMinimumMs`, or the setup term and allowance when they're larger | 1,862,000 ms |
656
+ | `No provider progress within …ms`, on a call that isn't streamed | the setup term (`beforeContentMs`, `betweenEventsMs`) and the allowance (`thinkTokensPerSecond`, or the request's `maxTokens`); the larger of the setup term and `flatMinimumMs` when the request names no `maxTokens` | 150 s plus `maxTokens` at 87 a second; 1,862,000 ms with no `maxTokens` |
657
+
658
+ Each cut of a turn's call is traced as `inference:failed`, with its reason as `error`, and logged with the turn's inference log as a failed call, whether or not its fresh call then answers, so a host can count cuts a resident never sees and raise a bound before turns start failing. An MCPL server's request that a bound cuts is traced as `mcpl:inference_fail` with the reason as `error`, and a compression or reply-judge call's cut reaches only its caller, as the `timeout` error.
659
+
597
660
  ### Abort / Cancellation
598
661
 
599
662
  ```typescript
@@ -795,8 +858,8 @@ retract of a batch takes off the mark of its emoji from each of its messages,
795
858
  whichever batch placed it. 0.22.x reads only versions 1 and 2, and its start
796
859
  stops on a version 3 file: to go back to 0.22.x, move the file aside first,
797
860
  and 0.22.x then starts with no marks history. A version 1 ledger, which only
798
- an unreleased commit wrote, is refused until it is moved away, and its error
799
- says what that gives up.
861
+ an unreleased commit wrote, is refused as any version but 2 and 3 is, until it
862
+ is moved away.
800
863
 
801
864
  ## Observability
802
865
 
@@ -1,4 +1,5 @@
1
1
  import type { Membrane, NormalizedMessage, NormalizedRequest, ContentBlock, ThinkingBindingEntry, YieldingStream } from '@animalabs/membrane';
2
+ import { type InferenceBounds } from './inference-bounds.js';
2
3
  import type { CacheWireReceipt } from './kv-unified-wire.js';
3
4
  import { ToolResultGuard } from './tool-result-guard.js';
4
5
  import { type PlacedDrop } from './thinking-drops.js';
@@ -23,6 +24,9 @@ export interface ActivationRequestOptions {
23
24
  * pass it (its errorPolicy is their retry layer); a direct caller of
24
25
  * startStream keeps membrane's retries. */
25
26
  membraneRetries?: boolean;
27
+ /** The framework's inferenceBounds, resolved: the stream gets their phase
28
+ * bounds and flat bound. None when left out. */
29
+ inferenceBounds?: InferenceBounds | null;
26
30
  }
27
31
  /** A compile's render stats, as context-manager's `getRenderStats()` types
28
32
  * them; each compile carries its own, where the strategy records them, in
@@ -79,6 +83,7 @@ export interface StartStreamResult {
79
83
  }
80
84
  import type { ContextManager, TokenBudget, ContextInjection, CompileResult, MessageId, MessageMetadata, RequestIdentity, ThinkingStrip } from '@animalabs/context-manager';
81
85
  import type { AgentConfig, AgentState, SameRoundThinkTextPolicy, SameRoundThinkTextPolicySource, ToolCallId, ToolCall, ToolResult, ToolDefinition, AgentInfo, InferenceResult, InferenceOptions, AgentRuntimeSettingsPatch, AgentRuntimeSettingsSnapshot, AgentRuntimeSettingsOverrides } from './types/index.js';
86
+ export declare function assertThinkingBinding(setting: string, value: AgentConfig['thinkingBinding']): void;
82
87
  /**
83
88
  * Refuse an agent config whose `promptCaching`, `toolResultGuard`,
84
89
  * `toolWrapperProseGuard`, `thinking.enabled`, `thinkingBinding.dropBlock`,
@@ -470,11 +475,7 @@ export declare class Agent {
470
475
  * A message above it may still be replaced or withdrawn in place by its
471
476
  * sender, though it may already have been in one of the agent's requests.
472
477
  * A live stream carries each round's own content and results, which it
473
- * stores at its tool boundaries, into its next request. It can also carry
474
- * the messages injected at a boundary whose stream didn't say whether it
475
- * carries injections, as no membrane 0.5.x stream does: its native path
476
- * carries them and its XML path drops them, and either way they stay
477
- * above it.
478
+ * stores at its tool boundaries, into its next request.
478
479
  */
479
480
  private consumedWatermark;
480
481
  /** Counts marks (markContextConsumed's and applyCompileWatermark's), so a
@@ -484,8 +485,7 @@ export declare class Agent {
484
485
  * The newest stored message a compile or a tool boundary may have put in
485
486
  * front of the agent, per branch. It moves where the consumed watermark
486
487
  * does, and sooner: when a committing compile takes its value, before it
487
- * awaits, and at every tool boundary that injects, whether or not the
488
- * stream says it carries injected messages. A message above it may still
488
+ * awaits, and at every tool boundary that injects into its stream. A message above it may still
489
489
  * have been shown, though: for one, a live stream carries each round's own
490
490
  * content and results, stored at a boundary that injected nothing, into its
491
491
  * next request. A compile that throws assembled nothing, and gives its move
@@ -522,6 +522,24 @@ export declare class Agent {
522
522
  branch: string;
523
523
  sequence: number;
524
524
  } | null): void;
525
+ /**
526
+ * Keep the stored rows from `first` through `last` raw for the turn now
527
+ * opening, with a raw pin under one name per agent. Any pin of that name
528
+ * already held is removed first, one a crash left included. Under a
529
+ * strategy without pins nothing is pinned. A committing compile that
530
+ * refuses as over budget while a pin of that name is held removes it and
531
+ * compiles once more, and `unpinTurnInputs` removes it. Returns the pin's
532
+ * id, or undefined when nothing was pinned.
533
+ *
534
+ * @internal For the framework's turn starts; not a host API.
535
+ */
536
+ pinTurnInputs(first: MessageId, last: MessageId): string | undefined;
537
+ /** Remove the turn's input pin `pinId`, or without one every pin of its
538
+ * name. False when a removal threw.
539
+ * @internal For the framework's turn starts and ends; not a host API. */
540
+ unpinTurnInputs(pinId?: string): boolean;
541
+ private compileUnpinningOnRefusal;
542
+ private holdsTurnInputsPin;
525
543
  /**
526
544
  * Per destination (a server's channel, by its key), the newest consumed
527
545
  * watermark the agent had read when it published there by a route the
@@ -549,7 +567,7 @@ export declare class Agent {
549
567
  * stream declaring it carries them; see consumedWatermark). */
550
568
  markContextConsumed(): void;
551
569
  /** Mark everything currently stored as possibly shown (a tool boundary
552
- * that injected messages, whatever its stream says it carries). Without
570
+ * that injected messages into its stream). Without
553
571
  * a watermark the coalescer counts a message as shown, as it counts one
554
572
  * read without a consumed watermark. */
555
573
  markContextShown(): void;
@@ -591,7 +609,9 @@ export declare class Agent {
591
609
  * run. It isn't told the agent's thinking binding (`thinkingBinding.binds`),
592
610
  * so a context manager that keeps a thinking-binding record neither reads
593
611
  * nor writes the record here, and what it returns keeps thinking whose
594
- * earlier conversation changed. */
612
+ * earlier conversation changed. Called while a turn's input pin is held
613
+ * (pinTurnInputs), a refusal as over budget removes the pin and compiles
614
+ * once more, as the turn's own compiles do. */
595
615
  compileContext(budget?: TokenBudget): Promise<CompileResult>;
596
616
  /**
597
617
  * The stored context injections of this agent's that the last compile it
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,YAAY,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE9I,OAAO,KAAK,EAAE,gBAAgB,EAAyB,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAA+C,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAK5D,OAAO,EAQL,KAAK,iBAAiB,EAEtB,KAAK,mBAAmB,EAEzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAO/E,MAAM,WAAW,wBAAwB;IACvC,8DAA8D;IAC9D,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC;wEACoE;IACpE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;uBAKmB;IACnB,gBAAgB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACvC;;;gDAG4C;IAC5C,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED;;mCAEmC;AACnC,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,UAAU,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;AAQpF;+CAC+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AAiB;IAazB,cAAc,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG;QAAE,OAAO,EAAE,IAAI,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,KAAK,CAc7E;YAEa,WAAW;IAsEzB,OAAO,CAAC,yBAAyB;IAuBjC,OAAO,CAAC,uBAAuB;CA8BhC"}
package/dist/src/agent.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { NOTICE_TAG } from './notice-tags.js';
2
2
  import { heartbeatToolAlias } from './heartbeat/heartbeat.js';
3
3
  import { isAbortedResponse } from '@animalabs/membrane';
4
+ import { streamBounds } from './inference-bounds.js';
4
5
  import { ToolResultGuard } from './tool-result-guard.js';
5
6
  import { withoutTokenEstimates } from './thinking-token-stamp.js';
6
7
  import { placeThinkingDrops } from './thinking-drops.js';
@@ -41,6 +42,15 @@ function wireDigest(value) {
41
42
  const DEFAULT_CONTEXT_BUDGET_TOKENS = 100_000;
42
43
  const DEFAULT_TRANSITION_PACE_TOKENS = 16_000;
43
44
  const DEFAULT_SAME_ROUND_THINK_TEXT_POLICY = 'public';
45
+ const TURN_INPUTS_PIN = 'agent-framework:turn-inputs';
46
+ export function assertThinkingBinding(setting, value) {
47
+ if (holdsSettings(setting, value, '{ binds: true, dropBlock: true }')) {
48
+ assertBooleanSetting(`${setting}.dropBlock`, value.dropBlock, 'true asks the provider to drop a signed thinking block whose earlier conversation changed rather than refuse the request, ' +
49
+ 'and false or leaving it out sends nothing, so the account\'s default applies');
50
+ assertBooleanSetting(`${setting}.binds`, value.binds, 'true says the model binds its signed thinking to the conversation before it, so each compile tells the context manager so, ' +
51
+ 'and false or leaving it out compiles as before');
52
+ }
53
+ }
44
54
  /**
45
55
  * Refuse an agent config whose `promptCaching`, `toolResultGuard`,
46
56
  * `toolWrapperProseGuard`, `thinking.enabled`, `thinkingBinding.dropBlock`,
@@ -60,12 +70,7 @@ export function assertAgentSwitches(config) {
60
70
  if (holdsSettings(`${agent} thinking`, config.thinking, '{ enabled: true }')) {
61
71
  assertBooleanSetting(`${agent} thinking.enabled`, config.thinking.enabled, 'true asks the provider for extended thinking, and false or leaving it out doesn\'t');
62
72
  }
63
- if (holdsSettings(`${agent} thinkingBinding`, config.thinkingBinding, '{ binds: true, dropBlock: true }')) {
64
- assertBooleanSetting(`${agent} thinkingBinding.dropBlock`, config.thinkingBinding.dropBlock, 'true asks the provider to drop a signed thinking block whose earlier conversation changed rather than refuse the request, ' +
65
- 'and false or leaving it out sends nothing, so the account\'s default applies');
66
- assertBooleanSetting(`${agent} thinkingBinding.binds`, config.thinkingBinding.binds, 'true says the model binds its signed thinking to the conversation before it, so each compile tells the context manager so, ' +
67
- 'and false or leaving it out compiles as before');
68
- }
73
+ assertThinkingBinding(`${agent} thinkingBinding`, config.thinkingBinding);
69
74
  if (holdsSettings(`${agent} refusalHandling`, config.refusalHandling, '{ autoRewind: true }')) {
70
75
  assertBooleanSetting(`${agent} refusalHandling.autoRewind`, config.refusalHandling.autoRewind, 'true redacts the turn that tripped a refusal and runs again, up to maxRewinds times, ' +
71
76
  'and false or leaving it out doesn\'t');
@@ -938,11 +943,7 @@ export class Agent {
938
943
  * A message above it may still be replaced or withdrawn in place by its
939
944
  * sender, though it may already have been in one of the agent's requests.
940
945
  * A live stream carries each round's own content and results, which it
941
- * stores at its tool boundaries, into its next request. It can also carry
942
- * the messages injected at a boundary whose stream didn't say whether it
943
- * carries injections, as no membrane 0.5.x stream does: its native path
944
- * carries them and its XML path drops them, and either way they stay
945
- * above it.
946
+ * stores at its tool boundaries, into its next request.
946
947
  */
947
948
  consumedWatermark = null;
948
949
  /** Counts marks (markContextConsumed's and applyCompileWatermark's), so a
@@ -952,8 +953,7 @@ export class Agent {
952
953
  * The newest stored message a compile or a tool boundary may have put in
953
954
  * front of the agent, per branch. It moves where the consumed watermark
954
955
  * does, and sooner: when a committing compile takes its value, before it
955
- * awaits, and at every tool boundary that injects, whether or not the
956
- * stream says it carries injected messages. A message above it may still
956
+ * awaits, and at every tool boundary that injects into its stream. A message above it may still
957
957
  * have been shown, though: for one, a live stream carries each round's own
958
958
  * content and results, stored at a boundary that injected nothing, into its
959
959
  * next request. A compile that throws assembled nothing, and gives its move
@@ -987,6 +987,67 @@ export class Agent {
987
987
  if (watermark)
988
988
  this.answeredWatermark = watermark;
989
989
  }
990
+ /**
991
+ * Keep the stored rows from `first` through `last` raw for the turn now
992
+ * opening, with a raw pin under one name per agent. Any pin of that name
993
+ * already held is removed first, one a crash left included. Under a
994
+ * strategy without pins nothing is pinned. A committing compile that
995
+ * refuses as over budget while a pin of that name is held removes it and
996
+ * compiles once more, and `unpinTurnInputs` removes it. Returns the pin's
997
+ * id, or undefined when nothing was pinned.
998
+ *
999
+ * @internal For the framework's turn starts; not a host API.
1000
+ */
1001
+ pinTurnInputs(first, last) {
1002
+ if (!this.unpinTurnInputs())
1003
+ return undefined;
1004
+ const cm = this.contextManager;
1005
+ if (typeof cm.getStrategy().pinRange !== 'function')
1006
+ return undefined;
1007
+ try {
1008
+ return cm.pinRange(first, last, { name: TURN_INPUTS_PIN });
1009
+ }
1010
+ catch (error) {
1011
+ console.error(`[turn-inputs] ${this.name}: could not pin the turn's inputs (${first}..${last}), so they may be compressed:`, error);
1012
+ return undefined;
1013
+ }
1014
+ }
1015
+ /** Remove the turn's input pin `pinId`, or without one every pin of its
1016
+ * name. False when a removal threw.
1017
+ * @internal For the framework's turn starts and ends; not a host API. */
1018
+ unpinTurnInputs(pinId) {
1019
+ try {
1020
+ for (const pin of this.contextManager.listPins()) {
1021
+ if (pin.name === TURN_INPUTS_PIN && (pinId === undefined || pin.id === pinId))
1022
+ this.contextManager.unpin(pin.id);
1023
+ }
1024
+ return true;
1025
+ }
1026
+ catch (error) {
1027
+ console.error(`[turn-inputs] ${this.name}: could not remove the turn's input pin:`, error);
1028
+ return false;
1029
+ }
1030
+ }
1031
+ async compileUnpinningOnRefusal(compile) {
1032
+ const pinned = this.holdsTurnInputsPin();
1033
+ try {
1034
+ return await compile();
1035
+ }
1036
+ catch (error) {
1037
+ if (error?.name !== 'OverBudgetError' || !pinned || !this.unpinTurnInputs())
1038
+ throw error;
1039
+ console.error(`[turn-inputs] ${this.name}: the compile refused with the turn's inputs pinned, so they are unpinned and it compiles again`);
1040
+ return compile();
1041
+ }
1042
+ }
1043
+ holdsTurnInputsPin() {
1044
+ try {
1045
+ return this.contextManager.listPins().some((pin) => pin.name === TURN_INPUTS_PIN);
1046
+ }
1047
+ catch {
1048
+ return false;
1049
+ }
1050
+ }
990
1051
  /**
991
1052
  * Per destination (a server's channel, by its key), the newest consumed
992
1053
  * watermark the agent had read when it published there by a route the
@@ -1031,7 +1092,7 @@ export class Agent {
1031
1092
  this.shownWatermark = this.consumedWatermark;
1032
1093
  }
1033
1094
  /** Mark everything currently stored as possibly shown (a tool boundary
1034
- * that injected messages, whatever its stream says it carries). Without
1095
+ * that injected messages into its stream). Without
1035
1096
  * a watermark the coalescer counts a message as shown, as it counts one
1036
1097
  * read without a consumed watermark. */
1037
1098
  markContextShown() {
@@ -1112,7 +1173,9 @@ export class Agent {
1112
1173
  * run. It isn't told the agent's thinking binding (`thinkingBinding.binds`),
1113
1174
  * so a context manager that keeps a thinking-binding record neither reads
1114
1175
  * nor writes the record here, and what it returns keeps thinking whose
1115
- * earlier conversation changed. */
1176
+ * earlier conversation changed. Called while a turn's input pin is held
1177
+ * (pinTurnInputs), a refusal as over budget removes the pin and compiles
1178
+ * once more, as the turn's own compiles do. */
1116
1179
  async compileContext(budget) {
1117
1180
  // RFC-006 §3.3: consumption is determined at assembly — a compile that
1118
1181
  // fails assembled nothing, so the watermark moves only on success.
@@ -1121,7 +1184,7 @@ export class Agent {
1121
1184
  const shownBefore = this.shownWatermark;
1122
1185
  if (watermark)
1123
1186
  this.shownWatermark = watermark;
1124
- const compile = () => this.contextManager.compile(this.compileBudget(budget));
1187
+ const compile = () => this.compileUnpinningOnRefusal(() => this.contextManager.compile(this.compileBudget(budget)));
1125
1188
  let result;
1126
1189
  try {
1127
1190
  result = budget ? await compile() : await this.compileAtLiveBudget(compile);
@@ -1375,7 +1438,8 @@ export class Agent {
1375
1438
  const shownBefore = this.shownWatermark;
1376
1439
  if (watermark)
1377
1440
  this.shownWatermark = watermark;
1378
- const compile = () => this.contextManager.compile(this.compileBudget(budget), injections, opts);
1441
+ const select = () => this.contextManager.compile(this.compileBudget(budget), injections, opts);
1442
+ const compile = opts?.dryRun ? select : () => this.compileUnpinningOnRefusal(select);
1379
1443
  let result;
1380
1444
  try {
1381
1445
  result = budget || opts?.dryRun ? await compile() : await this.compileAtLiveBudget(compile);
@@ -1936,6 +2000,7 @@ export class Agent {
1936
2000
  // since membrane 0.7 its own schedules, ten minutes at a 529, would
1937
2001
  // otherwise run inside each of the caller's attempts, out of its sight.
1938
2002
  ...(options.membraneRetries === false ? { retry: false } : {}),
2003
+ ...streamBounds(options.inferenceBounds ?? null, request.config.maxTokens),
1939
2004
  // Retry a content-policy refusal at the provider seam rather than at
1940
2005
  // the framework level: membrane replays the SAME request immediately
1941
2006
  // (cache-warm), where a framework-level requeue would recompile and