diff --git a/packages/core/src/opendirector/agent/native.py b/packages/core/src/opendirector/agent/native.py index e00427394..5b23f3c5c 100644 --- a/packages/core/src/opendirector/agent/native.py +++ b/packages/core/src/opendirector/agent/native.py @@ -19,7 +19,7 @@ from opendirector.agent.citations import search_sources from opendirector.agent.gateway import ToolGateway from opendirector.agent.process import terminate -from opendirector.agent.tools import ROOT, SUGGESTED_REPLIES, SYSTEM +from opendirector.agent.tools import ROOT, SUGGESTED_REPLIES, SYSTEM, runtime_instructions from opendirector.installation import BUNDLED from opendirector.agent.skill_snapshot import prepare_skills from opendirector.agent.directory_links import link_directory, unlink_directory @@ -126,7 +126,7 @@ def command(runtime: str, work: Path, socket: str, token: str, model: str | None return args, env if runtime == 'pi': args = pi.command(binary, session_dir=work.parent.parent / 'pi-sessions' / 'native', - system=SYSTEM, model=model) + system=runtime_instructions(runtime), model=model) return args, env if runtime == 'codex': settings = ['features.shell_tool=true', 'features.apply_patch_freeform=false', 'web_search="disabled"', diff --git a/packages/core/src/opendirector/agent/pi.py b/packages/core/src/opendirector/agent/pi.py index fc8c53341..ae2891d5a 100644 --- a/packages/core/src/opendirector/agent/pi.py +++ b/packages/core/src/opendirector/agent/pi.py @@ -13,8 +13,7 @@ 'Video creation work belongs to the OpenDirector project: change it only through the ' 'opendirector command on PATH, never by editing project storage directly. ' 'Pass --operation-id to every command that changes project content.\n' - 'This runtime accepts text and images only. Read images with the read tool and obtain ' - 'video frames, audio or other media facts through project media commands before ' + 'This runtime accepts text and images only. Obtain audio and other media facts through project media commands before ' 'describing them; never claim to have watched a video or heard audio.' ) diff --git a/packages/core/src/opendirector/agent/tools.py b/packages/core/src/opendirector/agent/tools.py index a3610de92..150487756 100644 --- a/packages/core/src/opendirector/agent/tools.py +++ b/packages/core/src/opendirector/agent/tools.py @@ -95,6 +95,18 @@ def query_guidance(failure): ) +def runtime_instructions(runtime: str) -> str: + if runtime == 'pi': + return SYSTEM + ( + 'For local visual inspection, use the native read tool on image files. ' + 'Extract video frames into the execution directory with FFmpeg before reading them. ' + 'If read cannot recognize an extensionless image, make a PNG inspection copy in the execution directory ' + 'and read the copy. Keep the source file untouched. ' + 'If the selected model does not receive visual content, report that limitation.\n' + ) + return SYSTEM + + def tool_schema(name: str, description: str, parameters: dict) -> dict: assert description.strip(), f'Missing tool metadata: {name}' return {'type': 'function', 'function': {'name': name, 'description': description, 'parameters': parameters}} diff --git a/tests/test_pi_runtime.py b/tests/test_pi_runtime.py index 40d8b17b4..0dcf6b358 100644 --- a/tests/test_pi_runtime.py +++ b/tests/test_pi_runtime.py @@ -173,6 +173,8 @@ def test_turn_streams_argv_and_finalizes_text_once(cli, tmp_path): assert '--thinking' not in argv system = argv[argv.index('--append-system-prompt') + 1] assert 'opendirector' in system and 'text and images only' in system + assert 'use the native read tool on image files' in system + assert 'PNG inspection copy' in system assert record['session_dir_exists'] assert Path(argv[argv.index('--session-dir') + 1]).name == 'native' assert 'Make a video' in record['prompt']