Interface PromptComposer

All Known Implementing Classes:
ComponentPropsPromptComposer, EventScriptPromptComposer, InstanceWizardPromptComposer, NamedQueryPromptComposer, QueryBrowserPromptComposer, UdtEditorPromptComposer
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface PromptComposer
Captures host-UI state at submit time and turns it into the host-context blocks that lead the message body sent to the assistant's harness. Implementations are invoked on every submit, so they should snapshot live host state inside compose(String, List) rather than at construction time.

The composer owns only the host-context portion of the wire format. The framework assembles the full message — the composer's blocks, then the canonical <references>… </references> block for any user-inserted references, then the user's prompt — so composers never render references or splice the prompt themselves. The agent's system prompt is responsible for describing whatever framing this composer emits — there is no runtime check that the framing and the system prompt agree.

compose(String, List) is invoked on the Swing event dispatch thread so implementations may read Swing-owned state directly. Composers that need to defer slow work (Gateway, tag, OPC, or database reads) should capture EDT-visible state synchronously, then return a CompletableFuture that the embedded assistant blocks on from its background task. Composers whose work is cheap return CompletableFuture.completedFuture(Object).

  • Method Details

    • compose

      CompletableFuture<String> compose(String userPrompt, List<ContextReference> references)
      Builds the host-context blocks for one user submission. The framework appends the canonical references block and the user's prompt after whatever this returns.
      Parameters:
      userPrompt - the text the user typed into the prompt box, including any inline reference tokens (e.g. @tag:[default]Tank/Level) that match entries in references. Provided so composers can adapt their context to the request; implementations must not append it to their output — the framework places it.
      references - references the user inserted via the autocomplete popup, each with its body already resolved. Empty when the user inserted no references — or when no PromptAssists were supplied to the session. Provided so composers can load extra context keyed off a reference (e.g. OPC grounding); implementations must not render the references themselves — the framework emits the canonical block.
      Returns:
      a future completing with the host-context blocks, or the empty string when the host has nothing to contribute. Sync composers return CompletableFuture.completedFuture(Object); composers that defer slow reads return a future they complete on a worker thread.