[GH-ISSUE #6292] [Feature]: Let capability packages receive structured data from a turn #3507

Closed
opened 2026-10-21 06:03:46 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @BiBoBaBe on GitHub (Sep 17, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6292

Originally assigned to: @SpicyMarinara on GitHub.

What problem does this solve?

A capability package can put text into a turn's prompt (registerPromptContext, API 1.7/1.14) and read named verbs back out of the finished narration (gm-verbs.json, API 1.16). Both directions are conventions the model is asked to honour, and there is no way to get structured data back from a turn that the provider itself has constrained.

That gap bites hardest for a package that owns live state — a world, a clock, an inventory, a map. Concretely, with the verb path today:

  • The model writes a place name that does not exist, and the verb is rejected after the fact. The turn is spent, the state did not move, and the player sees narration describing something that did not happen.
  • Recovering means a repair pass: another call, more latency, more spend.
  • The package has to parse structure out of prose, so every model and every sampler setting is a new source of format drift.

Measuring this on a package I maintain, across identical scenes: parsing named actions out of narration produced at least one unusable argument in 1 of 3 turns. Handing the same vocabulary to the model as a JSON Schema with enums produced 0 rejections in 3 of 3. The difference is not prompt wording — it is whether the allowed values are a constraint or a request.

Proposed solution

Let a package register a tool the model may call, with the parameters as a JSON Schema the package builds:

api.registerTool({
  name: "set_time",
  description: "Move the world clock forward or back.",
  parameters: {
    type: "object",
    properties: {
      action: { type: "string", enum: ["advance", "rewind"] },
      minutes: { type: "integer", minimum: 0 },
    },
    required: ["action", "minutes"],
    additionalProperties: false,
  },
  handler: async (args, { chatId }) => ({ time: await moveClock(chatId, args) }),
});

Engine offers it alongside the built-in tools, validates the call, and hands the arguments to the package's handler. The enum is the point: a package that knows the twelve places in its world can put those twelve strings in the schema, and a thirteenth is refused before the handler ever sees it.

Alternatives considered

  • A response format / structured output on the whole reply. This is the obvious alternative and I think it is the wrong one here: it claims the entire response, so narration would have to become a field inside a JSON object and could no longer stream. Roleplay and Game both depend on the prose arriving token by token. A tool call arrives beside the prose and costs it nothing.
  • Keep extending the verb table. gm-verbs.json is declarative and hash-pinned, which is genuinely better for reviewability, but it is still parsed out of generated text and cannot express argument types, ranges or required fields.
  • Each package prompts for its own JSON block and parses it. This is what packages do today. It is the thing that drifts.

Additional context

Engine already has the machinery: resolveGenerationTools builds tool definitions, executeToolCalls dispatches them, and the argument validator already names the allowed enum values on a refusal — which is exactly the repair signal a model needs.

I have a working implementation and opened it as a PR so the discussion has something concrete to look at. It is not asking to be merged as-is; the PR body lists four design questions I would rather a maintainer decide than assume, chiefly whether package tools should be scoped to chats bound to the package (as verbs are) rather than attached globally, and whether the tool surface should be manifest-declared and hash-pinned so it is reviewable at install time rather than appearing at runtime.

Filing this issue after the fact rather than before, which is the wrong order per CONTRIBUTING.md; opening it now so the PR has somewhere to point.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @BiBoBaBe on GitHub (Sep 17, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6292 Originally assigned to: @SpicyMarinara on GitHub. ## What problem does this solve? A capability package can put text **into** a turn's prompt (`registerPromptContext`, API 1.7/1.14) and read named verbs back **out** of the finished narration (`gm-verbs.json`, API 1.16). Both directions are conventions the model is *asked* to honour, and there is no way to get structured data back from a turn that the provider itself has constrained. That gap bites hardest for a package that owns live state — a world, a clock, an inventory, a map. Concretely, with the verb path today: - The model writes a place name that does not exist, and the verb is rejected after the fact. The turn is spent, the state did not move, and the player sees narration describing something that did not happen. - Recovering means a repair pass: another call, more latency, more spend. - The package has to parse structure out of prose, so every model and every sampler setting is a new source of format drift. Measuring this on a package I maintain, across identical scenes: parsing named actions out of narration produced at least one unusable argument in **1 of 3 turns**. Handing the same vocabulary to the model as a JSON Schema with enums produced **0 rejections in 3 of 3**. The difference is not prompt wording — it is whether the allowed values are a constraint or a request. ## Proposed solution Let a package register a **tool** the model may call, with the parameters as a JSON Schema the package builds: ```ts api.registerTool({ name: "set_time", description: "Move the world clock forward or back.", parameters: { type: "object", properties: { action: { type: "string", enum: ["advance", "rewind"] }, minutes: { type: "integer", minimum: 0 }, }, required: ["action", "minutes"], additionalProperties: false, }, handler: async (args, { chatId }) => ({ time: await moveClock(chatId, args) }), }); ``` Engine offers it alongside the built-in tools, validates the call, and hands the arguments to the package's handler. The enum is the point: a package that knows the twelve places in its world can put those twelve strings in the schema, and a thirteenth is refused before the handler ever sees it. ## Alternatives considered - **A response format / structured output on the whole reply.** This is the obvious alternative and I think it is the wrong one here: it claims the entire response, so narration would have to become a field inside a JSON object and could no longer stream. Roleplay and Game both depend on the prose arriving token by token. A tool call arrives *beside* the prose and costs it nothing. - **Keep extending the verb table.** `gm-verbs.json` is declarative and hash-pinned, which is genuinely better for reviewability, but it is still parsed out of generated text and cannot express argument types, ranges or required fields. - **Each package prompts for its own JSON block and parses it.** This is what packages do today. It is the thing that drifts. ## Additional context Engine already has the machinery: `resolveGenerationTools` builds tool definitions, `executeToolCalls` dispatches them, and the argument validator already names the allowed enum values on a refusal — which is exactly the repair signal a model needs. I have a working implementation and opened it as a PR so the discussion has something concrete to look at. It is **not** asking to be merged as-is; the PR body lists four design questions I would rather a maintainer decide than assume, chiefly whether package tools should be scoped to chats bound to the package (as verbs are) rather than attached globally, and whether the tool surface should be manifest-declared and hash-pinned so it is reviewable at install time rather than appearing at runtime. Filing this issue after the fact rather than before, which is the wrong order per `CONTRIBUTING.md`; opening it now so the PR has somewhere to point. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 06:03:46 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Sep 17, 2026):

Implemented in #6290 and merged into staging. Capability packages can register structured, validated tool calls through Capability API 1.19.

<!-- gh-comment-id:5720321749 --> @SpicyMarinara commented on GitHub (Sep 17, 2026): Implemented in #6290 and merged into staging. Capability packages can register structured, validated tool calls through Capability API 1.19.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#3507
No description provided.