Implementation:Microsoft Autogen Studio Datamodel Types
| Knowledge Sources | python/packages/autogen-studio/frontend/src/components/types/datamodel.ts |
|---|---|
| Domains | Frontend, Type Definitions, Data Models, Component Configuration |
| Last Updated | 2026-02-11 |
Overview
The Datamodel Types module defines the complete TypeScript type system for AutoGen Studio, providing interfaces and types for all components, configurations, messages, and runtime objects used throughout the application.
Description
This comprehensive TypeScript module establishes the type foundation for AutoGen Studio's frontend architecture. It includes:
Component System:
- Base Component interface with generic type parameter for configuration
- ComponentTypes union defining all valid component categories (team, agent, model, tool, termination, workbench)
- Component interface supporting provider-based polymorphism with version tracking
Configuration Types:
- Teams: SelectorGroupChatConfig, RoundRobinGroupChatConfig, SwarmConfig
- Agents: AssistantAgentConfig, UserProxyAgentConfig, MultimodalWebSurferConfig
- Models: OpenAIClientConfig, AzureOpenAIClientConfig, AnthropicClientConfig
- Tools: FunctionToolConfig, PythonCodeExecutionToolConfig with executor configurations
- Workbenches: StaticWorkbenchConfig, McpWorkbenchConfig with multiple server parameter types
- Terminations: 11 different termination condition types including combinators (OR/AND)
Message System:
- AgentMessageConfig union type supporting text, multimodal, stop, handoff, tool call, and streaming messages
- RequestUsage interface for token tracking
- ImageContent, FunctionCall, and FunctionExecutionResult for rich message content
Database Models:
- Team, Message, Session interfaces with DBModel metadata
- Gallery interface for component collections
- Settings interface for environment variables and UI preferences
Runtime Types:
- Run and SessionRuns for execution tracking
- WebSocketMessage for real-time communication
- TaskResult and TeamResult for execution outcomes
- RunStatus enum with 7 states (created, active, awaiting_input, timeout, complete, error, stopped)
The module uses discriminated unions, generic constraints, and optional properties extensively to provide both flexibility and type safety. All configuration interfaces mirror the Python backend's data structures while maintaining TypeScript idioms.
Usage
This module is imported throughout the AutoGen Studio frontend wherever component data needs to be typed, including state management, API calls, UI components, and data transformation utilities.
import type {
Component,
ComponentConfig,
TeamConfig,
AgentConfig,
Message,
Run,
Gallery
} from "./types/datamodel";
Code Reference
Source Location: /tmp/kapso_repo_2mr4n2g4/python/packages/autogen-studio/frontend/src/components/types/datamodel.ts
Key Type Definitions:
// Base component system
export type ComponentTypes =
| "team"
| "agent"
| "model"
| "tool"
| "termination"
| "workbench";
export interface Component<T extends ComponentConfig> {
provider: string;
component_type: ComponentTypes;
version?: number;
component_version?: number;
description?: string | null;
config: T;
label?: string;
}
// Configuration unions
export type TeamConfig =
| SelectorGroupChatConfig
| RoundRobinGroupChatConfig
| SwarmConfig;
export type AgentConfig =
| MultimodalWebSurferConfig
| AssistantAgentConfig
| UserProxyAgentConfig;
export type ModelConfig =
| OpenAIClientConfig
| AzureOpenAIClientConfig
| AnthropicClientConfig;
export type ComponentConfig =
| TeamConfig
| AgentConfig
| ModelConfig
| ToolConfig
| WorkbenchConfig
| TerminationConfig
| ChatCompletionContextConfig;
// Database models
export interface DBModel {
id?: number;
user_id?: string;
created_at?: string;
updated_at?: string;
version?: number;
}
export interface Team extends DBModel {
component: Component<TeamConfig>;
}
export interface Gallery extends DBModel {
config: GalleryConfig;
}
// Runtime types
export type RunStatus =
| "created"
| "active"
| "awaiting_input"
| "timeout"
| "complete"
| "error"
| "stopped";
export interface Run {
id: number;
created_at: string;
updated_at?: string;
status: RunStatus;
task: AgentMessageConfig[];
team_result: TeamResult | null;
messages: Message[];
error_message?: string;
}
Import Statement:
import type {
// Base types
Component,
ComponentTypes,
ComponentConfig,
// Configurations
TeamConfig,
AgentConfig,
ModelConfig,
ToolConfig,
WorkbenchConfig,
TerminationConfig,
// Specific configs
AssistantAgentConfig,
SelectorGroupChatConfig,
OpenAIClientConfig,
FunctionToolConfig,
// Messages
AgentMessageConfig,
TextMessageConfig,
// Database models
Team,
Gallery,
Session,
Message,
// Runtime
Run,
RunStatus,
WebSocketMessage,
TaskResult,
// Settings
Settings,
EnvironmentVariable
} from "./types/datamodel";
I/O Contract
Component Configurations
| Configuration Type | Key Properties | Description |
|---|---|---|
| AssistantAgentConfig | name, model_client, workbench, system_message | Configuration for AI assistant agents with tool capabilities |
| UserProxyAgentConfig | name, description | Configuration for human user proxy agents |
| MultimodalWebSurferConfig | name, model_client, headless, start_page | Configuration for web browsing agents |
| SelectorGroupChatConfig | participants, model_client, termination_condition, selector_prompt | Team with model-based speaker selection |
| RoundRobinGroupChatConfig | participants, termination_condition, max_turns | Team with round-robin speaker order |
| OpenAIClientConfig | model, api_key, temperature, max_tokens | OpenAI model client configuration |
| AzureOpenAIClientConfig | model, azure_endpoint, azure_deployment, api_version | Azure OpenAI model client configuration |
| AnthropicClientConfig | model, api_key, max_tokens, temperature | Anthropic model client configuration |
| FunctionToolConfig | source_code, name, description, global_imports | Custom Python function tool configuration |
| PythonCodeExecutionToolConfig | executor, description, name | Python code execution tool with executor config |
| StaticWorkbenchConfig | tools | Static collection of tools |
| McpWorkbenchConfig | server_params | MCP server connection parameters |
Termination Configurations
| Type | Properties | Description |
|---|---|---|
| MaxMessageTerminationConfig | max_messages, include_agent_event | Terminate after N messages |
| TextMentionTerminationConfig | text | Terminate when specific text is mentioned |
| StopMessageTerminationConfig | (none) | Terminate on StopMessage |
| TokenUsageTerminationConfig | max_total_token, max_prompt_token, max_completion_token | Terminate on token limits |
| HandoffTerminationConfig | target | Terminate on handoff to target |
| TimeoutTerminationConfig | timeout_seconds | Terminate after duration |
| ExternalTerminationConfig | (none) | Externally controlled termination |
| SourceMatchTerminationConfig | sources | Terminate when specific sources respond |
| TextMessageTerminationConfig | source | Terminate on TextMessage from source |
| OrTerminationConfig | conditions | Terminate when any condition is met |
| AndTerminationConfig | conditions | Terminate when all conditions are met |
Message Types
| Message Type | Properties | Description |
|---|---|---|
| TextMessageConfig | source, content, models_usage, metadata | Plain text message |
| MultiModalMessageConfig | ImageContent)[] | Message with mixed text and images |
| StopMessageConfig | source, content | Message indicating stop |
| HandoffMessageConfig | source, content, target | Message indicating handoff |
| ToolCallMessageConfig | source, content (FunctionCall[]) | Tool invocation message |
| ToolCallResultMessageConfig | source, content (FunctionExecutionResult[]) | Tool execution result |
| ModelClientStreamingChunkEvent | source, content, type | Streaming chunk from model |
Database Models
| Model | Extends | Key Properties | Description |
|---|---|---|---|
| Team | DBModel | component: Component<TeamConfig> | Persisted team configuration |
| Session | DBModel | name, team_id | Conversation session |
| Message | DBModel | config: AgentMessageConfig, session_id, run_id | Message in a session/run |
| Gallery | DBModel | config: GalleryConfig | Component gallery collection |
| Settings | DBModel | config: SettingsConfig | Application settings |
Runtime Types
| Type | Properties | Description |
|---|---|---|
| Run | id, status, task, team_result, messages, error_message | Execution run of a team |
| SessionRuns | runs: Run[] | Collection of runs for a session |
| WebSocketMessage | type, data, status, error, timestamp | Real-time message over WebSocket |
| TaskResult | messages, stop_reason | Result of task execution |
| TeamResult | task_result, usage, duration | Complete team execution result |
Usage Examples
Type-Safe Component Creation
import type { Component, AssistantAgentConfig } from "./types/datamodel";
const agentComponent: Component<AssistantAgentConfig> = {
provider: "autogen_agentchat.agents.AssistantAgent",
component_type: "agent",
version: 2,
label: "My Assistant",
config: {
name: "assistant",
description: "A helpful assistant",
model_client: {
provider: "autogen_ext.models.openai.OpenAIChatCompletionClient",
component_type: "model",
config: { model: "gpt-4o-mini" }
},
workbench: [],
system_message: "You are a helpful assistant",
reflect_on_tool_use: false,
tool_call_summary_format: "{result}",
model_client_stream: false
}
};
Working with Messages
import type { Message, TextMessageConfig } from "./types/datamodel";
const message: Message = {
id: 1,
session_id: 123,
run_id: 456,
config: {
source: "assistant_agent",
content: "Hello! How can I help you today?",
models_usage: {
prompt_tokens: 10,
completion_tokens: 8
}
} as TextMessageConfig,
created_at: new Date().toISOString()
};
Handling Run States
import type { Run, RunStatus } from "./types/datamodel";
function handleRunUpdate(run: Run) {
switch (run.status) {
case "active":
console.log("Run is executing...");
break;
case "awaiting_input":
console.log("Run needs user input");
break;
case "complete":
console.log("Run completed:", run.team_result);
break;
case "error":
console.error("Run failed:", run.error_message);
break;
}
}
Gallery Configuration
import type { Gallery, GalleryConfig } from "./types/datamodel";
const gallery: Gallery = {
id: 1,
config: {
id: "my-gallery",
name: "My Component Gallery",
metadata: {
author: "John Doe",
version: "1.0.0",
description: "Custom components",
created_at: new Date().toISOString(),
updated_at: new Date().toISOString()
},
components: {
teams: [],
agents: [],
models: [],
tools: [],
workbenches: [],
terminations: []
}
}
};
Settings Configuration
import type { Settings, EnvironmentVariable } from "./types/datamodel";
const settings: Settings = {
config: {
environment: [
{
name: "OPENAI_API_KEY",
value: "sk-...",
type: "secret",
description: "OpenAI API key",
required: true
}
] as EnvironmentVariable[],
ui: {
show_llm_call_events: true,
expanded_messages_by_default: false,
show_agent_flow_by_default: true,
human_input_timeout_minutes: 5
}
}
};
Related Pages
- Studio Type Guards - Runtime type checking and narrowing functions
- Studio Component Templates - Pre-configured component templates
- Studio API Client - API interactions using these types
- Studio Component Editor - UI for editing components
- Studio Team Builder - Team configuration using these types