Implementation:Microsoft Autogen Studio Component Editor
| Sources | Microsoft_Autogen |
|---|---|
| Domains | Frontend, React, Component Editor, Form Editor |
| Last Updated | 2026-02-11 17:00 GMT |
Overview
Description
The ComponentEditor is a versatile form editor component that provides a unified interface for editing all types of AutoGen components (agents, models, tools, workbenches, teams, and termination conditions). It supports nested component navigation through an edit path mechanism, allowing users to drill down into nested configurations. The editor offers both form-based editing and JSON editing modes with real-time validation and testing capabilities.
Key features include:
- Type-specific field rendering based on component type
- Breadcrumb navigation for nested components
- Working copy mechanism to prevent accidental changes
- JSON editing mode with Monaco editor
- Component testing with result display
- Automatic normalization of workbench arrays
Usage
Used as a side panel or modal editor for configuring individual components within the team builder. It dispatches to specialized field components (AgentFields, ModelFields, etc.) based on the component type being edited. The editor maintains a working copy that can be committed or discarded, with support for deep nested editing paths.
Code Reference
Source Location:
python/packages/autogen-studio/frontend/src/components/views/teambuilder/builder/component-editor/component-editor.tsx
Signature:
export interface EditPath {
componentType: string;
id: string;
parentField: string;
index?: number;
}
export interface ComponentEditorProps {
component: Component<ComponentConfig>;
onChange: (updatedComponent: Component<ComponentConfig>) => void;
onClose?: () => void;
navigationDepth?: boolean;
}
export const ComponentEditor: React.FC<ComponentEditorProps> = ({
component,
onChange,
onClose,
navigationDepth = false,
}) => { /* ... */ }Import:
import ComponentEditor from "./component-editor/component-editor";I/O Contract
Props/Inputs
| Parameter | Type | Required | Description |
|---|---|---|---|
| component | Component<ComponentConfig> | Yes | The component to edit (agent, model, tool, etc.) |
| onChange | (component: Component<ComponentConfig>) => void | Yes | Callback invoked when component changes are committed |
| onClose | () => void | No | Callback for closing the editor panel |
| navigationDepth | boolean | No | Enable navigation into nested components (default: false) |
Outputs
| Output | Type | Description |
|---|---|---|
| onChange callback | Component<ComponentConfig> | Emits the updated component configuration |
| onClose callback | void | Signals editor should be closed |
State Management
| State | Type | Description |
|---|---|---|
| editPath | EditPath[] | Navigation path for nested component editing |
| workingCopy | Component<ComponentConfig> | Local copy of component being edited |
| isJsonEditing | boolean | Toggle for JSON vs form editing mode |
| testLoading | boolean | Loading state for component testing |
| testResult | null | Results from component test execution |
Key Features
Type-Based Field Rendering
The editor automatically renders appropriate fields based on component type:
- Teams: TeamFields for participant and termination configuration
- Agents: AgentFields for agent-specific settings (system messages, models, tools)
- Models: ModelFields for API configuration and model parameters
- Tools: ToolFields for function tool source code and imports
- Workbenches: WorkbenchFields for workbench-specific settings
- Termination: TerminationFields for condition configuration
When navigationDepth is enabled:
- Edit Path Tracking: Maintains array of navigation breadcrumbs
- Deep Editing: Navigate into nested components (e.g., tools within agents)
- Breadcrumb UI: Visual navigation path with back button
- Path-based Updates: Updates correctly propagate through nested structure
- Index Support: Handles both array indices and ID-based lookups
Working Copy Mechanism
- Isolation: Edits modify working copy, not the original component
- Commit on Apply: Changes committed when "Apply" button clicked
- Discard Changes: Close without applying reverts all changes
- Deep Clone: Working copy created with Object.assign
Component Testing
- Test Button: Runs component validation and execution test
- Test Results: Displays test status, message, and logs
- Loading State: Shows spinner during test execution
- Error Handling: Graceful error display for test failures
Workbench Normalization
Special handling for workbench fields:
- Format Flexibility: Accepts both single workbench object and array
- Automatic Normalization: Converts to array format internally
- Backward Compatibility: Handles legacy configurations
- Nested Tool Access: Locates tools within StaticWorkbench configs
JSON Editing Mode
- Monaco Editor: Full-featured JSON editor with syntax highlighting
- Debounced Updates: 500ms debounce on JSON changes to prevent lag
- Validation: JSON parsing errors caught and logged
- Toggle Switch: Easy switching between form and JSON modes
Implementation Details
Path-based Component Lookup
The getCurrentComponent function traverses the edit path:
const getCurrentComponent = (root: Component<ComponentConfig>) => {
return editPath.reduce<Component<ComponentConfig> | null>(
(current, path) => {
if (!current) return null;
let field = current.config[path.parentField];
// Special workbench normalization
if (path.parentField === "workbench") {
field = normalizeWorkbenches(field);
}
// Array or single item lookup
if (Array.isArray(field)) {
return field[path.index] || field.find(item => item.label === path.id);
}
return field || null;
},
root
);
};Path-based Component Update
The updateComponentAtPath function recursively updates nested components:
- Base case: Empty path updates root component
- Recursive case: Updates field at current path, then recurses
- Array handling: Uses index if provided, falls back to ID lookup
- Special workbench handling: Updates tools within StaticWorkbench
const breadcrumbItems = [
{ title: workingCopy.label || "Root" },
...editPath.map((path) => ({
title: path.id,
onClick: () => handleNavigateBack(),
})),
];Usage Examples
Basic Component Editing
import ComponentEditor from "./component-editor/component-editor";
function ComponentPanel({ selectedComponent }) {
const handleComponentChange = (updated: Component<ComponentConfig>) => {
// Update in parent state/store
updateComponentInTeam(updated);
};
return (
<ComponentEditor
component={selectedComponent}
onChange={handleComponentChange}
onClose={() => setSelectedComponent(null)}
/>
);
}<ComponentEditor
component={agentComponent}
onChange={handleComponentChange}
navigationDepth={true}
onClose={handleClose}
/>This allows users to click "Edit" on nested items (like tools within an agent) and navigate into a dedicated editor for that nested component.
Testing a Component
The editor includes a "Test" button that validates and executes the component:
const handleTestComponent = async () => {
setTestLoading(true);
const result = await validationAPI.testComponent(currentComponent);
setTestResult(result);
if (result.status) {
messageApi.success("Component test passed!");
}
};Integration Points
Field Components
| Component | Used For |
|---|---|
| AgentFields | Editing agent configurations (AssistantAgent, UserProxyAgent, WebSurferAgent) |
| ModelFields | Editing model configurations (OpenAI, Azure, Anthropic) |
| TeamFields | Editing team structure and participants |
| ToolFields | Editing function tool source code and imports |
| WorkbenchFields | Editing workbench configurations (Static, MCP) |
| TerminationFields | Editing termination conditions |
Type Guards
Uses type guard functions to determine component type:
isTeamComponent()isAgentComponent()isModelComponent()isToolComponent()isWorkbenchComponent()isTerminationComponent()
API Integration
- validationAPI.testComponent: Tests component execution and validation
UI Components
- Breadcrumb: Navigation path display
- Button: Actions (Apply, Test, JSON mode toggle)
- MonacoEditor: JSON editing interface
- TestDetails: Test result display component
- message: Toast notifications (Ant Design)
Related Pages
- Studio Agent Fields - Agent configuration fields
- Studio Model Fields - Model configuration fields
- Studio Tool Fields - Tool editing interface
- Studio Termination Fields - Termination editor
- Studio Common Fields - Shared field components
- Studio Team Builder - Parent builder component
- Component Guards - Type checking utilities