Skip to content

AutonomousTurnHook

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/libs/agent-core/src/autonomous/autonomous-loop.ts

TurnHook that drives autonomous agent behavior.

It watches what the agent is doing (via tool calls in input items) and injects nudges when the agent skips investigation or verification.

Usage:

typescript
const hook = new AutonomousTurnHook({
  maxTurns: 40,
  qualityGateProvider: async () => [
    { id: 'tests_pass', description: 'All tests pass', passed: false },
  ],
});

Implements: TurnHook

Methods

MethodSignatureReturns
updateTokenUsageupdateTokenUsage(inputTokens: number)void
getCircleDetectorgetCircleDetector()`CircleDetector
beforeModelCallbeforeModelCall(args: TurnHookArgs<TContext>)Promise<{ instructions?: string; input?: AgentInputItem[] }>
getStategetState()Readonly<LoopState>
getRecentFilesgetRecentFiles()readonly string[]

Properties

PropertyType
onPreCompact(data: { turnNumber: number; tokenCount: number; recentFiles: string[] }) => void
onPostCompact(data: { turnNumber: number; summaryInjected: boolean }) => void

Where it refuses work

  • AutonomousTurnHook stops the work with an early return when nudges.length === 0 && !notesBlock && !windowedInput && !phaseDirective.

When something fails

  • AutonomousTurnHook handles failure in 8 places: it discards it silently in 7, and logs it and continues in 1.

Was this page helpful?

Download as PDF