hylo.codeagents.bridge¶
Package: hylo-code-agents · Core contracts
bridge ¶
The toolkit's Executor on top of the kernel (RFC-0006 part 4): a program moves the robot only through the kernel.
Two threads meet here. The kernel thread calls the agent (act, on_step, on_episode_end); the program thread
(a model's turns, or a frozen solve(robot)) calls the Executor (observation, run, status) and finish:
program: robot.run(plan) -> bridge.run(actions) ---- posts a chunk, blocks ------------------+
kernel: act(obs) blocks until a chunk is posted, returns it -> SafetyShield -> env.step x T |
act(obs) again (the queue is empty): the chunk is done -> wakes the program <-------+
program: finish() -> a chunk marked END_EPISODE -> the kernel ends the episode ("agent_done")
While the program computes (or the model thinks) the kernel is blocked in act(): simulation time does not pass, and
a robot runner holds. A chunk cut short (the shield modified an action and the kernel dropped the rest) wakes the
program with interrupted: true. When the episode ends for any reason (task terminated, max_steps, an error, the
operator), on_episode_end wakes the program: every later run() returns at once with ended: true. Needs the
kernel's sync timing (realtime mode asks for chunks before the last one finished).
EpisodeBridge ¶
EpisodeBridge(env_spec: EnvSpec, task: TaskInstance, *, expose_success: bool = False, act_wait_s: float = 1800.0)
One episode's handoff between the kernel thread and the program thread. Implements hylo.manip.Executor.
cancel ¶
Unblock both sides for good (shutdown): the kernel gets an END_EPISODE chunk, the program ended.
wait_ready ¶
Block until the kernel has the first observation (it is waiting in act) or the episode ended.
finish ¶
End the episode (END_EPISODE) and block until the kernel has ended it; returns the outcome record.
TimedExecutor ¶
LiveExecutor ¶
BridgeAgent ¶
BridgeAgent(bridge: EpisodeBridge, name: str = 'code.research', components: Mapping[str, str] | None = None)
An Agent that is nothing but a bridge: the program runs elsewhere (a research session's model loop).