Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Merge pull request #6150 from AdityaUmale/fix/mail-1a1e0f46-remove-step-cap

milind-sonib28ce347ff19
diff --cc docs/runtime-contract.md
index 9cad57721d,fc19844593..3288b1c075
--- a/docs/runtime-contract.md
+++ b/docs/runtime-contract.md
@@@ -111,9 -111,9 +111,9 @@@ The suite asserts these after every sce
## 8. Ports
-The host (today `server/index.ts`) implements `TurnRunner`: `validate`, `canStart`, `run`, `park`, `report`, `changed`, `names`, and optionally `outward(a)`: the short labels of the outward actions (sends, posts, publishes, commits, pushes, payments) the node's cut turn completed since it began, read from the thread's activity rows (a room thread's rows attributed to the member); the restart policy (§5) reads it once at open and never reruns a turn that acted outward. The runtime owns the record and the decisions; the host owns engines, threads, chips, cards, names and notifications. A turn the host runs itself (a person's, a routine's, a room member's) begins its root with `begin()` and ends it through `end()` with the turn's evidence, cards and seat; a turn the runtime dispatched ends through its `run` result. There is no other settle, and a hand-off from a turn whose root was never begun is refused ("no turn"). The level the host records at enqueue (`levelOf`) is the level the target's turn will run with: a room hand-off's is resolved from its source, since a Chief's level flows into a room with the hand-off and never onto the shared thread (invariant I6). When that level came down a Chief's chain, `levelOf` also returns the Chief conversation's level, which the coordinator passes as `levels.chief`; the host resolves the chain from the requester's node up its parents (`server/host/delegated-level.ts`). A host method that throws is logged and read as "not now"; the next tick retries. The host calls `tick()` on its own schedule and `progress(id)` when it sees activity on a turn; `progress` writes no event (per-tool-call rows would be noise), every status change does.
+The host (today `server/index.ts`) implements `TurnRunner`: `validate`, `canStart`, `run`, `park`, `report`, `changed`, `names`, and optionally `away(a)` (the assignee's place cannot be reached now; §6) and `outward(a)`: the short labels of the outward actions (sends, posts, publishes, commits, pushes, payments) the node's cut turn completed since it began, read from the thread's activity rows (a room thread's rows attributed to the member); the restart policy (§5) reads it once at open and never reruns a turn that acted outward. The runtime owns the record and the decisions; the host owns engines, threads, chips, cards, names and notifications. A turn the host runs itself (a person's, a routine's, a room member's) begins its root with `begin()` and ends it through `end()` with the turn's evidence, cards and seat; a turn the runtime dispatched ends through its `run` result. There is no other settle, and a hand-off from a turn whose root was never begun is refused ("no turn"). The level the host records at enqueue (`levelOf`) is the level the target's turn will run with: a room hand-off's is resolved from its source, since a Chief's level flows into a room with the hand-off and never onto the shared thread (invariant I6). When that level came down a Chief's chain, `levelOf` also returns the Chief conversation's level, which the coordinator passes as `levels.chief`; the host resolves the chain from the requester's node up its parents (`server/host/delegated-level.ts`). A host method that throws is logged and read as "not now"; the next tick retries. The host calls `tick()` on its own schedule and `progress(id)` when it sees activity on a turn; `progress` writes no event (per-tool-call rows would be noise), every status change does.
- Engine drivers declare capabilities (`server/runtime/capabilities.ts`): `resume` (keeps a native session), `nativeReviewer`, `full`, `edits`, `stepCap`, `subagents`. The level rule and the continuation rule read these flags, never driver names.
+ Engine drivers declare capabilities (`server/runtime/capabilities.ts`): `resume` (keeps a native session), `nativeReviewer`, `full`, `edits`, `subagents`. The level rule and the continuation rule read these flags, never driver names.
## 9. One tool surface
diff --cc server/drivers/openai-chat.ts
index 71da009675,8a622d5683..cc0a48063a
--- a/server/drivers/openai-chat.ts
+++ b/server/drivers/openai-chat.ts
@@@ -625,12 -623,9 +622,11 @@@ export function createOpenAIChatRuntime
messages.push({ role: "user", content: unread.join("\n\n") });
deliveredAsides.push(...unread);
}
- turnEntry.ending = round === MAX_CHAT_ROUNDS - 1;
+ // Servers still starting when the turn began join once they have, never after the tools were dropped (none left while ask_user is allowed).
+ const joined = !questionAllowed || tools.definitions.length ? await joinLateChatTools(tools, [ASK_USER_TOOL_DEFINITION]) : undefined;
+ for (const message of joined ?? []) emit({ ...base(turn.threadId, turnId), type: "runtime.notice", message: safeText(message) });
native("out", options.nativeLog.outgoing(turn, messages, model, tools.definitions));
- let attempt = 0;
- let resized = false;
+ let attempt = 0, resized = false;
let completion: Completion;
for (;;) {
let streamed = false;