Request automatic optional input sections in prompts

This commit is contained in:
2026-12-03 21:52:35 +00:00
parent 207677e994
commit 33cc00d4f0

View File

@@ -0,0 +1,81 @@
# Feature Request: Automatic Optional Input Content in Prompts
Status: proposed
Requested: 2026-12-03
## Consumer and Use Case
An Ansible role collection deploys a D&D transcript-processing suite in which
Narratio invokes Scriptorium to execute PromptKit definitions. Ansible manages
the definitions and application configuration; it does not know which runtime
inputs will be available for a particular session.
The session-recap and character-analysis prompts use the current transcript and,
when available, a previous session's recap. The previous recap is legitimately
absent for a first session or when a predecessor has no published recap.
Narratio omits unavailable inputs whose bindings are optional. Other prompts
similarly declare optional player or party context.
We need one prompt definition to work in both situations automatically:
include optional context when supplied, and omit its section when absent.
## Observed Released Behavior
Verified with Scriptorium v0.16.0, PromptKit v0.25.0 and Narratio v4.0.0.
The [format reference](../formats.md#inputs) permits optional declarations but
requires any input referenced during template rendering to exist. For example:
```yaml
inputs:
- name: recap
required: false
```
A message containing `{{ input "recap" }}` still fails when the request omits
`recap`, with `referenced unknown input artifact: recap`. Putting that call in
an `if` or `with` condition also fails. The released configuration interface
does not offer an input-presence condition, optional-read operation or declared
input default that provides the requested automatic behavior. This is a
capability request, not a claim that the documented strict behavior regressed.
## Desired Consumer-Facing Behavior
Prompt authors must be able to express an optional section whose inclusion
depends on whether its named input was supplied for the current request.
- When the input is supplied, render its content in that section normally.
- When it is omitted, preparation and rendering succeed and omit the section,
including any heading or explanatory text that would incorrectly imply
context was supplied.
- Make the decision from actual request input availability. Operators and
calling applications should not need to maintain a separate Boolean flag,
select a different prompt or overlay, or create placeholder inputs.
- Support this through the prompt-definition configuration consumed by
Scriptorium, so the existing Narratio omission behavior can remain unchanged.
- Retain normal failure for missing required inputs. The request concerns
omitted optional inputs, not suppression of errors in supplied inputs.
The exact syntax and public API are for PromptKit to design. This request does
not prescribe helpers, data structures, renderer changes or internal control flow.
## Acceptance Scenarios
1. Supply a current transcript and a synthetic previous recap. The prepared
prompt contains the previous-recap section and its supplied content.
2. Use the same definition and transcript but omit the previous recap. Prompt
preparation succeeds and contains neither that section nor its heading,
without changing variables, configuration selection or the calling workflow.
3. For a definition with independently optional context inputs, supplying one
and omitting another includes only the available context sections.
4. Omitting the definition's required transcript still fails normally.
These outcomes should be observable through offline Scriptorium preparation;
no provider call is needed to establish the requested rendering behavior.
Preparation and generation must agree on the resulting prompt content.
## Scope
This document requests the consumer capability only. Implementation planning,
application changes, release selection and subsequent Ansible adoption are
separate work. It does not request changes to Narratio's input delivery contract.