AgentBehaviour Properties
Complete reference for AgentBehaviour component properties.
Overview
AgentBehaviour is a Unity MonoBehaviour component that wraps the core Agent class, providing inspector-friendly configuration and Unity lifecycle integration.
Agent Reference
Agent
public Agent Agent { get; }Read-only. Underlying runtime Agent instance.
Example:
var agent = agentBehaviour.Agent;
await agent.GenerateResponseAsync("Hello");Identity Properties
Id
public string Id { get; }Read-only. Unique agent identifier from settings.
Example:
Debug.Log($"Agent ID: {agentBehaviour.Id}");Name
public string Name { get; }Read-only. Human-readable agent name.
Example:
chatHeaderText.text = agentBehaviour.Name;Api
public override Api Api { get; }Read-only. API provider inferred from Model.
Values:
Api.OpenAIApi.AnthropicApi.Google
State Properties
State
public AgentStatus State { get; }Read-only. Current agent lifecycle state.
Values:
None- Not initializedInitializing- Initialization in progressInitializationFailed- Failed to initializeReady- Ready for requestsProcessing- Handling requestTerminating- Shutting down
Example:
if (agentBehaviour.State == AgentStatus.Ready)
{
sendButton.interactable = true;
}IsInitialized
public bool IsInitialized { get; }Read-only. True when agent is fully initialized.
Example:
void Update()
{
statusText.text = agentBehaviour.IsInitialized
? "Ready"
: "Initializing...";
}Model Properties
Model
public Model Model { get; set; }Active language model for text generation.
Example:
agentBehaviour.Model = Model.GPT4;
agentBehaviour.Model = Model.Claude35Sonnet;Inspector:
[SerializeField] private AgentBehaviour agent;
void Start()
{
// Model can be changed at runtime
agent.Model = Model.GPT4Turbo;
}ToolChoice
public ToolChoice ToolChoice { get; set; }Tool selection strategy.
Values:
ToolChoice.Auto- Model decidesToolChoice.None- Disable toolsToolChoice.Required- Must use toolToolChoice.Function("name")- Specific tool
Example:
// Let model decide
agentBehaviour.ToolChoice = ToolChoice.Auto;
// Force specific tool
agentBehaviour.ToolChoice = ToolChoice.Function("get_weather");Voice & Audio Properties
Voice
public Voice Voice { get; set; }TTS voice for audio responses.
Example:
agentBehaviour.Voice = Voice.Alloy;
agentBehaviour.Voice = Voice.Nova;OutputAudioVolume
public float OutputAudioVolume { get; set; }Master volume for speech output (0.0 to 1.0).
Example:
volumeSlider.onValueChanged.AddListener(volume =>
{
agentBehaviour.OutputAudioVolume = volume;
});InputAudioLanguage
public SystemLanguage InputAudioLanguage { get; set; }Language for audio input and transcription.
Example:
agentBehaviour.InputAudioLanguage = SystemLanguage.English;
agentBehaviour.InputAudioLanguage = SystemLanguage.Japanese;Microphone
public string Microphone { get; set; }Name of microphone device for audio input.
Example:
// List available microphones
string[] devices = UnityEngine.Microphone.devices;
microphoneDropdown.options = devices
.Select(d => new TMP_Dropdown.OptionData(d))
.ToList();
// Set selected microphone
microphoneDropdown.onValueChanged.AddListener(index =>
{
agentBehaviour.Microphone = devices[index];
});IsRecording
public bool IsRecording { get; }Read-only. True if currently recording audio.
Example:
void Update()
{
recordButton.GetComponent<Image>().color = agentBehaviour.IsRecording
? Color.red
: Color.white;
}Conversation Properties
Conversation
public Conversation Conversation { get; }Read-only. Active conversation instance.
Example:
var conversation = agentBehaviour.Conversation;
Debug.Log($"Messages: {conversation.Messages.Count}");
Debug.Log($"ID: {conversation.Id}");Items
public List<ConversationItem> Items { get; }Read-only. All items in conversation.
Example:
foreach (var item in agentBehaviour.Items)
{
Debug.Log($"{item.Type}: {item}");
}Messages
public List<Message> Messages { get; }Read-only. User and assistant messages only.
Example:
foreach (var message in agentBehaviour.Messages)
{
AddMessageToUI(message);
}LastMessage
public Message LastMessage { get; }Read-only. Most recent message.
Example:
if (agentBehaviour.LastMessage != null)
{
lastMessageText.text = agentBehaviour.LastMessage.Content;
}Instructions
public string Instructions { get; }Read-only. System instructions for agent.
Example:
instructionsText.text = agentBehaviour.Instructions;Component Properties
InputAudioRecorder
public InputAudioRecorder InputAudioRecorder { get; }Read-only. Recorder component for audio input.
Example:
if (agentBehaviour.InputAudioRecorder != null)
{
var level = agentBehaviour.InputAudioRecorder.GetAudioLevel();
levelMeter.value = level;
}OutputAudioPlayer
public OutputAudioPlayer OutputAudioPlayer { get; }Read-only. Player component for audio output.
Example:
if (agentBehaviour.OutputAudioPlayer != null)
{
var isPlaying = agentBehaviour.OutputAudioPlayer.IsPlaying;
speakerIcon.enabled = isPlaying;
}Capability Properties
HasInputAudio
public bool HasInputAudio { get; }Read-only. True if agent accepts audio input.
Example:
if (agentBehaviour.HasInputAudio)
{
microphoneButton.gameObject.SetActive(true);
}HasOutputAudio
public bool HasOutputAudio { get; }Read-only. True if agent can output speech.
Example:
if (agentBehaviour.HasOutputAudio)
{
speakerButton.gameObject.SetActive(true);
}HasOutputImage
public bool HasOutputImage { get; }Read-only. True if agent can generate images.
Example:
if (agentBehaviour.HasOutputImage)
{
imagePanel.gameObject.SetActive(true);
}Configuration Properties
ConversationStoreType
public ConversationStoreType ConversationStoreType { get; }Read-only. Storage backend for conversations.
Serialized Field:
[SerializeField] private ConversationStoreType conversationStore = ConversationStoreType.LocalFile;Values:
LocalFile- Local file systemCloudStorage- Cloud storageDatabase- Database
InitialConversationId
public string InitialConversationId { get; }Read-only. Conversation ID to load on initialization.
Serialized Field:
[SerializeField] private string conversationId;IncludeObfuscation
public bool IncludeObfuscation { get; }Read-only. Include obfuscation metadata in responses.
Serialized Field:
[SerializeField] private bool includeObfuscation = false;Stream
public bool Stream { get; set; }Enable/disable streaming responses.
Serialized Field:
[SerializeField] private bool stream = false;Example:
streamingToggle.onValueChanged.AddListener(enabled =>
{
agentBehaviour.Stream = enabled;
});Behavior Properties
WaitForToolCallsCompletion
public bool WaitForToolCallsCompletion { get; }Read-only. True if agent waits for all tool calls to complete.
UnhandledToolCallBehaviour
public UnhandledToolCallBehaviour UnhandledToolCallBehaviour { get; }Read-only. Policy for unhandled tool calls.
Serialized Field:
[SerializeField] private UnhandledToolCallBehaviour unhandledToolCallBehaviour;Values:
Ignore- Skip unhandled callsThrowError- Throw exceptionSubmitToolOutput- Wait for external submissionEvent- Fire onUnhandledToolCall event
SubmitToolOutputTimeoutSeconds
public int SubmitToolOutputTimeoutSeconds { get; }Read-only. Timeout for tool output submission.
Serialized Field:
[Range(0, 300)]
[SerializeField] private int submitToolOutputTimeoutSeconds = 60;McpApprovalTimeoutSeconds
public int McpApprovalTimeoutSeconds { get; }Read-only. Timeout for MCP approval requests.
Serialized Field:
[SerializeField] private int mcpApprovalTimeoutSeconds = 30;Complete Example
using UnityEngine;
using Glitch9.AIDevKit.Agents;
using TMPro;
public class AgentPropertiesUI : MonoBehaviour
{
[SerializeField] private AgentBehaviour agent;
[Header("UI Elements")]
[SerializeField] private TMP_Text nameText;
[SerializeField] private TMP_Text statusText;
[SerializeField] private TMP_Text modelText;
[SerializeField] private TMP_Text messagesText;
[SerializeField] private GameObject audioControls;
[SerializeField] private GameObject imagePanel;
void Start()
{
UpdateUI();
}
void Update()
{
UpdateStatus();
}
void UpdateUI()
{
// Identity
nameText.text = agent.Name;
// Model
modelText.text = agent.Model.ToString();
// Capabilities
audioControls.SetActive(agent.HasInputAudio || agent.HasOutputAudio);
imagePanel.SetActive(agent.HasOutputImage);
}
void UpdateStatus()
{
// State
statusText.text = agent.State switch
{
AgentStatus.None => "Not Initialized",
AgentStatus.Initializing => "Initializing...",
AgentStatus.Ready => "Ready",
AgentStatus.Processing => "Processing...",
AgentStatus.Terminating => "Shutting Down",
_ => "Unknown"
};
// Conversation
if (agent.Messages != null)
{
messagesText.text = $"Messages: {agent.Messages.Count}";
}
}
public void OnModelChanged(int index)
{
Model[] models = { Model.GPT4, Model.GPT4Turbo, Model.Claude35Sonnet };
agent.Model = models[index];
UpdateUI();
}
public void OnVolumeChanged(float volume)
{
agent.OutputAudioVolume = volume;
}
}Next Steps
Last updated