Skip to content

Commit 8135035

Browse files
Remove explicit version parameter from agent info (#120)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 9d93cc6 commit 8135035

File tree

5 files changed

+65
-51
lines changed

5 files changed

+65
-51
lines changed

tests/conftest.py

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Test fixtures for vlmrun tests."""
22

3+
import hashlib
34
import pytest
45
from typer.testing import CliRunner
56
from pydantic import BaseModel
@@ -474,26 +475,44 @@ class Agent:
474475
def __init__(self, client):
475476
self._client = client
476477

477-
def get(self, name=None, version=None, id=None):
478+
def get(self, name=None, id=None, prompt=None):
478479
from vlmrun.client.types import AgentInfo
479480
from datetime import datetime
480481

481-
if id and name:
482-
raise ValueError("Only one of `id` or `name` can be provided.")
483-
if not id and not name:
484-
raise ValueError("Either `id` or `name` must be provided.")
482+
if id:
483+
if name or prompt:
484+
raise ValueError(
485+
"Only one of `id` or `name` or `prompt` can be provided."
486+
)
487+
elif name:
488+
if id or prompt:
489+
raise ValueError(
490+
"Only one of `id` or `name` or `prompt` can be provided."
491+
)
492+
elif prompt:
493+
if id or name:
494+
raise ValueError(
495+
"Only one of `id` or `name` or `prompt` can be provided."
496+
)
497+
else:
498+
raise ValueError(
499+
"Either `id` or `name` or `prompt` must be provided."
500+
)
485501

486502
if id:
487503
agent_id = id
488504
agent_name = f"agent-{id}"
489-
else:
490-
agent_id = f"agent-{name}-{version or 'latest'}"
505+
elif name:
506+
agent_id = f"agent-{name}"
491507
agent_name = name
508+
elif prompt:
509+
hash_prompt = hashlib.sha256(prompt.encode()).hexdigest()
510+
agent_id = f"agent-{hash_prompt}"
511+
agent_name = f"agent-{hash_prompt}"
492512

493513
return AgentInfo(
494514
id=agent_id,
495515
name=agent_name,
496-
version=version or "latest",
497516
description="Test agent description",
498517
prompt="Test agent prompt",
499518
json_schema={
@@ -513,8 +532,7 @@ def list(self):
513532
return [
514533
AgentInfo(
515534
id="agent-1",
516-
name="test-agent-1",
517-
version="1.0.0",
535+
name="test-agent-1:1.0.0",
518536
description="First test agent",
519537
prompt="Test prompt 1",
520538
json_schema={
@@ -528,8 +546,7 @@ def list(self):
528546
),
529547
AgentInfo(
530548
id="agent-2",
531-
name="test-agent-2",
532-
version="2.0.0",
549+
name="test-agent-2:2.0.0",
533550
description="Second test agent",
534551
prompt="Test prompt 2",
535552
json_schema={
@@ -554,8 +571,7 @@ def create(self, config, name=None, inputs=None, callback_url=None):
554571

555572
return AgentCreationResponse(
556573
id=f"agent-{name or 'created'}",
557-
name=name or "created-agent",
558-
version="1.0.0",
574+
name=name or "created-agent:1.0.0",
559575
created_at=datetime.fromisoformat("2024-01-01T00:00:00+00:00"),
560576
updated_at=datetime.fromisoformat("2024-01-01T00:00:00+00:00"),
561577
status="pending",
@@ -564,7 +580,6 @@ def create(self, config, name=None, inputs=None, callback_url=None):
564580
def execute(
565581
self,
566582
name,
567-
version=None,
568583
inputs=None,
569584
batch=True,
570585
config=None,
@@ -582,7 +597,6 @@ def execute(
582597
return AgentExecutionResponse(
583598
id=f"execution-{name}",
584599
name=name,
585-
version=version or "latest",
586600
status="completed",
587601
created_at=datetime.fromisoformat("2024-01-01T00:00:00+00:00"),
588602
completed_at=datetime.fromisoformat("2024-01-01T00:00:01+00:00"),

tests/test_agent.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ def test_agent_creation_response_creation(self):
1919
"""Test creating an AgentCreationResponse instance."""
2020
response_data = {
2121
"id": "test-agent-123",
22-
"name": "Test Agent",
23-
"version": "1.0.0",
22+
"name": "test-agent:1.0.0",
2423
"created_at": datetime.now(),
2524
"updated_at": datetime.now(),
2625
"status": "completed",
@@ -29,8 +28,7 @@ def test_agent_creation_response_creation(self):
2928
response = AgentCreationResponse(**response_data)
3029

3130
assert response.id == "test-agent-123"
32-
assert response.name == "Test Agent"
33-
assert response.version == "1.0.0"
31+
assert response.name == "test-agent:1.0.0"
3432
assert response.status == "completed"
3533

3634

@@ -40,11 +38,10 @@ class TestAgentMethods:
4038
def test_agent_get_by_name_and_version(self, mock_client):
4139
"""Test getting an agent by name and version."""
4240
client = mock_client
43-
response = client.agent.get(name="test-agent", version="1.0.0")
41+
response = client.agent.get(name="test-agent:1.0.0")
4442

4543
assert isinstance(response, AgentInfo)
46-
assert response.name == "test-agent"
47-
assert response.version == "1.0.0"
44+
assert response.name == "test-agent:1.0.0"
4845
assert response.description == "Test agent description"
4946
assert response.prompt == "Test agent prompt"
5047
assert response.status == "completed"
@@ -57,18 +54,19 @@ def test_agent_get_by_id(self, mock_client):
5754
assert isinstance(response, AgentInfo)
5855
assert response.id == "agent-123"
5956
assert response.name == "agent-agent-123"
60-
assert response.version == "latest"
6157

6258
def test_agent_get_validation_error(self, mock_client):
6359
"""Test that get method validates input parameters."""
6460
client = mock_client
6561

6662
with pytest.raises(
67-
ValueError, match="Only one of `id` or `name` can be provided."
63+
ValueError, match="Only one of `id` or `name` or `prompt` can be provided."
6864
):
6965
client.agent.get(id="agent-123", name="test-agent")
7066

71-
with pytest.raises(ValueError, match="Either `id` or `name` must be provided."):
67+
with pytest.raises(
68+
ValueError, match="Either `id` or `name` or `prompt` must be provided."
69+
):
7270
client.agent.get()
7371

7472
def test_agent_list(self, mock_client):
@@ -79,8 +77,8 @@ def test_agent_list(self, mock_client):
7977
assert isinstance(response, list)
8078
assert len(response) == 2
8179
assert all(isinstance(agent, AgentInfo) for agent in response)
82-
assert response[0].name == "test-agent-1"
83-
assert response[1].name == "test-agent-2"
80+
assert response[0].name.startswith("test-agent-1")
81+
assert response[1].name.startswith("test-agent-2")
8482

8583
def test_agent_create(self, mock_client):
8684
"""Test creating an agent."""
@@ -99,7 +97,6 @@ def test_agent_create(self, mock_client):
9997

10098
assert isinstance(response, AgentCreationResponse)
10199
assert response.name == "new-agent"
102-
assert response.version == "1.0.0"
103100
assert response.status == "pending"
104101

105102
def test_agent_create_validation_error(self, mock_client):
@@ -125,15 +122,13 @@ def test_agent_execute(self, mock_client):
125122
)
126123

127124
response = client.agent.execute(
128-
name="test-agent",
129-
version="1.0.0",
125+
name="test-agent:1.0.0",
130126
inputs={"input": "test data"},
131127
config=config,
132128
)
133129

134130
assert isinstance(response, AgentExecutionResponse)
135-
assert response.name == "test-agent"
136-
assert response.version == "1.0.0"
131+
assert response.name == "test-agent:1.0.0"
137132
assert response.status == "completed"
138133
assert response.response == {"result": "execution result"}
139134
assert isinstance(response.usage, CreditUsage)
@@ -147,7 +142,6 @@ def test_agent_execute_without_version(self, mock_client):
147142

148143
assert isinstance(response, AgentExecutionResponse)
149144
assert response.name == "test-agent"
150-
assert response.version == "latest"
151145

152146
def test_agent_execute_batch_mode_required(self, mock_client):
153147
"""Test that execute method requires batch mode."""

vlmrun/client/agent.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,42 @@ def __init__(self, client: "VLMRunProtocol") -> None:
3030
def get(
3131
self,
3232
name: str | None = None,
33-
version: str | None = None,
3433
id: str | None = None,
34+
prompt: str | None = None,
3535
) -> AgentInfo:
36-
"""Get an agent by name and version.
36+
"""Get an agent by name, id, or prompt. Only one of `name`, `id`, or `prompt` can be provided.
3737
3838
Args:
39-
name: Name of the agent (lookup either by name + version or by id alone)
40-
version: Version of the agent
39+
name: Name of the agent
4140
id: ID of the agent
41+
prompt: Prompt of the agent
4242
4343
Raises:
4444
APIError: If the agent is not found (404) or the agent name is invalid (400)
4545
4646
Returns:
4747
AgentInfo: Agent information response
4848
"""
49-
if id and name:
50-
raise ValueError("Only one of `id` or `name` can be provided.")
51-
elif id is not None:
49+
if id:
50+
if name or prompt:
51+
raise ValueError(
52+
"Only one of `id` or `name` or `prompt` can be provided."
53+
)
5254
data = {"id": id}
53-
elif name is not None:
54-
data = {"name": name, "version": version}
55+
elif name:
56+
if id or prompt:
57+
raise ValueError(
58+
"Only one of `id` or `name` or `prompt` can be provided."
59+
)
60+
data = {"name": name}
61+
elif prompt:
62+
if id or name:
63+
raise ValueError(
64+
"Only one of `id` or `name` or `prompt` can be provided."
65+
)
66+
data = {"prompt": prompt}
5567
else:
56-
raise ValueError("Either `id` or `name` must be provided.")
68+
raise ValueError("Either `id` or `name` or `prompt` must be provided.")
5769

5870
response, status_code, headers = self._requestor.request(
5971
method="GET",
@@ -124,7 +136,6 @@ def create(
124136
def execute(
125137
self,
126138
name: str | None = None,
127-
version: str | None = None,
128139
inputs: Optional[dict[str, Any]] = None,
129140
batch: bool = True,
130141
config: Optional[AgentExecutionConfig] = None,
@@ -135,7 +146,6 @@ def execute(
135146
136147
Args:
137148
name: Name of the agent to execute. If not provided, we use the prompt to identify the unique agent.
138-
version: Optional version of the agent to execute
139149
inputs: Optional inputs to the agent
140150
batch: Whether to process in batch mode (async)
141151
config: Optional agent execution configuration
@@ -150,7 +160,6 @@ def execute(
150160

151161
data = {
152162
"name": name,
153-
"version": version,
154163
"batch": batch,
155164
"inputs": inputs,
156165
}

vlmrun/client/types.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ class AgentExecutionResponse(BaseModel):
189189

190190
id: str = Field(..., description="ID of the agent")
191191
name: str = Field(..., description="Name of the agent")
192-
version: str = Field(..., description="Version of the agent.")
193192
created_at: datetime = Field(
194193
..., description="Date and time when the agent was created (in UTC timezone)"
195194
)
@@ -259,7 +258,6 @@ class AgentExecutionConfig(AgentExecutionOrCreationConfig):
259258
class AgentInfo(BaseModel):
260259
id: str = Field(..., description="ID of the agent")
261260
name: str = Field(..., description="Name of the agent")
262-
version: str = Field(..., description="Version of the agent.")
263261
description: str = Field(..., description="Description of the agent")
264262
prompt: str = Field(..., description="The prompt of the agent")
265263
json_schema: Optional[Dict[str, Any]] = Field(
@@ -280,7 +278,6 @@ class AgentInfo(BaseModel):
280278
class AgentCreationResponse(BaseModel):
281279
id: str = Field(..., description="ID of the agent")
282280
name: str = Field(..., description="Name of the agent")
283-
version: str = Field(..., description="Version of the agent.")
284281
created_at: datetime = Field(
285282
..., description="Date and time when the agent was created (in UTC timezone)"
286283
)

vlmrun/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.3.2"
1+
__version__ = "0.3.3"

0 commit comments

Comments
 (0)