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.
Implements
Inherited Members
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 SourceonAgentDataSaved
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> |
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> |
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> |
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> |
onCodeInterpreterOutputImage
Declaration
[Tooltip("Invoked when the Code Interpreter tool produces an image output.")]
public UnityEvent<Texture2D> onCodeInterpreterOutputImage
Field Value
| Type | Description |
|---|---|
| UnityEvent<Texture2D> |
onCodeInterpreterOutputLogs
Declaration
[Tooltip("Invoked when the Code Interpreter tool emits textual log output.")]
public UnityEvent<string> onCodeInterpreterOutputLogs
Field Value
| Type | Description |
|---|---|
| UnityEvent<string> |
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> |
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> |
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[]> |
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> |
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> |
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> |
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[]> |
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> |
onGeneratedImage
Declaration
[Header("Image Generation")]
[Tooltip("Invoked when an image is generated.")]
public UnityStreamEvent<Texture2D> onGeneratedImage
Field Value
| Type | Description |
|---|---|
| UnityStreamEvent<Texture2D> |
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> |
onMcpListToolsOutput
Declaration
[Tooltip("Invoked when MCP list tools call produces output.")]
public UnityEvent<McpListToolsCallOutput> onMcpListToolsOutput
Field Value
| Type | Description |
|---|---|
| UnityEvent<McpListToolsCallOutput> |
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> |
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> |
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> |
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> |
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> |
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> |
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> |
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> |
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 SourceAgent
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.
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.
Api
API provider inferred from the selected Model.
Declaration
public override sealed Api Api { get; }
Property Value
| Type | Description |
|---|---|
| Api |
Overrides
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.
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.
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.
ConversationSettings
Declaration
public IMemorySettings ConversationSettings { get; }
Property Value
| Type | Description |
|---|---|
| IMemorySettings |
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.
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.
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.
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.
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 |
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.
InputAudioRecorder
Recorder component used to capture audio input for transcription, if assigned.
Declaration
public SpeechToTextRecorder InputAudioRecorder { get; }
Property Value
| Type | Description |
|---|---|
| SpeechToTextRecorder |
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.
IsInitialized
Indicates whether the underlying Agent has completed initialization.
Declaration
public bool IsInitialized { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsRecording
Indicates whether the input audio recorder is currently capturing audio.
Declaration
public bool IsRecording { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsStreaming
Declaration
public bool IsStreaming { get; }
Property Value
| Type | Description |
|---|---|
| bool |
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.
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.
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).
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.
Model
Active generative model used for this agent.
Declaration
public Model Model { get; set; }
Property Value
| Type | Description |
|---|---|
| Model |
Remarks
-
When
saveDatais 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.
Name
Declaration
[Obsolete("Use AgentName property instead.")]
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| string |
OutputAudioPlayer
Player component used to output synthesized speech, if assigned.
Declaration
public TextToSpeechPlayer OutputAudioPlayer { get; }
Property Value
| Type | Description |
|---|---|
| TextToSpeechPlayer |
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.
SpeechOutputVolume
Declaration
[Obsolete("Use SpeechVolume instead.")]
public float SpeechOutputVolume { get; set; }
Property Value
| Type | Description |
|---|---|
| float |
SpokenLanguage
Declaration
[Obsolete("Use InputVoiceLanguage instead.")]
public SystemLanguage SpokenLanguage { get; set; }
Property Value
| Type | Description |
|---|---|
| SystemLanguage |
State
Declaration
[Obsolete("Use Status instead.")]
public AgentStatus State { get; }
Property Value
| Type | Description |
|---|---|
| AgentStatus |
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.
Stream
Declaration
[Obsolete("Use IsStreaming property instead.")]
public bool Stream { get; }
Property Value
| Type | Description |
|---|---|
| bool |
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.
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.
ToolChoice
Tool selection strategy for this agent.
Declaration
public ToolChoice ToolChoice { get; set; }
Property Value
| Type | Description |
|---|---|
| ToolChoice |
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 |
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.
VoiceRecorder
Declaration
[Obsolete("Use InputAudioRecorder instead.")]
public SpeechToTextRecorder VoiceRecorder { get; }
Property Value
| Type | Description |
|---|---|
| SpeechToTextRecorder |
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.
inputTranscription
Declaration
[Obsolete("Use onInputTranscription instead.")]
public UnityStreamEvent<string> inputTranscription { get; }
Property Value
| Type | Description |
|---|---|
| UnityStreamEvent<string> |
message
Declaration
[Obsolete("Use onMessage instead.")]
public UnityStreamEvent<string> message { get; }
Property Value
| Type | Description |
|---|---|
| UnityStreamEvent<string> |
onInputTranscription
Declaration
[Obsolete("Use onInputTranscript instead.")]
public UnityStreamEvent<string> onInputTranscription { get; }
Property Value
| Type | Description |
|---|---|
| UnityStreamEvent<string> |
onReceiveCodeInterpreterOutputImage
Declaration
[Obsolete("Use onReceiveCodeInterpreterOutputImage instead.")]
public UnityEvent<Texture2D> onReceiveCodeInterpreterOutputImage { get; }
Property Value
| Type | Description |
|---|---|
| UnityEvent<Texture2D> |
onReceiveCodeInterpreterOutputLogs
Declaration
[Obsolete("Use onReceiveCodeInterpreterOutputLogs instead.")]
public UnityEvent<string> onReceiveCodeInterpreterOutputLogs { get; }
Property Value
| Type | Description |
|---|---|
| UnityEvent<string> |
onReceiveFileSearchOutput
Declaration
[Obsolete("Use onFileSearchOutput instead.")]
public UnityEvent<FileSearchOutput> onReceiveFileSearchOutput { get; }
Property Value
| Type | Description |
|---|---|
| UnityEvent<FileSearchOutput> |
onReceiveMcpListToolsOutput
Declaration
[Obsolete("Use onMcpListToolsOutput instead.")]
public UnityEvent<McpListToolsCallOutput> onReceiveMcpListToolsOutput { get; }
Property Value
| Type | Description |
|---|---|
| UnityEvent<McpListToolsCallOutput> |
onReceiveMcpToolOutput
Declaration
[Obsolete("Use onMcpToolOutput instead.")]
public UnityEvent<McpOutput> onReceiveMcpToolOutput { get; }
Property Value
| Type | Description |
|---|---|
| UnityEvent<McpOutput> |
onReceiveWebSearchOutput
Declaration
[Obsolete("Use onWebToolStatusChanged instead.")]
public UnityEvent<WebSearchOutput> onReceiveWebSearchOutput { get; }
Property Value
| Type | Description |
|---|---|
| UnityEvent<WebSearchOutput> |
onTranscript
Declaration
[Obsolete("Use onOutputTranscript instead.")]
public UnityStreamEvent<string> onTranscript { get; }
Property Value
| Type | Description |
|---|---|
| UnityStreamEvent<string> |
reasoning
Declaration
[Obsolete("Use onReasoning instead.")]
public UnityStreamEvent<string> reasoning { get; }
Property Value
| Type | Description |
|---|---|
| UnityStreamEvent<string> |
reasoningSummary
Declaration
[Obsolete("Use onReasoningSummary instead.")]
public UnityStreamEvent<string> reasoningSummary { get; }
Property Value
| Type | Description |
|---|---|
| UnityStreamEvent<string> |
refusal
Declaration
[Obsolete("Use onRefusal instead.")]
public UnityStreamEvent<string> refusal { get; }
Property Value
| Type | Description |
|---|---|
| UnityStreamEvent<string> |
transcript
Declaration
[Obsolete("Use onTranscript instead.")]
public UnityStreamEvent<string> transcript { get; }
Property Value
| Type | Description |
|---|---|
| UnityStreamEvent<string> |
Methods
| Edit this page View SourceAddAttachments(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.
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.
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. |
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. |
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. |
Awake()
Declaration
protected override void Awake()
Overrides
| Edit this page View SourceCreateConversation()
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).
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. |
EnterChatMessage(Message)
Declaration
[Obsolete("Use SendMessage instead.")]
public void EnterChatMessage(Message request)
Parameters
| Type | Name | Description |
|---|---|---|
| Message | request |
EnterChatText(string)
Declaration
[Obsolete("Use SendText instead.")]
public void EnterChatText(string inputText)
Parameters
| Type | Name | Description |
|---|---|---|
| string | inputText |
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
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.
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. |
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 |
Remarks
This is a fire-and-forget convenience wrapper around LoadConversationAsync(string, bool, CancellationToken).
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 |
| CancellationToken | ct | Optional cancellation token. |
Returns
| Type | Description |
|---|---|
| UniTask<Conversation> | The loaded or newly created Conversation. |
OnAgentDataSaved(AgentSaveData)
Called when agent data has been successfully saved.
Declaration
public void OnAgentDataSaved(AgentSaveData prefs)
Parameters
| Type | Name | Description |
|---|---|---|
| AgentSaveData | prefs |
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 |
OnAnnotationDelta(Delta<IAnnotationChunk>)
Declaration
public void OnAnnotationDelta(Delta<IAnnotationChunk> e)
Parameters
| Type | Name | Description |
|---|---|---|
| Delta<IAnnotationChunk> | e |
OnConversationEvent(ConversationEvent)
Declaration
public void OnConversationEvent(ConversationEvent evt)
Parameters
| Type | Name | Description |
|---|---|---|
| ConversationEvent | evt |
OnDestroy()
Declaration
protected override void OnDestroy()
Overrides
| Edit this page View SourceOnImageDelta(Delta<IImageChunk>)
Declaration
public void OnImageDelta(Delta<IImageChunk> e)
Parameters
| Type | Name | Description |
|---|---|---|
| Delta<IImageChunk> | e |
OnTextDelta(Delta<ITextChunk>)
Declaration
public void OnTextDelta(Delta<ITextChunk> e)
Parameters
| Type | Name | Description |
|---|---|---|
| Delta<ITextChunk> | e |
OnToolOutput(ToolOutputEvent)
Declaration
public void OnToolOutput(ToolOutputEvent e)
Parameters
| Type | Name | Description |
|---|---|---|
| ToolOutputEvent | e |
OnToolStatus(ToolStatusEvent)
Declaration
public void OnToolStatus(ToolStatusEvent e)
Parameters
| Type | Name | Description |
|---|---|---|
| ToolStatusEvent | e |
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 |
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 |
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. |
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. |
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.
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).
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. |
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).
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. |
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.
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).
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).
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 |
SetInstructionsUpdater(IInstructionsUpdater)
Declaration
public void SetInstructionsUpdater(IInstructionsUpdater instructionsUpdater)
Parameters
| Type | Name | Description |
|---|---|---|
| IInstructionsUpdater | instructionsUpdater |
SetToolRouter(IToolRouter)
Declaration
public void SetToolRouter(IToolRouter toolRouter)
Parameters
| Type | Name | Description |
|---|---|---|
| IToolRouter | toolRouter |
StartRecording()
Declaration
[Obsolete("Use StartTranscription instead.")]
public void StartRecording()
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.
StopRecording()
Declaration
[Obsolete("Use StopTranscription instead.")]
public void StopRecording()
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.
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 |
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 |
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 |
|
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 |
|
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 |
|
Type Parameters
| Name | Description |
|---|---|
| TCall | Type of the tool call. |
| TOutput | Type of the tool output. |