Optionalprovider: IMetadataProviderProtectedCheckChecks whether the serialized content for a new artifact version is identical to the latest existing version of the same artifact, using SHA-256 content hashing.
When the content is unchanged, creating a new version adds noise without value.
This method computes the hash of the candidate content and compares it against
the ContentHash stored on the most recent version (populated by
MJArtifactVersionEntityServer.Save()).
The artifact whose latest version to compare against
The serialized (JSON-stringified) content that would become the new version
The version number of the current latest version
User context for the RunView query
Optionalprovider: IMetadataProviderThe existing version's ID if content is identical, or null if a new version should be created
Creates MJ: Artifact + MJ: Artifact Version + MJ: Conversation Detail Artifact
junction records for agent-produced media outputs (images, audio, video).
Replaces the deprecated CreateConversationMediaAttachments path which wrote to
the MJ: Conversation Detail Attachments table (then auto-paired to an artifact
via the server-side hook). Writing artifacts directly removes the deprecated-entity
dependency and the redundant dual-write.
Reuses createArtifactWithVersion — the same helper that ProcessFileArtifacts
uses — so artifact creation logic (MIME resolution, transaction wrapping, junction
linking) lives in exactly one place.
The conversation detail to link artifacts to
Media outputs to persist as artifacts
User context for DB operations
Optionalprovider: IMetadataProviderOptional metadata provider for multi-provider support
Finds the most recent artifact for a conversation detail to determine versioning. Queries the junction table to locate artifacts linked to a specific conversation message.
The conversation detail ID to query
The user context for the query
Optionalprovider: IMetadataProviderArtifact info if exists, null if this is the first artifact for this message
Gets the maximum version number for an artifact. Used when creating new versions of explicitly specified artifacts.
The artifact ID to query
The user context for the query
Optionalprovider: IMetadataProviderThe maximum version number, or 0 if no versions exist
ProtectedLinkCreates a ConversationDetailArtifact junction record linking an artifact version
to a conversation detail, then returns the standard artifact result tuple.
Extracted as a helper so both the normal version-creation path and the duplicate-skip path can share the same linking and return logic.
The artifact version ID to link
The conversation detail to link to
The parent artifact ID (passed through to the return value)
The version number (passed through to the return value)
User context for the save operation
Metadata provider for entity creation
The standard artifact result tuple
Processes agent completion to create artifacts from the agent's payload. Handles artifact creation, versioning, and linking to conversation details.
This method implements intelligent artifact versioning:
Respects the agent's ArtifactCreationMode configuration:
The result from agent execution containing the payload
The conversation detail to link the artifact to. May be
undefined for runs executed OUTSIDE a conversation context (e.g. realtime voice
delegations): the artifact + version are still created, but the previous-artifact lookup
and the ConversationDetailArtifact junction link are skipped.
Optional explicit artifact to version from (agent continuity)
The user context for the operation
Optionalprovider: IMetadataProviderArtifact metadata if created, undefined if skipped or failed
Creates MJ: Artifact records for file outputs collected during agent execution.
Reads directly from ExecuteAgentResult.fileOutputs — no DB query needed.
Called automatically by RunAgentInConversation after the agent completes.
File outputs collected by BaseAgent during action execution
The conversation detail to link artifacts to
User context for DB operations
OptionalresolvedStorageAccountId: stringPre-resolved FileStorageAccount ID from the agent's hierarchical resolution chain (Runtime → Agent → Category → Type → fallback). When provided, uploads use this specific account instead of picking the first active one.
Optionalprovider: IMetadataProviderOptionalacceptUnregisteredFiles: booleanRuns an AI agent with the specified parameters.
This method acts as a thin pass-through that:
The type of the agent's context as provided in the ExecuteAgentParams
The type of the agent's result as returned in ExecuteAgentResult
Parameters for agent execution (same as BaseAgent.Execute)
The execution result (same as BaseAgent.Execute)
Runs an AI agent within a conversation context, handling conversation and artifact management.
This method provides a complete workflow for running agents in conversations:
Core agent execution parameters
Conversation-specific options
OptionalconversationDetailId?: stringOptional existing conversation detail ID. If provided, skips conversation/detail creation
OptionalconversationId?: stringOptional existing conversation ID. If not provided, a new conversation will be created
OptionalconversationName?: stringOptional conversation name (only used when creating new conversation)
OptionalcreateArtifacts?: booleanWhether to create artifacts from the agent's payload (default: true)
OptionalsourceArtifactId?: stringOptional source artifact ID for versioning (agent continuity/refinement)
OptionaltestRunId?: stringOptional test run ID to link conversation and details to (for test execution traceability)
OptionaluserMessage?: stringThe user's message text for this conversation turn (required if conversationDetailId not provided)
Promise containing the agent execution result and conversation/artifact metadata
const runner = new AgentRunner();
const result = await runner.RunAgentInConversation({
agent: myAgent,
conversationMessages: messages,
contextUser: currentUser
}, {
conversationId: existingConvoId, // Optional - creates new if not provided
userMessage: 'User query text',
createArtifacts: true
});
Saves media outputs to AIAgentRunMedia table for permanent storage. Creates a record for each media output promoted during agent execution. All items in the array are saved.
The ID of the agent run
Array of media outputs to save
User context for the operation
Optionalprovider: IMetadataProviderArray of saved AIAgentRunMedia IDs
AgentRunner provides a thin wrapper for executing AI agents.
This class handles:
AgentRunner
Example