Search Results for

    Show / Hide Table of Contents

    Class AgentBehaviour

    Agent behaviour callbacks and UnityEvent bridges.

    • Implements listener interfaces for agent, conversation, text, image, and tool events.
    • Exposes UnityEvents so game code and UI can react to agent activity.
    • Converts low-level deltas and tool outputs into high-level Unity events.
    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    AIBehaviour
    AgentBehaviour
    Implements
    IUniTaskQueueEventListener
    IAgentEventListener
    IGenerativeStreamListener
    IUsageEventListener
    IErrorEventListener
    IConversationEventListener
    ITextDeltaListener
    IImageDeltaListener
    IAnnotationDeltaListener
    IToolStatusListener
    IToolOutputListener
    IAgentBehaviour
    Inherited Members
    AIBehaviour.onUsageReceived
    AIBehaviour.onError
    AIBehaviour.LogLevel
    AIBehaviour.IsProcessing
    AIBehaviour.CancelAllRequests()
    AIBehaviour.CancelLastRequest()
    AIBehaviour.OnQueueStarted()
    AIBehaviour.OnQueueCompleted()
    AIBehaviour.OnQueueCanceled()
    AIBehaviour.OnQueueError(Exception)
    AIBehaviour.OnError(Exception)
    AIBehaviour.OnUsageEvent(UsageEvent)
    AIBehaviour.OnErrorEvent(Event<Exception>)
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    MonoBehaviour.CancelInvoke(string)
    MonoBehaviour.IsInvoking(string)
    MonoBehaviour.StartCoroutine(string)
    MonoBehaviour.StartCoroutine(string, object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.destroyCancellationToken
    MonoBehaviour.useGUILayout
    MonoBehaviour.didStart
    MonoBehaviour.didAwake
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, bool)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>(bool)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.GetComponentIndex()
    Component.CompareTag(string)
    Component.CompareTag(TagHandle)
    Component.SendMessageUpwards(string, object, SendMessageOptions)
    Component.SendMessageUpwards(string, object)
    Component.SendMessageUpwards(string)
    Component.SendMessageUpwards(string, SendMessageOptions)
    Component.SendMessage(string, object)
    Component.SendMessage(string)
    Component.SendMessage(string, object, SendMessageOptions)
    Component.SendMessage(string, SendMessageOptions)
    Component.BroadcastMessage(string, object, SendMessageOptions)
    Component.BroadcastMessage(string, object)
    Component.BroadcastMessage(string)
    Component.BroadcastMessage(string, SendMessageOptions)
    Component.transform
    Component.transformHandle
    Component.gameObject
    Component.tag
    Object.GetEntityId()
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.InstantiateAsync<T>(T)
    Object.InstantiateAsync<T>(T, Transform)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int)
    Object.InstantiateAsync<T>(T, int, Transform)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion)
    Object.InstantiateAsync<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>)
    Object.InstantiateAsync<T>(T, int, Transform, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, CancellationToken)
    Object.InstantiateAsync<T>(T, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)
    Object.InstantiateAsync<T>(T, int, ReadOnlySpan<Vector3>, ReadOnlySpan<Quaternion>, InstantiateParameters, CancellationToken)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Scene)
    Object.Instantiate<T>(T, InstantiateParameters)
    Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    Namespace: Glitch9.AIDevKit.Agents
    Assembly: Glitch9.AIDevKit.Agent.dll
    Syntax
    [AddComponentMenu("AI DevKit/AI Agents/Agent", 0)]
    [HelpURL("https://glitch9.gitbook.io/ai-dev-kit/agent/components/agent-behaviour")]
    public sealed class AgentBehaviour : AIBehaviour, IUniTaskQueueEventListener, IAgentEventListener, IGenerativeStreamListener, IUsageEventListener, IErrorEventListener, IConversationEventListener, ITextDeltaListener, IImageDeltaListener, IAnnotationDeltaListener, IToolStatusListener, IToolOutputListener, IAgentBehaviour
    Remarks
    • Attach this component to a UnityEngine.GameObject to integrate AI conversation logic, streaming responses, and tool-calling into a scene.
    • Exposes a simplified, inspector-friendly API on top of the underlying Agent class so that UI, input, and audio components can interact with the agent without depending on low-level networking or provider-specific details.
    • Use the public properties to control the active model, voice, and audio settings at runtime, and the public methods to manage conversations and send messages.

    Fields

    | Edit this page View Source

    onAgentDataSaved

    Agent preferences save event.

    • Invoked after agent preferences are persisted to the configured store.
    • Provides the saved AgentSaveData snapshot.
    Declaration
    [FormerlySerializedAs("onAgentPreferencesSave")]
    public UnityEvent<AgentSaveData> onAgentDataSaved
    Field Value
    Type Description
    UnityEvent<AgentSaveData>
    | Edit this page View Source

    onAgentStatusChanged

    Agent status change event.

    • Invoked whenever the agent status is updated.
    • Provides the new AgentStatus value.
    Declaration
    [FormerlySerializedAs("onStateChanged")]
    [FormerlySerializedAs("onAgentStateChanged")]
    public UnityEvent<AgentStatusChangedEvent> onAgentStatusChanged
    Field Value
    Type Description
    UnityEvent<AgentStatusChangedEvent>
    | Edit this page View Source

    onAnnotation

    Annotation delta event.

    • Invoked when an annotation chunk is received from the AI model.
    • Provides incremental annotation data and a completion flag.
    Declaration
    public UnityStreamEvent<IAnnotationChunk> onAnnotation
    Field Value
    Type Description
    UnityStreamEvent<IAnnotationChunk>
    | Edit this page View Source

    onCodeInterpreterCode

    Declaration
    [Header("Code Interpreter")]
    [Tooltip("Invoked when code text is streamed from the Code Interpreter tool.")]
    public UnityStreamEvent<string> onCodeInterpreterCode
    Field Value
    Type Description
    UnityStreamEvent<string>
    | Edit this page View Source

    onCodeInterpreterOutputImage

    Declaration
    [Tooltip("Invoked when the Code Interpreter tool produces an image output.")]
    public UnityEvent<Texture2D> onCodeInterpreterOutputImage
    Field Value
    Type Description
    UnityEvent<Texture2D>
    | Edit this page View Source

    onCodeInterpreterOutputLogs

    Declaration
    [Tooltip("Invoked when the Code Interpreter tool emits textual log output.")]
    public UnityEvent<string> onCodeInterpreterOutputLogs
    Field Value
    Type Description
    UnityEvent<string>
    | Edit this page View Source

    onConversationCreated

    Conversation created event.

    • Invoked when a new conversation instance is created.
    • Provides the created Conversation.
    Declaration
    public UnityEvent<Conversation> onConversationCreated
    Field Value
    Type Description
    UnityEvent<Conversation>
    | Edit this page View Source

    onConversationDeleted

    Conversation deleted event.

    • Invoked when a conversation delete operation completes.
    • Provides a boolean indicating whether the delete succeeded.
    Declaration
    public UnityEvent<bool> onConversationDeleted
    Field Value
    Type Description
    UnityEvent<bool>
    | Edit this page View Source

    onConversationItemsLoaded

    Conversation items loaded event.

    • Invoked when conversation items are loaded from storage.
    • Provides an array of ConversationItem entries.
    Declaration
    public UnityEvent<ConversationItem[]> onConversationItemsLoaded
    Field Value
    Type Description
    UnityEvent<ConversationItem[]>
    | Edit this page View Source

    onConversationLoaded

    Conversation loaded event.

    • Invoked when a conversation is loaded from storage.
    • Provides the loaded Conversation.
    Declaration
    public UnityEvent<Conversation> onConversationLoaded
    Field Value
    Type Description
    UnityEvent<Conversation>
    | Edit this page View Source

    onConversationSummaryUpdated

    Conversation summary updated event.

    • Invoked when a conversation summary is generated or changed.
    • Provides the new conversation summary as a string.
    Declaration
    public UnityEvent<string> onConversationSummaryUpdated
    Field Value
    Type Description
    UnityEvent<string>
    | Edit this page View Source

    onConversationTitleUpdated

    Conversation title updated event.

    • Invoked when a conversation title is generated or changed.
    • Provides the new conversation title as a string.
    Declaration
    public UnityEvent<string> onConversationTitleUpdated
    Field Value
    Type Description
    UnityEvent<string>
    | Edit this page View Source

    onConversationsLoaded

    Conversation list loaded event.

    • Invoked when multiple conversations are loaded from storage.
    • Provides an array of loaded Conversation objects.
    Declaration
    public UnityEvent<Conversation[]> onConversationsLoaded
    Field Value
    Type Description
    UnityEvent<Conversation[]>
    | Edit this page View Source

    onFileSearchOutput

    Declaration
    [Header("File Search")]
    [Tooltip("Invoked when the File Search tool completes a search operation.")]
    public UnityEvent<FileSearchOutput> onFileSearchOutput
    Field Value
    Type Description
    UnityEvent<FileSearchOutput>
    | Edit this page View Source

    onGeneratedImage

    Declaration
    [Header("Image Generation")]
    [Tooltip("Invoked when an image is generated.")]
    public UnityStreamEvent<Texture2D> onGeneratedImage
    Field Value
    Type Description
    UnityStreamEvent<Texture2D>
    | Edit this page View Source

    onInputTranscript

    Input transcription delta event.

    • Invoked when speech input is transcribed into text.
    • Provides incremental input transcript text and completion flags.
    Declaration
    [FormerlySerializedAs("inputTranscription")]
    [FormerlySerializedAs("onInputTranscription")]
    public UnityStreamEvent<string> onInputTranscript
    Field Value
    Type Description
    UnityStreamEvent<string>
    | Edit this page View Source

    onMcpListToolsOutput

    Declaration
    [Tooltip("Invoked when MCP list tools call produces output.")]
    public UnityEvent<McpListToolsCallOutput> onMcpListToolsOutput
    Field Value
    Type Description
    UnityEvent<McpListToolsCallOutput>
    | Edit this page View Source

    onMcpOutput

    Declaration
    [Header("MCP (Model Context Protocol)")]
    [Tooltip("Invoked when an MCP tool produces output.")]
    public UnityEvent<McpOutput> onMcpOutput
    Field Value
    Type Description
    UnityEvent<McpOutput>
    | Edit this page View Source

    onMessage

    Assistant message delta event.

    • Invoked when assistant output text is streamed or finalized.
    • Provides incremental text fragments and completion flags.
    Declaration
    [FormerlySerializedAs("message")]
    public UnityStreamEvent<string> onMessage
    Field Value
    Type Description
    UnityStreamEvent<string>
    | Edit this page View Source

    onOutputTranscript

    Output transcription delta event.

    • Invoked when assistant output speech is transcribed back to text.
    • Provides incremental output transcript text and completion flags.
    Declaration
    [FormerlySerializedAs("transcript")]
    [FormerlySerializedAs("onTranscript")]
    public UnityStreamEvent<string> onOutputTranscript
    Field Value
    Type Description
    UnityStreamEvent<string>
    | Edit this page View Source

    onReasoning

    Reasoning text delta event.

    • Invoked when reasoning text is streamed, if supported by the model.
    • Provides incremental reasoning content and completion flags.
    Declaration
    [FormerlySerializedAs("reasoning")]
    public UnityStreamEvent<string> onReasoning
    Field Value
    Type Description
    UnityStreamEvent<string>
    | Edit this page View Source

    onReasoningSummary

    Reasoning summary text delta event.

    • Invoked when a concise reasoning summary is streamed or updated.
    • Provides incremental summary text and completion flags.
    Declaration
    [FormerlySerializedAs("reasoningSummary")]
    public UnityStreamEvent<string> onReasoningSummary
    Field Value
    Type Description
    UnityStreamEvent<string>
    | Edit this page View Source

    onRefusal

    Refusal text delta event.

    • Invoked when a refusal message is streamed, if supported.
    • Provides incremental refusal text and completion flags.
    Declaration
    [FormerlySerializedAs("refusal")]
    public UnityStreamEvent<string> onRefusal
    Field Value
    Type Description
    UnityStreamEvent<string>
    | Edit this page View Source

    onToolStatusChanged

    Tool status change event.

    • Invoked whenever any tool status is updated.
    • Provides a ToolStatusEvent containing status details.
    Declaration
    public UnityEvent<ToolStatusEvent> onToolStatusChanged
    Field Value
    Type Description
    UnityEvent<ToolStatusEvent>
    | Edit this page View Source

    onUnhandledToolCall

    Unhandled tool call event.

    • Invoked when a tool call is not handled by any registered tool handler.
    • Provides the original ToolCall instance.
    Declaration
    public UnityEvent<ToolCall> onUnhandledToolCall
    Field Value
    Type Description
    UnityEvent<ToolCall>
    | Edit this page View Source

    onWebSearchOutput

    Declaration
    [Header("Web Search")]
    [Tooltip("Invoked when the Web Search tool completes a search operation.")]
    public UnityEvent<WebSearchOutput> onWebSearchOutput
    Field Value
    Type Description
    UnityEvent<WebSearchOutput>

    Properties

    | Edit this page View Source

    Agent

    Underlying runtime Agent instance used by this behaviour.

    Declaration
    public Agent Agent { get; }
    Property Value
    Type Description
    Agent
    Remarks

    This is created and managed internally by AgentBehaviour and should not be replaced at runtime. Use the public methods and properties on AgentBehaviour instead of invoking methods directly on the Agent.

    | Edit this page View Source

    AgentName

    Human-readable name of the agent.

    Declaration
    public string AgentName { get; }
    Property Value
    Type Description
    string
    Remarks

    This name is usually surfaced in UI elements (such as headers or labels) to indicate which agent the user is currently interacting with.

    | Edit this page View Source

    Api

    API provider inferred from the selected Model.

    Declaration
    public override sealed Api Api { get; }
    Property Value
    Type Description
    Api
    Overrides
    AIBehaviour.Api
    Remarks

    This value is derived from Model using Model.SafeGetApi() and is used by the internal request pipeline to select the correct adapter for the current provider.

    | Edit this page View Source

    AutoInit

    Gets whether the agent should automatically initialize when instantiated.

    Declaration
    public bool AutoInit { get; }
    Property Value
    Type Description
    bool
    Remarks

    If true, the agent will load conversation history, register tools, and prepare for interaction immediately. If false, you must manually call initialization methods before using the agent.

    | Edit this page View Source

    Conversation

    Currently active conversation for this agent.

    Declaration
    public Conversation Conversation { get; }
    Property Value
    Type Description
    Conversation
    Remarks

    The conversation encapsulates all items (messages, tool calls, and other events) that form the context for the agent's responses.

    | Edit this page View Source

    ConversationSettings

    Declaration
    public IMemorySettings ConversationSettings { get; }
    Property Value
    Type Description
    IMemorySettings
    | Edit this page View Source

    HasInputAudio

    Indicates whether this agent accepts audio input.

    Declaration
    public bool HasInputAudio { get; }
    Property Value
    Type Description
    bool
    Remarks

    This flag is used by UI components to show or hide audio-recording controls.

    | Edit this page View Source

    HasOutputAudio

    Indicates whether this agent can output audio (TTS).

    Declaration
    public bool HasOutputAudio { get; }
    Property Value
    Type Description
    bool
    Remarks

    This flag is used by UI components to show or hide speaker or playback controls.

    | Edit this page View Source

    HasOutputImage

    Indicates whether this agent can output images.

    Declaration
    public bool HasOutputImage { get; }
    Property Value
    Type Description
    bool
    Remarks

    When enabled and supported by the current model, image outputs may be attached to responses and consumed by UI components.

    | Edit this page View Source

    Id

    Unique agent identifier.

    Declaration
    public string Id { get; }
    Property Value
    Type Description
    string
    Remarks

    This is typically assigned from the associated AgentProfile and can be used to distinguish different agents when saving or loading data.

    | Edit this page View Source

    InitialConversationIdOverride

    Gets the conversation configuration settings for this agent, including context management, title generation, summarization, and RAG settings.

    Declaration
    public string InitialConversationIdOverride { get; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    InputAudioLanguage

    Preferred spoken language for audio input and transcription.

    Declaration
    public SystemLanguage InputAudioLanguage { get; set; }
    Property Value
    Type Description
    SystemLanguage
    Remarks

    Defaults to UnityEngine.Application.systemLanguage when not explicitly set. This value is used as a hint to the transcription and speech systems and may impact recognition accuracy and voice selection.

    | Edit this page View Source

    InputAudioRecorder

    Recorder component used to capture audio input for transcription, if assigned.

    Declaration
    public SpeechToTextRecorder InputAudioRecorder { get; }
    Property Value
    Type Description
    SpeechToTextRecorder
    | Edit this page View Source

    Instructions

    System-level instructions currently applied to this agent. If you set this property, it will override the instructions from settings for the current session. Setting this property will not modify the AgentSettings (ScriptableObject) asset.

    Declaration
    public string Instructions { get; set; }
    Property Value
    Type Description
    string
    Remarks

    These instructions are typically derived from AgentProfile and can be updated at runtime via the underlying Agent.

    | Edit this page View Source

    IsInitialized

    Indicates whether the underlying Agent has completed initialization.

    Declaration
    public bool IsInitialized { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    IsRecording

    Indicates whether the input audio recorder is currently capturing audio.

    Declaration
    public bool IsRecording { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    IsStreaming

    Declaration
    public bool IsStreaming { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    Items

    All items contained in the current Conversation.

    Declaration
    public List<ConversationItem> Items { get; }
    Property Value
    Type Description
    List<ConversationItem>
    Remarks
    • Items include chat messages, tool calls, tool outputs, and other domain events.
    • Use this list when you need the full, low-level event history rather than only user and assistant messages.
    | Edit this page View Source

    LastMessage

    Last message in the current conversation, if any.

    Declaration
    public Message LastMessage { get; }
    Property Value
    Type Description
    Message
    Remarks

    This is useful for quickly retrieving the most recent reply from the agent or the last user input without scanning the full history.

    | Edit this page View Source

    Messages

    User and assistant messages in the current conversation.

    Declaration
    public List<Message> Messages { get; }
    Property Value
    Type Description
    List<Message>
    Remarks

    This is a filtered view of Items that only includes message-type entries (system, user, assistant, and tool messages).

    | Edit this page View Source

    Microphone

    Name of the microphone device used for audio input.

    Declaration
    public string Microphone { get; set; }
    Property Value
    Type Description
    string
    Remarks

    This property proxies Microphone if an InputAudioRecorder is assigned; otherwise, it returns null.

    | Edit this page View Source

    Model

    Active generative model used for this agent.

    Declaration
    public Model Model { get; set; }
    Property Value
    Type Description
    Model
    Remarks
    • When saveData is enabled, the chosen model is persisted per agent and restored on the next session.
    • Changing this property at runtime will affect all subsequent requests but will not retroactively modify existing conversation items.
    | Edit this page View Source

    Name

    Declaration
    [Obsolete("Use AgentName property instead.")]
    public string Name { get; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    OutputAudioPlayer

    Player component used to output synthesized speech, if assigned.

    Declaration
    public TextToSpeechPlayer OutputAudioPlayer { get; }
    Property Value
    Type Description
    TextToSpeechPlayer
    | Edit this page View Source

    OutputAudioVolume

    Master volume for speech output.

    Declaration
    public float OutputAudioVolume { get; set; }
    Property Value
    Type Description
    float
    Remarks

    Valid range is 0.0 (muted) to 1.0 (full volume). Values outside this range are clamped by the underlying implementation.

    | Edit this page View Source

    SpeechOutputVolume

    Declaration
    [Obsolete("Use SpeechVolume instead.")]
    public float SpeechOutputVolume { get; set; }
    Property Value
    Type Description
    float
    | Edit this page View Source

    SpokenLanguage

    Declaration
    [Obsolete("Use InputVoiceLanguage instead.")]
    public SystemLanguage SpokenLanguage { get; set; }
    Property Value
    Type Description
    SystemLanguage
    | Edit this page View Source

    State

    Declaration
    [Obsolete("Use Status instead.")]
    public AgentStatus State { get; }
    Property Value
    Type Description
    AgentStatus
    | Edit this page View Source

    Status

    Current lifecycle state of the agent.

    Declaration
    public AgentStatus Status { get; }
    Property Value
    Type Description
    AgentStatus
    Remarks
    • None: Not initialized.
    • Initializing: Initialization in progress.
    • Ready: Ready to accept input.
    • GeneratingResponse: Handling a request.
    • Terminating: Shutting down.

    When the internal agent is null, None is returned.

    | Edit this page View Source

    Stream

    Declaration
    [Obsolete("Use IsStreaming property instead.")]
    public bool Stream { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    StreamOptions

    Gets the streaming options for real-time response generation.

    Declaration
    public StreamOptions StreamOptions { get; }
    Property Value
    Type Description
    StreamOptions
    Remarks

    Controls which types of streaming events the agent should emit (text, audio, images, annotations, etc.). Enabling only required event types can improve performance.

    | Edit this page View Source

    ToolCallConfig

    Gets the tool calling behavior and timeout settings.

    Declaration
    public ToolCallConfig ToolCallConfig { get; }
    Property Value
    Type Description
    ToolCallConfig
    Remarks

    Defines how the agent handles function/tool calls during interactions, including policies for unhandled tools and approval workflows. See ToolCallConfig for detailed configuration options.

    | Edit this page View Source

    ToolChoice

    Tool selection strategy for this agent.

    Declaration
    public ToolChoice ToolChoice { get; set; }
    Property Value
    Type Description
    ToolChoice
    | Edit this page View Source

    UserName

    Human-readable name of the user interacting with the agent, used in conversation messages.

    Declaration
    public string UserName { get; }
    Property Value
    Type Description
    string
    | Edit this page View Source

    Voice

    Selected TTS voice for audio responses.

    Declaration
    public Voice Voice { get; set; }
    Property Value
    Type Description
    Voice
    Remarks

    This property is optional and only applies when OutputAudioPlayer is present and the current provider supports speech synthesis.

    | Edit this page View Source

    VoiceRecorder

    Declaration
    [Obsolete("Use InputAudioRecorder instead.")]
    public SpeechToTextRecorder VoiceRecorder { get; }
    Property Value
    Type Description
    SpeechToTextRecorder
    | Edit this page View Source

    WriteGenerationRecords

    Gets whether to save request and response records for this agent.

    Declaration
    public bool WriteGenerationRecords { get; }
    Property Value
    Type Description
    bool
    Remarks

    When enabled, all API requests and responses are persisted for:

    • Debugging and troubleshooting
    • Usage analytics and monitoring
    • Compliance and audit trails

      Note: Saving records consumes additional storage and may include sensitive data.
    | Edit this page View Source

    inputTranscription

    Declaration
    [Obsolete("Use onInputTranscription instead.")]
    public UnityStreamEvent<string> inputTranscription { get; }
    Property Value
    Type Description
    UnityStreamEvent<string>
    | Edit this page View Source

    message

    Declaration
    [Obsolete("Use onMessage instead.")]
    public UnityStreamEvent<string> message { get; }
    Property Value
    Type Description
    UnityStreamEvent<string>
    | Edit this page View Source

    onInputTranscription

    Declaration
    [Obsolete("Use onInputTranscript instead.")]
    public UnityStreamEvent<string> onInputTranscription { get; }
    Property Value
    Type Description
    UnityStreamEvent<string>
    | Edit this page View Source

    onReceiveCodeInterpreterOutputImage

    Declaration
    [Obsolete("Use onReceiveCodeInterpreterOutputImage instead.")]
    public UnityEvent<Texture2D> onReceiveCodeInterpreterOutputImage { get; }
    Property Value
    Type Description
    UnityEvent<Texture2D>
    | Edit this page View Source

    onReceiveCodeInterpreterOutputLogs

    Declaration
    [Obsolete("Use onReceiveCodeInterpreterOutputLogs instead.")]
    public UnityEvent<string> onReceiveCodeInterpreterOutputLogs { get; }
    Property Value
    Type Description
    UnityEvent<string>
    | Edit this page View Source

    onReceiveFileSearchOutput

    Declaration
    [Obsolete("Use onFileSearchOutput instead.")]
    public UnityEvent<FileSearchOutput> onReceiveFileSearchOutput { get; }
    Property Value
    Type Description
    UnityEvent<FileSearchOutput>
    | Edit this page View Source

    onReceiveMcpListToolsOutput

    Declaration
    [Obsolete("Use onMcpListToolsOutput instead.")]
    public UnityEvent<McpListToolsCallOutput> onReceiveMcpListToolsOutput { get; }
    Property Value
    Type Description
    UnityEvent<McpListToolsCallOutput>
    | Edit this page View Source

    onReceiveMcpToolOutput

    Declaration
    [Obsolete("Use onMcpToolOutput instead.")]
    public UnityEvent<McpOutput> onReceiveMcpToolOutput { get; }
    Property Value
    Type Description
    UnityEvent<McpOutput>
    | Edit this page View Source

    onReceiveWebSearchOutput

    Declaration
    [Obsolete("Use onWebToolStatusChanged instead.")]
    public UnityEvent<WebSearchOutput> onReceiveWebSearchOutput { get; }
    Property Value
    Type Description
    UnityEvent<WebSearchOutput>
    | Edit this page View Source

    onTranscript

    Declaration
    [Obsolete("Use onOutputTranscript instead.")]
    public UnityStreamEvent<string> onTranscript { get; }
    Property Value
    Type Description
    UnityStreamEvent<string>
    | Edit this page View Source

    reasoning

    Declaration
    [Obsolete("Use onReasoning instead.")]
    public UnityStreamEvent<string> reasoning { get; }
    Property Value
    Type Description
    UnityStreamEvent<string>
    | Edit this page View Source

    reasoningSummary

    Declaration
    [Obsolete("Use onReasoningSummary instead.")]
    public UnityStreamEvent<string> reasoningSummary { get; }
    Property Value
    Type Description
    UnityStreamEvent<string>
    | Edit this page View Source

    refusal

    Declaration
    [Obsolete("Use onRefusal instead.")]
    public UnityStreamEvent<string> refusal { get; }
    Property Value
    Type Description
    UnityStreamEvent<string>
    | Edit this page View Source

    transcript

    Declaration
    [Obsolete("Use onTranscript instead.")]
    public UnityStreamEvent<string> transcript { get; }
    Property Value
    Type Description
    UnityStreamEvent<string>

    Methods

    | Edit this page View Source

    AddAttachments(params IFile[])

    Adds one or more file attachments to the pending input message.

    Declaration
    public void AddAttachments(params IFile[] files)
    Parameters
    Type Name Description
    IFile[] files

    Files to attach.

    Remarks

    This method can be used to attach images, documents, audio clips, or arbitrary files before sending the next user message to the agent.

    | Edit this page View Source

    AddAttachments(IEnumerable<IFile>)

    Adds a collection of files as attachments to the pending input message.

    Declaration
    public void AddAttachments(IEnumerable<IFile> files)
    Parameters
    Type Name Description
    IEnumerable<IFile> files

    Enumerable of files to attach.

    Remarks
    • If there is no pending message, a new UserMessage is created.
    • If the pending message has no content, a new content container is created prior to adding files.

    If files is null or empty, this method does nothing.

    | Edit this page View Source

    AddAttachments(params AudioClip[])

    Adds one or more UnityEngine.AudioClip assets as attachments to the pending input.

    Declaration
    public void AddAttachments(params AudioClip[] audioClips)
    Parameters
    Type Name Description
    AudioClip[] audioClips

    Audio clips to convert to files and attach.

    | Edit this page View Source

    AddAttachments(params TextAsset[])

    Adds one or more UnityEngine.TextAsset documents as attachments to the pending input.

    Declaration
    public void AddAttachments(params TextAsset[] documents)
    Parameters
    Type Name Description
    TextAsset[] documents

    Text assets to convert to files and attach.

    | Edit this page View Source

    AddAttachments(params Texture2D[])

    Adds one or more UnityEngine.Texture2D images as attachments to the pending input.

    Declaration
    public void AddAttachments(params Texture2D[] images)
    Parameters
    Type Name Description
    Texture2D[] images

    Images to convert to files and attach.

    | Edit this page View Source

    Awake()

    Declaration
    protected override void Awake()
    Overrides
    AIBehaviour.Awake()
    | Edit this page View Source

    CreateConversation()

    Creates a new conversation and makes it the active one for this agent.

    Declaration
    public void CreateConversation()
    Remarks

    This is a fire-and-forget convenience wrapper around CreateConversationAsync(CancellationToken).

    | Edit this page View Source

    CreateConversationAsync(CancellationToken)

    Asynchronously creates a new conversation and makes it active.

    Declaration
    public UniTask<Conversation> CreateConversationAsync(CancellationToken ct = default)
    Parameters
    Type Name Description
    CancellationToken ct

    Optional cancellation token.

    Returns
    Type Description
    UniTask<Conversation>

    The newly created Conversation.

    | Edit this page View Source

    EnterChatMessage(Message)

    Declaration
    [Obsolete("Use SendMessage instead.")]
    public void EnterChatMessage(Message request)
    Parameters
    Type Name Description
    Message request
    | Edit this page View Source

    EnterChatText(string)

    Declaration
    [Obsolete("Use SendText instead.")]
    public void EnterChatText(string inputText)
    Parameters
    Type Name Description
    string inputText
    | Edit this page View Source

    InitializeAsync()

    Initializes the underlying Agent, conversation controller, and tools.

    Declaration
    public override UniTask InitializeAsync()
    Returns
    Type Description
    UniTask

    A Cysharp.Threading.Tasks.UniTask that completes once initialization is finished.

    Overrides
    AIBehaviour.InitializeAsync()
    Remarks
    • Subscribe to the agent events (for example, streaming updates or unhandled tool calls) before calling this method.
    • If the behaviour is terminating or the agent has already left the None state, this call is ignored.
    | Edit this page View Source

    ListConversationsAsync(CancellationToken)

    Lists all conversations associated with this agent.

    Declaration
    public UniTask<Conversation[]> ListConversationsAsync(CancellationToken ct = default)
    Parameters
    Type Name Description
    CancellationToken ct

    Optional cancellation token.

    Returns
    Type Description
    UniTask<Conversation[]>

    An array of Conversation objects.

    | Edit this page View Source

    LoadConversation(string, bool)

    Loads an existing conversation by its identifier and makes it active.

    Declaration
    public void LoadConversation(string conversationId, bool createIfNotFound = true)
    Parameters
    Type Name Description
    string conversationId

    Identifier of the conversation to load.

    bool createIfNotFound

    If true, a new conversation is created when the requested one does not exist.

    Remarks

    This is a fire-and-forget convenience wrapper around LoadConversationAsync(string, bool, CancellationToken).

    | Edit this page View Source

    LoadConversationAsync(string, bool, CancellationToken)

    Asynchronously loads a conversation by its identifier and makes it active.

    Declaration
    public UniTask<Conversation> LoadConversationAsync(string conversationId, bool createIfNotFound = true, CancellationToken ct = default)
    Parameters
    Type Name Description
    string conversationId

    Identifier of the conversation to load.

    bool createIfNotFound

    If true, a new conversation is created when the requested one does not exist.

    CancellationToken ct

    Optional cancellation token.

    Returns
    Type Description
    UniTask<Conversation>

    The loaded or newly created Conversation.

    | Edit this page View Source

    OnAgentDataSaved(AgentSaveData)

    Called when agent data has been successfully saved.

    Declaration
    public void OnAgentDataSaved(AgentSaveData prefs)
    Parameters
    Type Name Description
    AgentSaveData prefs
    | Edit this page View Source

    OnAgentStatusChanged(AgentStatusChangedEvent)

    Called when the agent's status changes (e.g., from Idle to Processing).

    Declaration
    public void OnAgentStatusChanged(AgentStatusChangedEvent evt)
    Parameters
    Type Name Description
    AgentStatusChangedEvent evt
    | Edit this page View Source

    OnAnnotationDelta(Delta<IAnnotationChunk>)

    Declaration
    public void OnAnnotationDelta(Delta<IAnnotationChunk> e)
    Parameters
    Type Name Description
    Delta<IAnnotationChunk> e
    | Edit this page View Source

    OnConversationEvent(ConversationEvent)

    Declaration
    public void OnConversationEvent(ConversationEvent evt)
    Parameters
    Type Name Description
    ConversationEvent evt
    | Edit this page View Source

    OnDestroy()

    Declaration
    protected override void OnDestroy()
    Overrides
    AIBehaviour.OnDestroy()
    | Edit this page View Source

    OnImageDelta(Delta<IImageChunk>)

    Declaration
    public void OnImageDelta(Delta<IImageChunk> e)
    Parameters
    Type Name Description
    Delta<IImageChunk> e
    | Edit this page View Source

    OnTextDelta(Delta<ITextChunk>)

    Declaration
    public void OnTextDelta(Delta<ITextChunk> e)
    Parameters
    Type Name Description
    Delta<ITextChunk> e
    | Edit this page View Source

    OnToolOutput(ToolOutputEvent)

    Declaration
    public void OnToolOutput(ToolOutputEvent e)
    Parameters
    Type Name Description
    ToolOutputEvent e
    | Edit this page View Source

    OnToolStatus(ToolStatusEvent)

    Declaration
    public void OnToolStatus(ToolStatusEvent e)
    Parameters
    Type Name Description
    ToolStatusEvent e
    | Edit this page View Source

    RegisterCallback<T>(Action<T>)

    Registers an event handler for agent events.

    Declaration
    public IDisposable RegisterCallback<T>(Action<T> handler) where T : IEvent
    Parameters
    Type Name Description
    Action<T> handler

    The event handler callback

    Returns
    Type Description
    IDisposable
    Type Parameters
    Name Description
    T

    The event payload type

    | Edit this page View Source

    RegisterEvent<T>(Action<T>)

    Declaration
    [Obsolete("Use RegisterCallback<T> method instead.")]
    public void RegisterEvent<T>(Action<T> handler) where T : IEvent
    Parameters
    Type Name Description
    Action<T> handler
    Type Parameters
    Name Description
    T
    | Edit this page View Source

    RegisterMcpApprovalHandler(string, IMcpApprovalHandler)

    Registers an MCP approval handler for a given server label.

    Declaration
    public void RegisterMcpApprovalHandler(string serverLabel, IMcpApprovalHandler handler)
    Parameters
    Type Name Description
    string serverLabel

    Logical label of the MCP server.

    IMcpApprovalHandler handler

    Handler responsible for approving or rejecting MCP tool calls.

    | Edit this page View Source

    RegisterOAuthTokenProvider(string, IOAuthTokenProvider)

    Registers an OAuth token provider for a given server label.

    Declaration
    public void RegisterOAuthTokenProvider(string serverLabel, IOAuthTokenProvider provider)
    Parameters
    Type Name Description
    string serverLabel

    Logical label of the OAuth server (for example, "google" or "microsoft").

    IOAuthTokenProvider provider

    Provider instance that can supply and refresh OAuth tokens.

    | Edit this page View Source

    RegisterToolExecutor<TCall, TOutput>(IToolCallExecutor<TCall, TOutput>)

    Registers a tool call executor for a specific tool call and output type.

    Declaration
    public void RegisterToolExecutor<TCall, TOutput>(IToolCallExecutor<TCall, TOutput> executor) where TCall : ToolCall where TOutput : ToolOutput
    Parameters
    Type Name Description
    IToolCallExecutor<TCall, TOutput> executor

    Executor instance that can handle the specified tool type.

    Type Parameters
    Name Description
    TCall

    Type of the tool call.

    TOutput

    Type of the tool output.

    Remarks

    Registered executors are used to resolve tool calls emitted by the agent when running tools-enabled models or MCP-based integrations.

    | Edit this page View Source

    SaveConversation()

    Saves the current conversation using the configured Conversation.

    Declaration
    public void SaveConversation()
    Remarks

    This is a fire-and-forget convenience wrapper around SaveConversationAsync(CancellationToken).

    | Edit this page View Source

    SaveConversationAsync(CancellationToken)

    Asynchronously saves the current conversation.

    Declaration
    public UniTask SaveConversationAsync(CancellationToken ct = default)
    Parameters
    Type Name Description
    CancellationToken ct

    Optional cancellation token.

    Returns
    Type Description
    UniTask

    A Cysharp.Threading.Tasks.UniTask that completes when the save finishes.

    | Edit this page View Source

    SaveConversationItems()

    Saves the items of the current conversation using the configured store.

    Declaration
    public void SaveConversationItems()
    Remarks

    This is a fire-and-forget convenience wrapper around SaveConversationItemsAsync(CancellationToken).

    | Edit this page View Source

    SaveConversationItemsAsync(CancellationToken)

    Asynchronously saves the items of the current conversation.

    Declaration
    public UniTask SaveConversationItemsAsync(CancellationToken ct = default)
    Parameters
    Type Name Description
    CancellationToken ct

    Optional cancellation token.

    Returns
    Type Description
    UniTask

    A Cysharp.Threading.Tasks.UniTask that completes when the save finishes.

    | Edit this page View Source

    SendMessage(Message)

    Sends a structured Message to the agent.

    Declaration
    public void SendMessage(Message inputMessage)
    Parameters
    Type Name Description
    Message inputMessage

    Message to enqueue for processing.

    Remarks

    The message is stored as a pending input and then scheduled into the internal processing queue. If inputMessage is null, this call is ignored.

    | Edit this page View Source

    SendText(string)

    Sends a plain-text input to the agent as a new user message.

    Declaration
    public void SendText(string inputText)
    Parameters
    Type Name Description
    string inputText

    User text to send.

    Remarks

    This is a convenience helper that wraps the provided text in a UserMessage and forwards it to SendMessage(Message).

    | Edit this page View Source

    SetConversation(Conversation)

    Sets the active conversation instance for this agent.

    Declaration
    public void SetConversation(Conversation conversation)
    Parameters
    Type Name Description
    Conversation conversation

    Conversation to make active.

    Remarks

    This is a fire-and-forget convenience wrapper around SetConversationAsync(Conversation, CancellationToken).

    | Edit this page View Source

    SetConversationAsync(Conversation, CancellationToken)

    Asynchronously sets the active conversation instance for this agent.

    Declaration
    public UniTask SetConversationAsync(Conversation conversation, CancellationToken ct = default)
    Parameters
    Type Name Description
    Conversation conversation

    Conversation to make active.

    CancellationToken ct

    Optional cancellation token.

    Returns
    Type Description
    UniTask
    | Edit this page View Source

    SetInstructionsUpdater(IInstructionsUpdater)

    Declaration
    public void SetInstructionsUpdater(IInstructionsUpdater instructionsUpdater)
    Parameters
    Type Name Description
    IInstructionsUpdater instructionsUpdater
    | Edit this page View Source

    SetToolRouter(IToolRouter)

    Declaration
    public void SetToolRouter(IToolRouter toolRouter)
    Parameters
    Type Name Description
    IToolRouter toolRouter
    | Edit this page View Source

    StartRecording()

    Declaration
    [Obsolete("Use StartTranscription instead.")]
    public void StartRecording()
    | Edit this page View Source

    StartTranscription()

    Starts recording audio input for transcription, if supported.

    Declaration
    public void StartTranscription()
    Remarks

    This call proxies StartTranscription() and uses the configured InputAudioRecorder when available.

    | Edit this page View Source

    StopRecording()

    Declaration
    [Obsolete("Use StopTranscription instead.")]
    public void StopRecording()
    | Edit this page View Source

    StopTranscription()

    Stops recording audio input and submits the captured audio for transcription.

    Declaration
    public void StopTranscription()
    Remarks

    This call proxies StopTranscription() and will only have an effect if audio recording was previously started.

    | Edit this page View Source

    UnregisterCallback<T>(Action<T>)

    Unregisters an event handler.

    Declaration
    public void UnregisterCallback<T>(Action<T> handler) where T : IEvent
    Parameters
    Type Name Description
    Action<T> handler

    The event handler to remove

    Type Parameters
    Name Description
    T

    The event payload type

    | Edit this page View Source

    UnregisterEvent<T>(Action<T>)

    Declaration
    [Obsolete("Use UnregisterCallback<T> method instead.")]
    public void UnregisterEvent<T>(Action<T> handler) where T : IEvent
    Parameters
    Type Name Description
    Action<T> handler
    Type Parameters
    Name Description
    T
    | Edit this page View Source

    UnregisterMcpApprovalHandler(string)

    Unregisters the MCP approval handler associated with the given server label.

    Declaration
    public bool UnregisterMcpApprovalHandler(string serverLabel)
    Parameters
    Type Name Description
    string serverLabel

    Server label whose approval handler should be removed.

    Returns
    Type Description
    bool

    true if a handler was removed; otherwise, false.

    | Edit this page View Source

    UnregisterOAuthTokenProvider(string)

    Unregisters the OAuth token provider associated with the specified server label.

    Declaration
    public bool UnregisterOAuthTokenProvider(string serverLabel)
    Parameters
    Type Name Description
    string serverLabel

    Server label whose provider should be removed.

    Returns
    Type Description
    bool

    true if a provider was removed; otherwise, false.

    | Edit this page View Source

    UnregisterToolExecutor<TCall, TOutput>(IToolCallExecutor<TCall, TOutput>)

    Unregisters a previously registered tool call executor.

    Declaration
    public bool UnregisterToolExecutor<TCall, TOutput>(IToolCallExecutor<TCall, TOutput> executor) where TCall : ToolCall where TOutput : ToolOutput
    Parameters
    Type Name Description
    IToolCallExecutor<TCall, TOutput> executor

    Executor instance to remove.

    Returns
    Type Description
    bool

    true if the executor was successfully removed; otherwise, false.

    Type Parameters
    Name Description
    TCall

    Type of the tool call.

    TOutput

    Type of the tool output.

    Implements

    IUniTaskQueueEventListener
    IAgentEventListener
    IGenerativeStreamListener
    IUsageEventListener
    IErrorEventListener
    IConversationEventListener
    ITextDeltaListener
    IImageDeltaListener
    IAnnotationDeltaListener
    IToolStatusListener
    IToolOutputListener
    IAgentBehaviour

    Extension Methods

    LocalizationExtensions.SetLocalizedAsset<TComponent, TObject>(TComponent, string, Action<TComponent, TObject>, string, LocalizationOptions<TObject>)
    ArrayExtensions.ToArrayOrEmpty<T>(T)
    ArrayExtensions.ToArrayOrNull<T>(T)
    EventExtensions.ToDelta<T>(T, string, int, string, bool)
    EventExtensions.ToDone<T>(T, string, int, string)
    EventExtensions.ToEvent<T>(T)
    EventExtensions.UpcastDelta<T1, T2>(T1, string, int, string, bool)
    FallbackExtensions.IsOr<TParent, TChild>(TParent, TChild)
    FileExtensions.ToFile<T>(T, string)
    ResponseCastingExtensions.GetResult<T>(T)
    UnityObjectExtensions.Find<T>(T, string)
    UnityObjectExtensions.Find<T, TTarget>(TTarget, T, string)
    UnityObjectExtensions.Find<T, TTarget>(TTarget, T, string, string)
    UnityObjectExtensions.GetChildIndex<T>(T)
    UnityObjectExtensions.GetOrAddComponentInChildren<T, TV>(TV, string)
    SystemExtensions.GetName(object)
    UnityObjectExtensions.EncodeToBase64(Object)
    UnityObjectExtensions.ToBytes(Object)
    • Edit this page
    • View Source
    In this article
    Back to top AI DevKit Documentation