Skip to content

Commit aaba4fb

Browse files
committed
test(studio): cover byteplus agent loop runtimes
1 parent 859914f commit aaba4fb

2 files changed

Lines changed: 145 additions & 0 deletions

File tree

frontend/tests/agentRuntimeDraft.test.mjs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,77 @@ test("legacy runtime graph restores LLM agent loop runtime metadata", () => {
119119
assert.equal(restored.subAgents[0].runtime, "codex");
120120
assert.equal(restored.subAgents[1].runtime, "piagent");
121121
});
122+
123+
test("byteplus runtime metadata survives YAML and cloud graph recovery", () => {
124+
const draft = normalizeDraft({
125+
name: "byteplus_runtime_root",
126+
cloudProvider: "byteplus",
127+
description: "Runtime root",
128+
instruction: "Coordinate work.",
129+
agentType: "loop",
130+
subAgents: [
131+
{
132+
name: "coder",
133+
cloudProvider: "byteplus",
134+
description: "Writes code",
135+
instruction: "Edit code.",
136+
agentType: "llm",
137+
runtime: "codex",
138+
},
139+
{
140+
name: "operator",
141+
cloudProvider: "byteplus",
142+
description: "Runs tasks",
143+
instruction: "Run tasks.",
144+
agentType: "llm",
145+
runtime: "piagent",
146+
},
147+
],
148+
});
149+
150+
const yaml = draftToYaml(draft, {
151+
heading: "Test",
152+
importHint: "Import again.",
153+
});
154+
assert.match(yaml, /runtime: codex/);
155+
assert.match(yaml, /runtime: piagent/);
156+
157+
const restoredFromYaml = yamlToDraft(yaml);
158+
assert.equal(restoredFromYaml.runtime, "adk");
159+
assert.equal(restoredFromYaml.subAgents[0].runtime, "codex");
160+
assert.equal(restoredFromYaml.subAgents[1].runtime, "piagent");
161+
162+
const restoredFromCloud = runtimeAgentDraftFromCloud(
163+
{
164+
appName: "byteplus_runtime_root",
165+
graph: {
166+
name: "byteplus_runtime_root",
167+
type: "loop",
168+
children: [
169+
{
170+
name: "coder",
171+
type: "llm",
172+
runtime: "codex",
173+
model: "openai/gpt-5-codex",
174+
children: [],
175+
},
176+
{
177+
name: "operator",
178+
type: "llm",
179+
runtime: "piagent",
180+
model: "openai/gpt-5",
181+
children: [],
182+
},
183+
],
184+
},
185+
},
186+
"byteplus",
187+
);
188+
189+
assert.equal(restoredFromCloud.cloudProvider, "byteplus");
190+
assert.equal(restoredFromCloud.runtime, "adk");
191+
assert.equal(restoredFromCloud.subAgents[0].cloudProvider, "byteplus");
192+
assert.equal(restoredFromCloud.subAgents[0].runtime, "codex");
193+
assert.equal(restoredFromCloud.subAgents[1].cloudProvider, "byteplus");
194+
assert.equal(restoredFromCloud.subAgents[1].runtime, "piagent");
195+
});

tests/cli/test_generated_agent_backend_codegen_extended.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,77 @@ def test_byteplus_piagent_dockerfile_prefers_official_github_then_mirror() -> No
484484
)
485485

486486

487+
def test_byteplus_codex_runtime_uses_byteplus_image_and_dependencies() -> None:
488+
project = generate_project_from_draft(
489+
AgentDraft(
490+
name="byteplus-codex",
491+
cloudProvider="byteplus",
492+
runtime="codex",
493+
)
494+
)
495+
files = _file_map(project)
496+
agent_py = files["agents/byteplus_codex/agent.py"]
497+
dockerfile = files["Dockerfile"]
498+
requirements = files["requirements.txt"]
499+
500+
assert dockerfile.startswith(
501+
"FROM agentkit-prod-public-ap-southeast-1.cr.bytepluses.com/"
502+
"base/py-simple:python3.12-bookworm-slim-latest"
503+
)
504+
assert "RUN uv pip install -r requirements.txt" in dockerfile
505+
assert "repo.huaweicloud.com" not in dockerfile
506+
assert 'runtime="codex"' in agent_py
507+
assert "'cloudProvider': 'byteplus'" in agent_py
508+
assert "'runtime': 'codex'" in agent_py
509+
assert "openai-codex==0.1.0b3" in requirements
510+
assert "openai-codex-cli-bin==0.137.0a4" in requirements
511+
512+
513+
def test_byteplus_loop_root_with_piagent_child_preinstalls_binary_and_disables_bff_tools() -> (
514+
None
515+
):
516+
project = generate_project_from_draft(
517+
AgentDraft(
518+
name="byteplus-loop",
519+
cloudProvider="byteplus",
520+
agentType="loop",
521+
subAgents=[
522+
AgentDraft(
523+
name="worker",
524+
cloudProvider="byteplus",
525+
instruction="Work.",
526+
runtime="piagent",
527+
)
528+
],
529+
)
530+
)
531+
files = _file_map(project)
532+
agent_py = files["agents/byteplus_loop/agent.py"]
533+
app_py = files["app.py"]
534+
dockerfile = files["Dockerfile"]
535+
536+
assert dockerfile.startswith(
537+
"FROM agentkit-prod-public-ap-southeast-1.cr.bytepluses.com/"
538+
"base/py-simple:python3.12-bookworm-slim-latest"
539+
)
540+
assert (
541+
'PIAGENT_BINARY_BASE_URLS="https://github.com/earendil-works/pi/releases/download '
542+
'https://ghfast.top/https://github.com/earendil-works/pi/releases/download"'
543+
in dockerfile
544+
)
545+
assert "ENV PIAGENT_BINARY=/opt/piagent/pi/pi" in dockerfile
546+
assert 'runtime="piagent"' in agent_py
547+
assert "'cloudProvider': 'byteplus'" in agent_py
548+
assert "'runtime': 'piagent'" in agent_py
549+
assert 'os.environ.setdefault("PIAGENT_BINARY", "/opt/piagent/pi/pi")' in app_py
550+
assert app_py.index('os.environ.setdefault("PIAGENT_BINARY"') < app_py.index(
551+
"from agents.byteplus_loop.agent import"
552+
)
553+
assert '"enable_studio_tools": True' in app_py
554+
assert 'if not hasattr(_root_tools, "append"):' in app_py
555+
assert '_app_options["enable_studio_tools"] = False' in app_py
556+
557+
487558
def test_codegen_disables_studio_bff_tools_for_toolless_orchestrator_root() -> None:
488559
project = generate_project_from_draft(
489560
AgentDraft(

0 commit comments

Comments
 (0)