hylo.codeagents.session¶
Package: hylo-code-agents · Core contracts
session ¶
Tool sessions (RFC-0008 part 7): a chat model works with any registered tool surface (group hylo.surfaces) on
a request, outside an episode: build a scene, run robots in it, record data.
hylo world chat "put a Go1 on the floor next to a table with a red cube and walk it 1 m forward" \
[--stage lab] [--root runs/stages] [--model ollama:qwen3.5:35b-a3b] [--vision] [--out runs/world-chat]
hylo world chat (no request: read requests from the terminal, one session that remembers)
hylo world tools the tool manual of the surface
The loop is the one of tools.llm without an environment: every model call sends the projected conversation
(tool_context) and every tool; read calls of a reply run first, then act calls in order (each tool checks its own
preconditions: stage revisions, world generations); after any act the after_act read tool (the world's free
view) is called so a vision model sees the result. Events go to a hash-chained trace (hylo watch OUT follows it):
agent.tool.start / turn / result / operator / summary. An inbox file lets a person steer the session.
WORLD_SYSTEM
module-attribute
¶
WORLD_SYSTEM = 'You work in a 3D robotics workspace through tools: a stage (the scene as entities, edited by\npatches with revisions) and a MuJoCo world built from it (robots from packs, cameras, people), which you run with\nactions and check with predicates.\n\nHow to work:\n- Read before you write: stage_show gives the revision stage_edit needs; world_state gives the generation every\n robot action needs. A conflict or a stale refusal means: read again, then retry.\n- Edits change the stage, not the running world: call world_build after editing, then act.\n- Build scenes in metres, +z up, the floor at z = 0. A box\'s size is its half extents. A table top at height h with\n half thickness t has its centre at z = h - t. Put objects on surfaces (centre z = surface + half height).\n- Robots come from packs (packs tool): check a pack\'s controls before choosing actions. Arms move their tool point\n with tcp actions; grasp from above: move above the object, descend, close the gripper, lift.\n- stage_edit ops is a JSON array, never a JSON-encoded string. Keep patches small (up to six operations) and use\n the revision returned by each patch for the next one. Robot fields are nested, for example an add operation:\n {"op":"add","entity":{"id":"arm","pose":{"pos":[0,0,0]},"robot":{"pack":"panda","base":"fixed"}}}.\n Shapes likewise use pose.pos and shape {type,size,rgba}; kind, pack and pos are not top-level entity fields.\n On a validation error, correct the fields named by the error; do not repeat the same invalid arguments.\n- Look at the result (view or capture) and check goals with check: a receipt says what the robot did, a check says\n whether the goal holds. Report what you measured.\n- Do one thing at a time and keep replies short; finish with a summary of what exists and what was verified.'
ToolSession ¶
ToolSession(model: ChatModel, surface: Surface, *, system: str = WORLD_SYSTEM, out: str | Path = 'runs/session', inbox: str | None = None, after_act: str | None = 'view', max_calls: int = 60, reply_tokens: int = 4096, max_cost_usd: float | None = None, context: Mapping[str, Any] | None = None, emit: Callable[[str, Mapping[str, Any]], None] | None = None, printer: Callable[[str], None] | None = None)
id
instance-attribute
¶
ctx
instance-attribute
¶
ctx = ToolContext(system, '', summarize=self._summarize, **{'tail_decisions': 4, 'image_decisions': 1, 'inline_chars': 2500, 'compact_tokens': 60000, **dict(context or {})})
ask ¶
Work on one request until the model answers without tool calls (or a budget runs out); its last words.
main ¶
a chat model builds and runs a robot world (chat), or list the world tools (tools)