Skip to content

Class: AgentRuntimeMutationManager

Makaio Framework


Makaio Framework / ai-adapters-core / AgentRuntimeMutationManager

Defined in: ../../../adapters/core/src/agent/agent-runtime-mutation-manager.ts:76

Handles runtime mutation requests for AIAgent (cwd/model/credential changes).

new AgentRuntimeMutationManager(config): AgentRuntimeMutationManager

Defined in: ../../../adapters/core/src/agent/agent-runtime-mutation-manager.ts:92

AgentRuntimeMutationManagerConfig

AgentRuntimeMutationManager

handleCredentialChanged(payload): Promise<{ success: true; swapped: true; } | { reason: string; success: false; }>

Defined in: ../../../adapters/core/src/agent/agent-runtime-mutation-manager.ts:479

Handle a credential rotation request.

When a turn is active, returns { success: false, reason: 'turn_active' }. Otherwise:

  1. Rebuilds provider context from storage (validates providerConfigId)
  2. Fires credential.activate so extensions prepare native stores
  3. Swaps the connector with updated providerContext (forces re-resolution)

Credential change request payload

string = ...

Adapter instance identifier (required)

string = ...

Adapter type name (e.g., ‘claude-code’) (required)

string = ...

Provider’s native session ID is optional for persisted agents during credential fan-out.

string = ...

Unique agent identifier (required)

number = CredentialChangeSequenceSchema

Monotonic per-provider-config change token used to reject stale fan-out.

string = ...

Client identifier for the owning application/runtime when known.

Record<string, string> = ...

Updated credential references to resolve.

string = ...

Provider definition ID (e.g., 'anthropic').

string = ...

User message ID being processed (for correlation with user_message lifecycle events)

number = ...

Event occurrence timestamp in epoch milliseconds when known.

string = ...

Provider config UUID whose credentials changed.

string = ...

Makaio session ID (NOT provider’s native session ID)

string = ...

Turn ID from the session orchestrator. Optional for backward compatibility.

Promise<{ success: true; swapped: true; } | { reason: string; success: false; }>

Success/failure result


handleCwdChange(payload): Promise<{ previousCwd?: string; reason?: string; success: boolean; }>

Defined in: ../../../adapters/core/src/agent/agent-runtime-mutation-manager.ts:111

Handle agent.cwd.change request.

CWD change request payload

string = ...

Adapter instance identifier (required)

string = ...

Adapter type name (e.g., ‘claude-code’) (required)

string = ...

Provider’s native session ID (e.g., Claude conversation ID)

string = ...

Unique agent identifier (required)

string = ...

Client identifier for the owning application/runtime when known.

string = ...

User message ID being processed (for correlation with user_message lifecycle events)

string = ...

New working directory path

number = ...

Event occurrence timestamp in epoch milliseconds when known.

string = ...

Resolved provider configuration identifier when known.

string = ...

Makaio session ID (NOT provider’s native session ID)

boolean = ...

Skip interactive warning dialog for trusted/programmatic callers

string = ...

Turn ID from the session orchestrator. Optional for backward compatibility.

Promise<{ previousCwd?: string; reason?: string; success: boolean; }>

CWD mutation response payload


handleModelChange(payload): Promise<{ appliedReasoningEffort?: "none" | "low" | "medium" | "high" | "extra-high"; model?: string; reason?: string; success: boolean; supportedReasoningLevels?: { extra-high?: string | number; high?: string | number; low?: string | number; medium?: string | number; none?: string | number; }; swapped?: boolean; }>

Defined in: ../../../adapters/core/src/agent/agent-runtime-mutation-manager.ts:154

Handle agent.model.change request.

Implements a four-branch decision tree based on the presence of newModel and reasoningEffort in the request payload:

  • Both present → change model, then apply reasoningEffort (with fallback)
  • Model only → change model, run fallback chain for reasoning
  • Effort only → change reasoning in-place, no model swap logic
  • Neither → no-op (return current state)

Model change request payload

string = ...

Adapter instance identifier (required)

string = ...

Adapter type name (e.g., ‘claude-code’) (required)

string = ...

Provider’s native session ID (e.g., Claude conversation ID)

string = ...

Unique agent identifier (required)

string = ...

Client identifier for the owning application/runtime when known.

string = ...

User message ID being processed (for correlation with user_message lifecycle events)

string = ...

New model identifier. Optional when only changing reasoning effort without switching models.

number = ...

Event occurrence timestamp in epoch milliseconds when known.

string = ...

Resolved provider configuration identifier when known.

{ credentialEnvVars?: Record<string, string>; credentialRefs: Record<string, string>; definitionId: string; endpointOverrides?: { anthropic?: string; openai?: string; }; providerConfigId: string; } = ...

Unresolved provider context (credential refs, not plaintext). Connectors resolve credentials locally via resolveConnectorCredentials().

Record<string, string> = ...

Maps credential keys to environment variable names for subprocess adapters. E.g., { apiKey: 'ANTHROPIC_API_KEY' }.

Record<string, string> = ...

Credential references resolved at the connector layer, not on the bus.

string = ...

Provider definition ID (e.g., 'anthropic', 'alibaba').

{ anthropic?: string; openai?: string; } = ...

Endpoint URL overrides keyed by protocol.

providerContext.endpointOverrides.anthropic?
Section titled “providerContext.endpointOverrides.anthropic?”

string = ...

string = ...

string = ...

Provider config UUID. Links back to the ProviderConfig that produced this context.

"none" | "low" | "medium" | "high" | "extra-high" = ...

Reasoning effort level to apply after the model change.

string = ...

Makaio session ID (NOT provider’s native session ID)

boolean = ...

Skip interactive warning dialog for trusted/programmatic callers

string = ...

Turn ID from the session orchestrator. Optional for backward compatibility.

Promise<{ appliedReasoningEffort?: "none" | "low" | "medium" | "high" | "extra-high"; model?: string; reason?: string; success: boolean; supportedReasoningLevels?: { extra-high?: string | number; high?: string | number; low?: string | number; medium?: string | number; none?: string | number; }; swapped?: boolean; }>

Model mutation response payload