Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/src/opendirector/agent/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"',
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/opendirector/agent/pi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
)

Expand Down
12 changes: 12 additions & 0 deletions packages/core/src/opendirector/agent/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
2 changes: 2 additions & 0 deletions tests/test_pi_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
Loading