SDKAgent loop

Agent loop

One run of Syntic Code works like this:

  1. The prompt, the system prompt, the memory files and the available tool list are sent to the model.
  2. The model replies with text, or with one or more tool calls.
  3. Each tool call goes through the permission check: deny rules, then ask rules, then the permission mode, then the tool’s own checks.
  4. Allowed calls run. Independent read-only calls in the same turn run in parallel, in batches of up to ten.
  5. Tool results are added to the conversation, and the loop returns to step 1.

The loop ends when the model answers without a tool call, when --max-turns is reached, or when --max-budget-usd is spent.

Context management

The conversation is compacted as it grows. Compaction runs at 80% and again at 95% of the context window, keeping a summary of earlier turns. Compaction is part of the session; see Context window.

When a model reply is cut off by the output limit, the run continues the reply automatically.

Hooks

Hooks run at fixed points: before and after a tool call, when the agent stops, and at session start and end. A hook can allow, deny or add context to a step. See Hooks.

Permission questions from a program

In a stream-json run started with --permission-prompt-tool stdio, step 3 can send the question to the program that drives the run and wait for its answer. See Permissions for programs.