One-turn LLM Query ​
The LLM Query connector asks a model to make exactly one typed application decision. It uses the ordinary provider-backed kind: query path, so pipeline caching and Query capture can replay the returned decision without another inference.
The model never executes a connector operation. A call is inert proposal data. Authorization and dispatch belong to a later TPF step boundary.
application state + release-pinned callable catalogue
↓
LLM Query
↓
call:<tpf.llm.AgentCall>
| askUser:<tpf.llm.AskUser>
| complete:ApplicationResultDefine the decision ​
Reference the connector-owned protocol type from an application-authored union:
version: 3
appName: invoice-agent
basePackage: example.invoice
transport: LOCAL
types:
InvoiceState:
fields:
- [invoiceId, string]
- [amount, decimal]
- [effectScope, string]
- [nextEffectKey, string]
ChargeArguments:
fields:
- [invoiceId, string]
- [amount, decimal]
- [effectKey, string]
InvoiceResult:
fields:
- [status, string]
InvoiceDecision:
variants:
call: <tpf.llm.AgentCall>
askUser: <tpf.llm.AskUser>
complete: InvoiceResultAgentCall contains binding, operation, canonical argumentsJson, and canonical contextJson. The context is inert trusted data selected from the original typed Query input for a later reducer; it is never sent to the chosen Connector. AgentCall has no provider identity, credentials, runtime handle, hidden reasoning, execution ID, or authority to invoke the selected operation.
An output union may also declare handoff: <tpf.llm.HandoffCall>. When present, a selected Command callable produces that distinct payload with the same canonical fields. The model supplies only the declared non-trusted arguments; TPF resolves the pinned binding and operation, injects trusted input fields and validates the whole input. The handoff is inert: a following application step must validate scope and policy and admit a native Command if appropriate. The dynamic invocation catalogue for this decision contains only Query aliases. Without the handoff variant, ordinary AgentCall Command dispatch retains its existing semantics.
AskUser is an inert clarification request with two fields:
prompt: plain text suitable for display after the receiving boundary escapes it;choices: a list of allowed answers, or an empty list for a free-text response.
The type deliberately has no provider metadata, runtime handle, conversation memory, Agent execution ID, approval state, or correlation field. Canonical output validation rejects undeclared fields, and provider observation metadata remains beside the typed Query output rather than entering AskUser. Exclude sensitive application-state paths from model input with modelInputExcludes; display boundaries must continue to treat model-authored prompt and choice text as untrusted plain text.
An askUser result ends the current Query and pipeline handling proceeds like any other typed union branch. A boundary that supports deferred completion may correlate and durably suspend using its ordinary pipeline/interaction identity, then map the submitted answer into application-authored state before a later LLM Query invocation. No model or framework Agent loop remains alive while the user is away. AskUser is clarification only: Command confirmation, approval, idempotency, and effect authority remain on the native Command path.
For a one-turn application completion with no tool selection, use an ordinary non-union output and omit callables. TPF exposes one required complete alternative whose schema is that authored output type. Configuring callables for this mode is rejected.
When trusted input context must accompany a smaller model-authored value, the output may instead be a record envelope and config.completion may name the model-authored field plus input paths to carry:
output: ReviewReady
config:
modelInputExcludes:
- documentId
- invoice
completion:
field: review
documentId: documentId
invoice: invoice
instructions: Analyse the evidence and return InvoiceReview.Here the model schema is only ReviewReady.review; documentId and invoice are copied from the typed Query input after schema validation. The modelInputExcludes list also keeps those paths out of the model-state JSON and prevents excluded payload_ref values from being materialized as media. Every other envelope field must have an explicit mapping, and dotted paths address nested record fields. This projection does not perform another inference or allow model output to overwrite trusted application context.
The same completion projection can target the non-call payload of a union decision. The model authors that payload's selected field, while the connector copies the declared trusted fields from the Query input and materializes the union's complete variant. Tool call variants retain their ordinary typed argument validation. ChatAgent uses this form so a first inference can either reply directly or request one application-bound Query.
Configure the Query ​
The named LLM binding owns model configuration. The Query step owns its instructions and explicitly exposed callable catalogue:
connectors:
model:
provider: llm.query
version: 1
config:
model: qwen3:8b
baseUrl: http://localhost:11434
payments:
provider: acme.payments
version: 1
config:
connection: payments-production
steps:
- name: Decide invoice
kind: query
cardinality: ONE_TO_ONE
input: InvoiceState
output: InvoiceDecision
using: model
operation: decide
operationVersion: 1
config:
instructions: Decide whether to propose the charge or complete the invoice.
structuredOutputSchema: REQUIRED
modelInputExcludes:
- effectScope
- nextEffectKey
callContext:
invoiceId: invoiceId
callables:
charge:
using: payments
operation: charge.create
operationVersion: 1
kind: command
input: ChargeArguments
commandIdGenerator: example.invoice.ChargeCommandIdGenerator
trustedArguments:
effectKey: nextEffectKeyusing and operation select the configured capability. The compiler verifies kind, operationVersion, and input against the selected operation's normalized type contract from Connector metadata; they are never trusted model output. Command callables that can be invoked also declare their ordinary command ID generator and may declare the existing duplicate and command policies. Inside an imported Block those Command choices are forbidden in the package and are injected from the application's blockBindings mapping instead.
modelInputExcludes, callContext, and each callable's trustedArguments resolve typed record paths against the original decision input independently. Trusted targets are top-level callable-input fields omitted from the model tool schema. A model response containing a trusted target is rejected; TPF does not silently overwrite it. Trusted values are merged before the complete callable input is canonically validated.
The compiler emits the canonical v3 catalogue into the release contract. At runtime the connector projects the selected input types and only their transitively reachable definitions into model-safe JSON Schema, then validates returned arguments against the same canonical metadata. Unrelated pipeline types are not exposed to the model. The schema is a projection for the model, not an alternative application schema language. Unknown aliases, missing or extra fields, malformed JSON, and type mismatches become TerminalFailure("invalid-model-decision").
Model aliases are untrusted observations. TPF looks up the exact compiled alias and constructs binding + operation from the catalogue; it never copies a provider or operation identity supplied inside model arguments.
MCP-backed operations use this same path after explicit pinned import. Discovery, import, and callable exposure are separate stages; see Import MCP tools as Connector operations.
structuredOutputSchema defaults to REQUIRED. In required mode an adapter that cannot enforce the supplied decision schemas for the compiled alternatives fails before inference. The LangChain4j adapter uses the selected provider's native JSON Schema response format for a single direct complete alternative; multi-alternative tool selection is not claimed as natively schema-enforced. OPTIONAL is an explicit best-effort mode for prompt-guided tool selection; TPF still validates the single response against the canonical v3 contract. Neither mode performs a hidden repair call or reinference.
Invoke one proposal ​
A following ordinary step dynamically invokes exactly one capability from the named Query step's compiled catalogue:
- name: Invoke proposal
input: <tpf.llm.AgentCall>
output: <tpf.connector.OperationObservation>
operation:
mode: dynamic
from: Decide invoiceThe generated invocation adapter revalidates the proposed binding + operation and canonical arguments before invoking a provider. Query operations use captured Query semantics; Command operations use the existing effect store, idempotency, duplicate, confirmation, ambiguity, and user-action semantics. Dynamic operation selection is binding mechanics, not a new semantic step kind; it neither loops nor updates application state.
OperationObservation is a discriminated union:
resultcarries the bound operation identity, normalized outcome/code, final canonicalargumentsJson, canonicalcontextJson, canonical result type, and canonicalresultJson;emptycarries the same identity, outcome/code, final canonical arguments, and context without inventing a result payload.
QueryOutcome.NotFound becomes an empty observation with outcome not-found, because absence is normally information the next application decision may need. Found and successful Commands become result observations. TemporarilyUnavailable, authentication/authority failures, terminal failures, Command ambiguity, confirmation barriers, and user-action requirements retain their existing Query/Command failure or effect-state semantics; they are not flattened into successful observations.
The application maps the generic observation into its own state in a later Mapper, service, or reducer step. Dynamic invocation never manufactures InvoiceState, EngineeringState, or another application-owned type.
Compose multiple turns with ordinary recursion ​
When a later turn needs earlier dialogue, carry authorised conversation state between steps and select its model-visible entries. A new execution can optionally hydrate accepted turns through an owner-scoped, captured Query. The LLM Query connector retains no transcript between invocations. See ChatAgent for a reusable Block and Conversation context for manual composition, model behaviour and limits.
Agentic behavior does not require a second Agent runtime. Put the one-turn Query, dynamic native operation, and application-authored reducer inside a named v3 pipeline, then route the reducer's state back through an ordinary bounded self-invocation:
State -> LLM Query -> call:<tpf.llm.AgentCall>
-> operation.mode: dynamic -> native Query | Command
-> <tpf.connector.OperationObservation> -> authored reducer
-> State -> pipeline:self
State -> LLM Query -> askUser:<tpf.llm.AskUser>
-> application boundary / general deferred completion
-> authored answer mapping -> State -> later pipeline invocation
State -> LLM Query -> complete:ApplicationResult -> terminalThe model still makes exactly one decision per Query invocation. Returning AskUser ends that invocation; it does not create polling, a child execution, or an Agent-specific suspension ledger. The dynamic adapter invokes at most one release-pinned capability and never chooses whether another turn is needed. The reducer alone interprets the observation and advances application state; the existing recursive pipeline depth limit provides the framework-owned safety bound.
The offline Callable Loop Proof packages the complete topology in a fixture Block. The consuming application supplies only bindings and Command authority. It exercises a Query NotFound observation, a durable Command with a trusted model-invisible argument, typed completion, generated metadata, and a stateless adapter whose response depends only on model-visible AgentState.phase.
After compilation, inspect META-INF/pipeline/pipeline-contract.json for contributed protocol types, the dynamic operation descriptor, and the named recursive binding; order.json for the finite root invocation; and branching.json for the call/askUser/complete routes. The existing connector-bindings.json exposes the release-pinned callable catalogue as generated inspection metadata. Runtime capabilities are resolved from PipelineYamlConfig and the trusted ConnectorProviderManifestCatalog; none of these artifacts introduces an Agent runtime or semantic dispatch step kind.
This composition follows the existing decisions for bounded recursion, Query observation, Command effects, and generated connector boundaries.
For non-agentic retrieval-augmented generation, compose the same LLM Query after an ordinary embedding and vector retrieval flow. Vector search remains an authorized Query capability if that flow is later placed inside the reducer-driven agent loop.
Adapter boundary ​
Add the LangChain4j adapter:
<dependency>
<groupId>org.pipelineframework</groupId>
<artifactId>llm-query-langchain4j-connector</artifactId>
<version>${pipelineframework.version}</version>
</dependency>The original llm.query provider uses Ollama:
connectors:
local-model:
provider: llm.query
version: 1
config:
model: qwen3:8b
baseUrl: http://localhost:11434Ollama runtime tuning is configured through ordinary runtime properties rather than the portable connector binding:
pipeline.llm.langchain4j.ollama.request-timeout=PT30S
pipeline.llm.langchain4j.ollama.thinking=trueThe timeout must be a positive ISO-8601 duration. These properties retain the adapter's prior defaults when omitted. The adapter disables LangChain4j's internal retries so one TPF Query execution cannot silently become multiple model inferences; retry policy remains owned by the pipeline execution.
OpenAI-compatible chat-completion providers use the same portable Query contract and media mapping:
connectors:
hosted-model:
provider: llm.query.openai.compatible
version: 1
config:
model: google/gemini-3.1-flash-lite
baseUrl: https://openrouter.ai/api/v1
connection: hosted-llm-primaryconnection is an opaque logical ConnectionRef, not a credential or account identifier. The application's tenant-aware ConnectionResolver turns it into the typed connection requested by the configured client implementation for each live invocation. The blocking implementation requests an AuthenticatedOpenAiCompatibleConnection backed by a LangChain4j ChatModel; the reactive implementation requests an AuthenticatedOpenAiCompatibleReactiveConnection backed by a StreamingChatModel. Both remain one llm.query.openai.compatible connector and one portable Query contract. API keys, vault paths, Keychain aliases, refresh behavior, and provider security configuration remain entirely behind the host boundary. Each host model factory must preserve all supplied non-secret model settings, including strict JSON Schema for required structured output.
Only non-sensitive adapter tuning is configured as a runtime property:
pipeline.llm.langchain4j.openai-compatible.request-timeout=PT60S
pipeline.llm.langchain4j.openai-compatible.client-implementation=reactiveclient-implementation accepts reactive or blocking and defaults to reactive. A blocking host must set it to blocking explicitly. It is runtime/deployment selection, not pipeline DSL: switching host stacks does not change the connector binding or Query contract.
The connection reference and one host ConnectionResolver are required when an llm.query.openai.compatible binding starts. Tenant context and the typed authenticated connection are required for each live inference. Missing resolution context and non-positive timeouts fail before inference. Captured replay does not resolve the connection again. Applications should pin a model whose provider advertises native JSON Schema support when structuredOutputSchema remains REQUIRED.
The adapter uses LangChain4j's low-level chat/tool-proposal API. It performs one chat call, returns one proposed alias plus arguments, and never installs a tool executor or autonomous Agent loop. When the provider reports token usage, response model, or finish reason, the adapter retains those values as framework-owned Query observation metadata. Input, output, and total token counts are independently optional; TPF neither estimates missing counts nor recomputes the provider total.
Operational connection and provider failures retain safe typed outcomes rather than collapsing everything into llm-query-failed. Authentication failures become AuthenticationRequired, timeouts, rate limits, and provider outages become TemporarilyUnavailable, and rejected requests, unavailable models, exhausted quota, and content filtering become terminal failures with bounded codes. Provider messages, response bodies, and credentials are not copied into those codes or logs. An unclassified adapter failure remains llm-query-failed.
A syntactically or structurally invalid model decision is instead a typed terminal Query outcome, while its completed provider observation remains available for usage telemetry. Query capture records the successful application decision plus optional observation metadata, not prompts, credentials, SDK objects, or hidden reasoning. Observation metadata does not enter the application output type, canonical schema, or capture key. The durable DynamoDB store persists only a SHA-256 input fingerprint, the canonical typed decision, and the optional bounded observation; its 300 KiB event limit requires PayloadReference for larger values.
Live input and output counts produce gen_ai.client.token.usage metric points with {token} units. Captured replay retains historical values on a tpf.query.observation span marked tpf.query.replayed=true, but emits no new usage metric because replay consumes no provider tokens. Telemetry excludes prompts, completions, application payloads, catalogue entries, credentials, execution IDs, and provider response IDs.
See LLM Query token usage for the metric and span contract, and All Settings for the runtime adapter and telemetry switches.
Deliberate limits ​
- No recursive tool loop, Agent runtime, Agent state, memory bag, or Agent execution identity exists.
- No runtime discovery snapshot or dynamic grant subsystem is required for the release-pinned v1 catalogue.
- No MCP or AskUser protocol is included.
argumentsJsonis canonical serialized data for the selected operation input contract, not a general JSON escape hatch.