fabric/graph/llm

One structured LLM decision as a policy-gated graph activity. llm_wire owns the request; Fabric retains the receipt and its route. Tool rounds belong to a managed agent, not this single-request binding.

Types

What one decision sends: the application’s started HTTP Gun client, the llm_wire configuration and a plain request. Build one with call.

pub opaque type Call
pub type Outcome(output) {
  Answer(value: output, raw_json: String)
  Refusal(reason: String)
  OutputLimited(partial_text: String)
}

Constructors

  • Answer(value: output, raw_json: String)

    Both the validated application value and the provider’s original JSON.

  • Refusal(reason: String)

    The model declined (llm_wire.Refused), or the provider’s content filter blocked the prompt or stopped the output (error.ContentFiltered); a filter’s reason is error.describe’s line, such as "Provider content filter blocked the prompt: SAFETY".

  • OutputLimited(partial_text: String)
pub type Receipt(output) {
  Receipt(
    model: String,
    outcome: Outcome(output),
    usage: option.Option(message.Usage),
  )
}

Constructors

  • Receipt(
      model: String,
      outcome: Outcome(output),
      usage: option.Option(message.Usage),
    )

    model is the requested model, not a resolved provider revision. Missing usage is not zero usage.

Values

pub fn call(
  client client: http_gun.Client,
  config config: llm_wire.Config,
  request request: llm_wire.Request(String),
) -> Call

A decision’s call: request sent through client with config. Fabric adds the structured output and the run’s correlation (http_gun.with_correlation); it neither starts nor stops the client.

pub fn decision(
  identity: run.DefinitionId,
  input input: codec.Codec(input),
  output output: codec.Codec(output),
  name name: String,
  call call: fn(context, input) -> Call,
) -> @internal Operation(
  context,
  input,
  Receipt(output),
  operation.Kind,
  operation.Recovery,
  operation.Invocation,
  operation.Error,
)

One structured decision as the graph activity identity: call builds the request for each admitted input, and the provider’s answer, decoded with output, becomes the receipt. name names the structured output for the provider. Version identity when the provider, prompt or output meaning changes. call runs only after policy admission. Credentials and the client belong in fresh context, never in the persisted input or receipt.

Requests must have no tools. Preparation and proven unsent failures are definite (tool.Explain); potentially sent failures require reconciliation (tool.Uncertain). A provider’s content filter is a Refusal receipt, not a failure. No implicit retry is made, even when llm_wire reports a transient error.

pub fn receipt_codec(
  output: codec.Codec(output),
) -> codec.Codec(Receipt(output))

A versioned durable receipt, independent of the provider’s output schema. Native answers must agree with the original JSON. Restoration decodes that JSON with the deployed output codec; it never contacts the provider.

A receipt is written as the fabric.graph.llm.v2 object {"format", "model", "outcome", "usage"}. A fabric.graph.llm.v1 receipt, the nested array an earlier release wrote, still decodes.

✨ Search Document