Skip to content

Commit 3bce93e

Browse files
feat: extract base properties and extend coded
1 parent 6a6c64e commit 3bce93e

File tree

2 files changed

+30
-18
lines changed

2 files changed

+30
-18
lines changed

src/uipath/agent/models/agent.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -502,24 +502,12 @@ class AgentSettings(BaseModel):
502502
class BaseAgentDefinition(BaseModel):
503503
"""Agent definition model."""
504504

505-
id: str = Field(..., description="Agent id or project name")
506-
name: str = Field(..., description="Agent name or project name")
507-
metadata: Optional[AgentMetadata] = Field(None, description="Agent metadata")
508-
messages: List[AgentMessage] = Field(
509-
..., description="List of system and user messages"
510-
)
511505
input_schema: Dict[str, Any] = Field(
512506
..., alias="inputSchema", description="JSON schema for input arguments"
513507
)
514508
output_schema: Dict[str, Any] = Field(
515509
..., alias="outputSchema", description="JSON schema for output arguments"
516510
)
517-
version: str = Field("1.0.0", description="Agent version")
518-
resources: List[AgentResourceConfig] = Field(
519-
..., description="List of tools, context, mcp and escalation resources"
520-
)
521-
features: List[Any] = Field(default_factory=list, description="Agent feature list")
522-
settings: AgentSettings = Field(..., description="Agent settings")
523511

524512
model_config = ConfigDict(
525513
validate_by_name=True, validate_by_alias=True, extra="allow"
@@ -530,18 +518,41 @@ class AgentType(str, Enum):
530518
"""Agent type."""
531519

532520
LOW_CODE = "lowCode"
521+
CODED = "coded"
533522

534523

535524
class LowCodeAgentDefinition(BaseAgentDefinition):
536525
"""Low code agent definition."""
537526

538527
type: Literal[AgentType.LOW_CODE] = AgentType.LOW_CODE
539528

529+
id: str = Field(..., description="Agent id or project name")
530+
name: str = Field(..., description="Agent name or project name")
531+
metadata: Optional[AgentMetadata] = Field(None, description="Agent metadata")
532+
messages: List[AgentMessage] = Field(
533+
..., description="List of system and user messages"
534+
)
535+
536+
version: str = Field("1.0.0", description="Agent version")
537+
resources: List[AgentResourceConfig] = Field(
538+
..., description="List of tools, context, mcp and escalation resources"
539+
)
540+
features: List[Any] = Field(default_factory=list, description="Agent feature list")
541+
settings: AgentSettings = Field(..., description="Agent settings")
540542

541-
class CodedAgentDefinition(BaseModel):
543+
model_config = ConfigDict(
544+
validate_by_name=True, validate_by_alias=True, extra="allow"
545+
)
546+
547+
548+
class CodedAgentDefinition(BaseAgentDefinition):
542549
"""Coded agent definition."""
543550

544-
pass
551+
type: Literal[AgentType.CODED] = AgentType.CODED
552+
553+
model_config = ConfigDict(
554+
validate_by_name=True, validate_by_alias=True, extra="allow"
555+
)
545556

546557

547558
KnownAgentDefinition = Annotated[

tests/agent/models/test_agent.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,13 @@ def test_agent_config_loads_unknown_agent_type(self):
4949
assert isinstance(config, UnknownAgentDefinition), (
5050
"AgentDefinition should be an unknown type."
5151
)
52-
assert config.id == "b2564199-e479-4b6f-9336-dc50f457afda"
53-
assert config.name == "Agent"
54-
assert config.version == "1.0.0"
52+
config_data = config.model_dump()
53+
assert config_data["id"] == "b2564199-e479-4b6f-9336-dc50f457afda"
54+
assert config_data["name"] == "Agent"
55+
assert config_data["version"] == "1.0.0"
5556

5657
# Validate resources
57-
assert len(config.resources) == 0
58+
assert len(config_data["resources"]) == 0
5859

5960
def test_agent_with_all_tool_types_loads(self):
6061
"""Test that AgentDefinition can load a complete agent package with all tool types"""

0 commit comments

Comments
 (0)