Class QueryBrowserPromptComposer
- All Implemented Interfaces:
PromptComposer
QueryBrowserAgent; the framework appends the canonical references block and the user's prompt
after them. Wire format (the agent's system prompt mirrors this — keep them in lockstep):
<database> name: my_postgres_db vendor: POSTGRES </database> <datasources> <datasource> name=datasource_name <datasource> </datasources> <queryType>AutoDetect | Select | Update</queryType> <rowLimit>1000</rowLimit> <query> SELECT ... </query> <selection>column_a</selection> (the user's actual prompt)
The <database> block is omitted when no datasource is selected — the agent's system
prompt tells it to ask the user to pick a connection rather than guess. The vendor: line
is omitted when the vendor cache has not resolved the datasource yet; the agent falls back to
portable ANSI SQL in that case.
The <rowLimit> block is informational: the runtime appends the limit clause itself, so
the agent should not duplicate it in its suggestions. The block exists so the agent can caveat
suggestions when a more selective WHERE would help.
The <datasources> list block is omitted when no datasources are available on the
gateway. This gives the agent context about the datasources outside the one selected on the
dropdown.
The <rowLimit> block is informational: the runtime appends the limit clause itself, so
the agent should not duplicate it in its suggestions. The block exists so the agent can caveat
suggestions when a more selective WHERE would help.
When the editor is showing the "no default datasource" warning string the <query>
block is dropped so we don't leak the i18n warning to the agent as if it were SQL.
When the editor is showing the "no default datasource" warning string the <query>
block is dropped so we don't leak the i18n warning to the agent as if it were SQL.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncompose(String userPrompt, List<ContextReference> references) Builds the host-context blocks for one user submission.
-
Constructor Details
-
QueryBrowserPromptComposer
- Parameters:
snapshotSupplier- returns the panel's live state on eachcompose(String, List)call. Must snapshot inside the supplier per the embed guide's "state must be snapshotted inside the composer" rule — retries replay the supplier and need fresh state.
-
-
Method Details
-
compose
Description copied from interface:PromptComposerBuilds the host-context blocks for one user submission. The framework appends the canonical references block and the user's prompt after whatever this returns.- Specified by:
composein interfacePromptComposer- 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 inreferences. 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 noPromptAssists 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.
-