hylo.codeagents.prompt¶
Package: hylo-code-agents · Core contracts
prompt ¶
What code-writing models are told: the robot, the toolkit's API, the rules, and the feedback after each block.
Task-agnostic: the robot comes from RobotSpec, the API from the toolkit itself (hylo.manip.api_reference, else the Tools signatures and docstrings), the task from the instruction. No task names, no success signal.
RULES
module-attribute
¶
RULES = "How to work:\n- Reply with a short thought, then exactly ONE fenced block: ```python ... ```. It runs as soon as you send it; you\n see what it printed, any error, and the robot's status, then you write the next block. There are no tools or\n functions to call through the chat: write the code as text in your reply, inside the fence.\n- Variables, functions and imports persist between blocks. Preloaded: `robot` (the toolkit), `np` (numpy), `math`.\n The only imports allowed are math and numpy. No files, no network, no class definitions, no names that start\n with an underscore.\n- Each block may compute for at most {block_s:g} s; time the robot spends moving is not counted.\n- Every turn is one model call, which can be slow: when you are confident, do several steps in one block (perceive,\n plan, run a motion, check it) and print what you need to verify.\n- `robot.run(plan)` is the only call that moves the robot: it returns when the motion is done. The simulation is\n paused while you think, so take the time you need.\n- print() what you need to see: values you do not print are not shown to you.{vision}"
VISION
module-attribute
¶
VISION = '\n- `robot.show(view_or_image, note)` attaches an image you will see with the next feedback.'
NO_VISION
module-attribute
¶
extract_code ¶
The first fenced Python block of a reply, and how many blocks there were.
compact ¶
A short JSON-ish rendering of a status dict (numbers rounded, arrays as lists).
api_reference ¶
The toolkit's reference, after what the toolkit says about itself first (tools.extra_reference(), e.g.
privileged verbs).
toolkit_reference ¶
The toolkit's own reference (hylo.manip.api_reference) or, until it exists, signatures and docstrings.
code_llm_system ¶
code_llm_system(*, robot: str, api: str, block_s: float, vision: bool, skills: str = '', demonstration: str | None = None) -> str
task_message ¶
task_message(instruction: str, status: Mapping[str, Any], budget: Mapping[str, Any], scene: str = '') -> str
scene_preview ¶
What the first message says about the scene before any block ran: the segment labels the environment gives (if any) and, for a vision model, the cameras side by side. Saves the model a turn spent only looking.
feedback ¶
feedback(*, code: str | None, n_blocks: int, output: str, error: str | None, status: Mapping[str, Any] | None, images: Sequence[Mapping[str, Any]], vision: bool, remaining: Mapping[str, Any], seconds: float = 0.0) -> str