One shot

One model response, returned directly. There is no managed runtime and no run polling. run() makes one request to the API gateway and hands back what the model said.

Reach for one-shot when the job needs the model's judgement once and nothing else: summarising a document, extracting fields from unstructured text, rewriting a passage, or answering a bounded question.

Options#

Beyond the shared options every type accepts:

OptionTypeNotes
temperaturenumberSampling temperature
stopstring | readonly string[]Stop sequences

Extracting structured fields#

TypeScript
import { createAgent } from '@coresourceai/sdk';

const extractor = createAgent({
  type: 'one-shot',
  systemPrompt:
    'Extract the vendor, invoice number, and total from the supplied text. ' +
    'Reply with JSON only. Use null for anything absent.',
  model: 'deepseek/deepseek-v4-flash',
  temperature: 0
});

const result = await extractor.run(
  'Invoice INV-4417 from Acme GmbH, total EUR 82,400, due 30 September.'
);

console.log(JSON.parse(result.text));

await extractor.close();

temperature: 0 reduces sampling variability, but it does not guarantee identical output across requests. Validate and parse model output before sending it to a downstream system.

What one-shot agents do not have#

A One shot agent exposes run() and close(). They do not have:

  • start(). There is no durable run to hold a handle to, so there is nothing to stream or cancel.
  • registerRuntimeTools() or registerMcpServer(). One-shot agents are tool-free by design.

Reach for Single Agent when you need any of that.