Skip to content

Interface: PostTurnContext

Makaio Framework


Makaio Framework / hooks / PostTurnContext

Defined in: ../../../packages/hooks/src/types/hook-context.ts:179

PostTurn context with turn completion data.

Intercepts: SessionSubjects.turn.completed event

Provides access to turn outcome (success/error) and identifiers. Useful for semantic extraction, analytics, and post-processing.

Extends SessionHookContext for optional session enrichment (session, recentHistory, project) when available.

[key: string]: unknown

readonly bus: IMakaioBus

Defined in: ../../../packages/hooks/src/types/hook-context.ts:76

Bus instance for making requests

SessionHookContext.bus


readonly contextExtensions: Record<string, unknown>

Defined in: ../../../packages/hooks/src/types/hook-context.ts:82

Arbitrary context extensions contributed by the host-registered SessionSubjects.enrichContext handler. Framework spreads these onto the context object at hook-call time. Empty object in OSS mode.

SessionHookContext.contextExtensions


readonly optional correlationId?: string

Defined in: ../../../packages/hooks/src/types/hook-context.ts:194

Correlation identifier for tracing


readonly optional error?: string

Defined in: ../../../packages/hooks/src/types/hook-context.ts:188

Error message if any agent failed


readonly hookEvent: "PostTurn"

Defined in: ../../../packages/hooks/src/types/hook-context.ts:180


readonly messageId: string

Defined in: ../../../packages/hooks/src/types/hook-context.ts:192

Message identifier for correlation


readonly payload: object

Defined in: ../../../packages/hooks/src/types/hook-context.ts:190

Full turn.completed payload for advanced use

optional error?: string

Error message if any agent failed

optional initiator?: object

Origin of the turn (for loop prevention and audit)

source: "user" | "extension" | "system"

Origin category

optional sourceId?: string

Identifier for the specific origin.

Examples: 'routine:validation', 'loop', 'subagent:xyz'.

sessionId: string

Makaio session ID

success: boolean

Whether all agents completed successfully

turnId: string

Turn identifier (UUID)

turnNumber: number

Monotonic per-session ordinal (1-based).


readonly recentHistory: object[]

Defined in: ../../../packages/hooks/src/types/hook-context.ts:74

Recent turn history, oldest first (up to 10 turns)

optional completedAt?: number

Turn completion timestamp (Unix ms)

optional error?: string

Error message if status is ‘error’

sessionId: string

Session this turn belongs to

startedAt: number

Turn start timestamp (Unix ms)

status: "error" | "completed" | "active" = TurnStatusSchema

Turn status

turnId: string

Unique turn identifier

turnNumber: number

Monotonic per-session ordinal (1-based), assigned by turn storage at creation.

optional usage?: object

Aggregated usage/cost for this turn. Populated on turn completion.

optional byAgent?: Record<string, { cost?: number; inputTokens: number; outputTokens: number; }>

Optional per-agent breakdown (for multi-agent turns)

total: object = UsageMetricsSchema

Total aggregated usage across all agents

optional cost?: number

Computed cost in USD (optional, requires pricing data)

inputTokens: number

Input tokens consumed

outputTokens: number

Output tokens generated

SessionHookContext.recentHistory


readonly optional session?: IMakaioSession

Defined in: ../../../packages/hooks/src/types/hook-context.ts:72

Session object (populated when sessionId is available)

SessionHookContext.session


readonly sessionId: string

Defined in: ../../../packages/hooks/src/types/hook-context.ts:182

Session ID where turn completed


readonly success: boolean

Defined in: ../../../packages/hooks/src/types/hook-context.ts:186

Whether all agents completed successfully


readonly turnId: string

Defined in: ../../../packages/hooks/src/types/hook-context.ts:184

Turn identifier

next(): Promise<void>

Defined in: ../../../packages/hooks/src/types/hook-context.ts:198

Continue to the next interceptor in the chain.

Promise<void>


stopPropagation(): void

Defined in: ../../../packages/hooks/src/types/hook-context.ts:203

Stop propagation of this event. Subsequent interceptors and handlers will NOT be called.

void