Single Agent

An agent is a loop. It calls tools, reads what comes back, and decides what to do next until the work is done or it hits maxTurns. This is the type to reach for when a job needs to look things up or do things rather than just answer.

Options#

Beyond the shared options:

OptionTypeDefaultNotes
instructionsstring-Task-level guidance, alongside systemPrompt
maxTurnsnumber-Cap on loop iterations
permissionMode'auto' | 'bypass' | 'default' | 'plan'autoHow tool permissions are resolved
deadlineMsnumbernoneExecution deadline; runs are unbounded by default
contextWindownumber250000Working context size
toolsreadonly AgentTool[]-Handlers that run in your process
toolAllowlistreadonly string[]derivedSee Tools
maxToolsnumber-Cap on tools exposed to the model
skillsreadonly AgentSkill[]-See Skills
mcpServersreadonly AgentMcpServer[]-See MCP
imageModelstring-Enables image understanding
outputsreadonly (AgentOutput | string)[]-Files to produce
maxOutputInlineBytesnumber262144Limit for output content projected inline into the result

A worker agent#

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

const worker = createAgent({
  type: 'agent',
  systemPrompt: 'You maintain the billing service.',
  instructions: 'Prefer the smallest change that fixes the issue.',
  model: 'deepseek/deepseek-v4-flash',
  maxTurns: 24,
  deadlineMs: 10 * 60 * 1000,
  outputs: ['patch.diff']
});

const result = await worker.run('Fix the currency rounding bug in refunds.');
console.log(result.status, result.text);

await worker.close();

systemPrompt versus instructions#

Both reach the model, and the distinction is worth keeping:

  • systemPrompt is who the agent is. Its role, its standards, what it always does. It is the same across every run of this definition.
  • instructions is task-level guidance layered on top. Use it for the policy that applies to this deployment rather than to the agent's identity.

If you only use one, use systemPrompt.

Bounding the loop#

Two independent options can bound a run:

maxTurns caps loop iterations. Set it according to the number of tool-use and reasoning cycles your task permits.

deadlineMs sets an execution deadline. Runs have no deadline by default. A run that reaches the configured deadline can end as expired.

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

const responder = createAgent({
  type: 'agent',
  systemPrompt: 'Answer support questions from the knowledge base.',
  // A person is waiting. Fail fast rather than run long.
  maxTurns: 6,
  deadlineMs: 30_000
});

const result = await responder.run('Does the Pro plan include SSO?');
console.log(result.status);

await responder.close();

Your tool handlers see the deadline too, as context.deadlineAt. See writing custom tools.