Skip to content

Self-hosted AI workspace.

Python

fix(routing): recognize multilingual media workflows

pewdiepie-archdaemondc26daadf116
diff --git a/src/turn_contract.py b/src/turn_contract.py
index 63f89a200..699c86871 100644
--- a/src/turn_contract.py
+++ b/src/turn_contract.py
@@ -4158,8 +4158,9 @@ def requested_capabilities(message: str, history: Iterable = (), *, active_docum
re.I,
)
media_action = re.search(
- r"\b(?:inspect|view|study|look\s+at|analy[sz]e|read|transcribe|caption|"
- r"recreate|reproduce|identify|describe|extract)\b",
+ r"\b(?:inspect|view|watch|study|look\s+at|analy[sz]e|read|transcribe|caption|"
+ r"recreate|reproduce|identify|describe|extract)\b|"
+ r"(?:浏览|查看|观看|分析|检查|识别|转录|截图)",
raw_text,
re.I,
)
@@ -4177,9 +4178,15 @@ def requested_capabilities(message: str, history: Iterable = (), *, active_docum
primary_media_family = "media_inspection"
families = {primary_media_family}
if (
- re.search(r"\b(?:create|write|save|build|implement|produce|recreate|reproduce)\b", raw_text, re.I)
+ re.search(
+ r"\b(?:create|write|save|build|implement|produce|recreate|reproduce)\b|"
+ r"(?:创建|写入|保存|生成|输出|拼成|制作)",
+ raw_text,
+ re.I,
+ )
and re.search(
- r"(?:file://)?/workspace/[^\s`\"']+\.(?:csv|html?|json|md|svg|txt)\b",
+ r"(?:file://)?/workspace/(?!input/)[^\s`\"']+\."
+ r"(?:csv|html?|json|md|svg|txt|avif|bmp|gif|jpe?g|png|webp|pdf|mp4|webm)\b",
raw_text,
re.I,
)
diff --git a/tests/test_turn_contract.py b/tests/test_turn_contract.py
index 492ddcb2b..2c9079d3b 100644
--- a/tests/test_turn_contract.py
+++ b/tests/test_turn_contract.py
@@ -4286,3 +4286,17 @@ def test_explicit_personal_note_action_survives_media_workflow_sealing():
"Inspect /workspace/input/score.png, then save a note in my notes called "
"Practice Review with the musical details."
) == {"media_inspection", "notes"}
+
+
+def test_watch_workspace_video_is_media_not_generic_shell():
+ assert requested_capabilities(
+ "Watch the entire match in /workspace/input/video.mp4 and count how many "
+ "points Bob won. Return a JSON object in the final answer."
+ ) == {"media_inspection"}
+
+
+def test_chinese_video_to_image_artifact_keeps_media_and_workspace_tools():
+ assert requested_capabilities(
+ "请完整浏览 /workspace/input/video.mp4,为每款零食截图并拼成清单图,"
+ "输出到 /workspace/snack_checklist.jpg,交付前打开成品图检查。"
+ ) == {"media_inspection", "shell_files"}