refactor: use a single agent model path
This commit is contained in:
@@ -69,12 +69,11 @@ class StubHandler(BaseHTTPRequestHandler):
|
||||
available_names = {
|
||||
str((tool.get("function") or {}).get("name", "")) for tool in tools if isinstance(tool, dict)
|
||||
}
|
||||
is_work = "update_plan" in available_names
|
||||
is_agent = "update_plan" in available_names
|
||||
|
||||
if tools and not has_tool_result:
|
||||
path = "work-proof.txt" if is_work else "chat-proof.txt"
|
||||
arguments = json.dumps(
|
||||
{"path": path, "content": _last_user_text(messages) or "e2e"},
|
||||
{"path": "work-proof.txt", "content": _last_user_text(messages) or "e2e"},
|
||||
ensure_ascii=False,
|
||||
)
|
||||
message = {
|
||||
@@ -91,7 +90,7 @@ class StubHandler(BaseHTTPRequestHandler):
|
||||
self._respond(payload, _completion(model, message, "tool_calls"))
|
||||
return
|
||||
|
||||
if is_work and "write_file" in called_tools and "read_file" not in called_tools:
|
||||
if is_agent and "write_file" in called_tools and "read_file" not in called_tools:
|
||||
message = {
|
||||
"role": "assistant",
|
||||
"content": None,
|
||||
|
||||
+24
-36
@@ -26,14 +26,10 @@ INTERNAL_PROVIDER_KEY = os.getenv(
|
||||
"e2e-provider-secret-at-least-32-bytes",
|
||||
)
|
||||
EXPECTED_MODELS = {
|
||||
"chat-light",
|
||||
"chat-medium",
|
||||
"chat-high",
|
||||
"chat-extreme",
|
||||
"work-light",
|
||||
"work-medium",
|
||||
"work-high",
|
||||
"work-extreme",
|
||||
"luna",
|
||||
"terra",
|
||||
"sol",
|
||||
"deepseek-v4-pro",
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +52,6 @@ def _stream_chat(
|
||||
model: str,
|
||||
chat_id: str,
|
||||
prompt: str,
|
||||
include_workspace_tools: bool,
|
||||
) -> tuple[int, str]:
|
||||
user_message_id = uuid.uuid4().hex
|
||||
assistant_message_id = uuid.uuid4().hex
|
||||
@@ -75,11 +70,9 @@ def _stream_chat(
|
||||
"content": prompt,
|
||||
"timestamp": int(time.time()),
|
||||
},
|
||||
"params": {"function_calling": "native"},
|
||||
"params": {},
|
||||
"features": {},
|
||||
}
|
||||
if include_workspace_tools:
|
||||
payload["tool_ids"] = ["server:workspace"]
|
||||
with client.stream(
|
||||
"POST",
|
||||
"/api/chat/completions",
|
||||
@@ -208,37 +201,25 @@ def main() -> None:
|
||||
|
||||
chat_ids = [f"local:e2e-{suffix}-a", f"local:e2e-{suffix}-b"]
|
||||
for index, user in enumerate(users):
|
||||
marker = f"E2E_CHAT_USER_{index}_{suffix}"
|
||||
marker = f"E2E_AGENT_USER_{index}_{suffix}"
|
||||
status_code, body = _stream_chat(
|
||||
client,
|
||||
user["token"],
|
||||
model="chat-light",
|
||||
model="luna" if index == 0 else "terra",
|
||||
chat_id=chat_ids[index],
|
||||
prompt=marker,
|
||||
include_workspace_tools=True,
|
||||
)
|
||||
assert status_code == 200, body
|
||||
|
||||
docker_client = docker.from_env()
|
||||
assert _workspace_file(docker_client, users[0]["id"], "chat-proof.txt") == f"E2E_CHAT_USER_0_{suffix}"
|
||||
assert _workspace_file(docker_client, users[1]["id"], "chat-proof.txt") == f"E2E_CHAT_USER_1_{suffix}"
|
||||
assert _workspace_file(docker_client, users[0]["id"], "work-proof.txt") == f"E2E_AGENT_USER_0_{suffix}"
|
||||
assert _workspace_file(docker_client, users[1]["id"], "work-proof.txt") == f"E2E_AGENT_USER_1_{suffix}"
|
||||
for user in users:
|
||||
ref = workspace_ref(user["id"])
|
||||
workspace = docker_client.containers.get(ref.container_name)
|
||||
workspace.reload()
|
||||
assert set(workspace.attrs["NetworkSettings"]["Networks"]) == {ref.network_name}
|
||||
|
||||
work_marker = f"E2E_WORK_USER_0_{suffix}"
|
||||
status_code, work_body = _stream_chat(
|
||||
client,
|
||||
users[0]["token"],
|
||||
model="work-medium",
|
||||
chat_id=chat_ids[0],
|
||||
prompt=work_marker,
|
||||
include_workspace_tools=False,
|
||||
)
|
||||
assert status_code == 200, work_body
|
||||
assert _workspace_file(docker_client, users[0]["id"], "work-proof.txt") == work_marker
|
||||
listing = client.get(
|
||||
"/api/v1/k1412/workspace/files",
|
||||
headers=_auth(users[0]["token"]),
|
||||
@@ -252,14 +233,21 @@ def main() -> None:
|
||||
params={"path": "work-proof.txt"},
|
||||
)
|
||||
download.raise_for_status()
|
||||
assert download.text == work_marker
|
||||
assert download.text == f"E2E_AGENT_USER_0_{suffix}"
|
||||
isolated_listing = client.get(
|
||||
"/api/v1/k1412/workspace/files",
|
||||
headers=_auth(users[1]["token"]),
|
||||
params={"path": "."},
|
||||
)
|
||||
isolated_listing.raise_for_status()
|
||||
assert "work-proof.txt" not in {item["name"] for item in isolated_listing.json()["entries"]}
|
||||
assert "work-proof.txt" in {item["name"] for item in isolated_listing.json()["entries"]}
|
||||
isolated_download = client.get(
|
||||
"/api/v1/k1412/workspace/download",
|
||||
headers=_auth(users[1]["token"]),
|
||||
params={"path": "work-proof.txt"},
|
||||
)
|
||||
isolated_download.raise_for_status()
|
||||
assert isolated_download.text == f"E2E_AGENT_USER_1_{suffix}"
|
||||
archive = client.get(
|
||||
"/api/v1/k1412/workspace/archive",
|
||||
headers=_auth(users[0]["token"]),
|
||||
@@ -276,20 +264,20 @@ def main() -> None:
|
||||
event_types = {event["type"] for event in events.json()["items"]}
|
||||
assert {"run.created", "tool.completed", "run.completed"} <= event_types
|
||||
|
||||
downgrade = runtime.post(
|
||||
legacy = runtime.post(
|
||||
"/v1/chat/completions",
|
||||
headers=runtime_headers,
|
||||
json={
|
||||
"model": "chat-high",
|
||||
"messages": [{"role": "user", "content": "THIS_DOWNGRADE_MUST_FAIL"}],
|
||||
"model": "work-high",
|
||||
"messages": [{"role": "user", "content": "LEGACY_MODEL_MUST_FAIL"}],
|
||||
"stream": False,
|
||||
},
|
||||
)
|
||||
assert downgrade.status_code == 409, downgrade.text
|
||||
assert legacy.status_code == 404, legacy.text
|
||||
|
||||
print(
|
||||
"E2E passed: auth approval, eight models, Chat tools, Work evidence, file downloads, "
|
||||
"isolation, and downgrade lock."
|
||||
"E2E passed: auth approval, four Agent models, custom loop evidence, file downloads, "
|
||||
"and per-user workspace isolation."
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user