HubClient
autogen.beta.network.client.hub_client.HubClient #
One connection to a hub. Multiple AgentClients register through it.
Takes a link factory (LocalLink in-process, WsLink over WebSocket) and an optional in-process hub reference. When the factory is a LocalLink its .hub is read automatically, so HubClient(LocalLink(hub)) and HubClient(LocalLink(hub), hub=hub) are equivalent. With no hub the client runs cross-process and routes control-plane calls through RequestFrame RPC.
A single tenant process should hold one HubClient per hub it connects to.
Source code in autogen/beta/network/client/hub_client.py
open async #
Open the underlying link (and start the receive loop). Idempotent.
For an in-process LocalLink this attaches the endpoint to the hub. For a WsLink it performs the WebSocket connect. Callers may rely on lazy connection (register / attach open on first use) or call this explicitly.
Source code in autogen/beta/network/client/hub_client.py
register async #
Register an agent and return its AgentClient handle.
In-process this is a direct hub call; cross-process it is a register RPC. Either way the resulting agent_id is bound to this connection's endpoint so dispatched NotifyFrames reach the right AgentClient.
attach_plugin=True (default) attaches the NetworkPlugin which adds say and delegate to agent.tools and appends NetworkContextPolicy to the assembly chain. Pass False for tests that need a bare agent without LLM tools.
Rejects passport.kind == "human" with a guidance error pointing at :meth:register_human.
Source code in autogen/beta/network/client/hub_client.py
attach async #
attach(agent, name, *, passport=None, resume=None, rule=None, skill_md=None, attach_plugin=True, since_envelope_id='')
Bind agent to the hub identity named name.
Reconnect-aware companion to :meth:register. If name is already registered the existing agent_id is re-bound to this connection (cross-process via a HelloFrame handshake that also replays unacked notifies past since_envelope_id; in-process via a direct re-bind). If name is not registered, falls back to :meth:register — passport and resume become required in that path.
since_envelope_id (cross-process only) is the reconnect high-water mark: "" (default) replays every notify the hub has not seen acked, None skips replay, a specific id replays strictly past it. In-process attach ignores it (the endpoint re-binds without replay).
Source code in autogen/beta/network/client/hub_client.py
register_human async #
Register a non-LLM participant and return its HumanClient handle.
Same UUID7-stamping + persistence path as register (direct in-process, register RPC cross-process); the passport's kind is forced to "human" so the participant is discoverable via list_agents(kind="human").
No Agent is attached, no plugin is installed. auto_ack_invites=True (default) makes the human auto-accept channel invites so adapter-driven handshakes complete without UI round-trips.
Source code in autogen/beta/network/client/hub_client.py
get_agent async #
Source code in autogen/beta/network/client/hub_client.py
get_resume async #
get_skill async #
find_agent_id #
Non-raising name → agent_id lookup.
In-process this hits the hub registry. Cross-process it reads the local name cache (populated as passports cross the wire); for an authoritative remote lookup use :meth:get_agent, which round-trips and raises :class:NotFoundError when absent.
Source code in autogen/beta/network/client/hub_client.py
get_rule async #
list_agents async #
Source code in autogen/beta/network/client/hub_client.py
set_resume async #
Source code in autogen/beta/network/client/hub_client.py
set_skill async #
Source code in autogen/beta/network/client/hub_client.py
set_rule async #
unregister_agent async #
create_channel async #
create_channel(*, creator_id, manifest_type, manifest_version=1, participants, required_acks=None, ttl=None, knobs=None, intent=None, labels=None)
Source code in autogen/beta/network/client/hub_client.py
get_channel async #
Source code in autogen/beta/network/client/hub_client.py
list_channels async #
Source code in autogen/beta/network/client/hub_client.py
close_channel async #
Source code in autogen/beta/network/client/hub_client.py
post_envelope async #
report_turn_failure async #
Report a notify-handler crash through the hub's observability surface.
The default notify handler calls this when the substantive path raises; the hub fans the failure out to every HubListener (including the built-in AuditLog). Cross-process the exception is carried as its string form (the original type is not reconstructed on the hub side).
Source code in autogen/beta/network/client/hub_client.py
fire_task_event async #
Fan out an on_task_event through the hub's listener chain.
Source code in autogen/beta/network/client/hub_client.py
read_wal async #
Source code in autogen/beta/network/client/hub_client.py
find_envelope_by_causation async #
Return the envelope a sender previously posted under this causation key, or None. The default notify handler uses this to skip work when an at-least-once redelivery re-triggers a turn it has already answered.
Source code in autogen/beta/network/client/hub_client.py
pending_turns_for async #
Return turns the protocol currently expects from agent_id.
Backs :meth:AgentClient.resume_pending_turns so the reconnect cycle works against an in-process or a remote hub identically.
Source code in autogen/beta/network/client/hub_client.py
can_send async #
Whether the adapter would accept a substantive send now.
Async because cross-process it is an authoritative round-trip to the hub (whose folded state is the source of truth); in-process it wraps the synchronous hub probe.
Source code in autogen/beta/network/client/hub_client.py
register_adapter #
Register a custom ChannelAdapter in the client-side registry.
Required cross-process for any non-built-in channel type, so the notify handler can resolve the adapter and fold state locally. In-process the hub's registry is authoritative; registering here too keeps the two in sync if both are consulted.
Source code in autogen/beta/network/client/hub_client.py
adapter_for_metadata #
Resolve the adapter for an already-fetched ChannelMetadata.
Synchronous — no I/O. In-process it delegates to the hub's authoritative registry; cross-process it looks up the client-side registry by manifest (type, version).
Source code in autogen/beta/network/client/hub_client.py
adapter_for #
Resolve the adapter for channel_id.
In-process delegates to the hub. Cross-process resolves from the metadata cache (populated by :meth:get_channel / :meth:create_channel); call one of those first if the channel has not been seen on this connection.
Source code in autogen/beta/network/client/hub_client.py
adapter_state async #
Return channel_id's folded adapter state, or None.
In-process this reads the hub's cached state. Cross-process it re-folds the state from the channel WAL via the client-side adapter — the same deterministic fold the hub runs on hydrate() — so the notify handler sees consistent state without shipping the (non-serialisable) state object over the wire.
Source code in autogen/beta/network/client/hub_client.py
default_view_policy #
Return the adapter-declared default view policy for a participant.
In-process delegates to the hub; cross-process resolves from the cached metadata + client-side adapter.
Source code in autogen/beta/network/client/hub_client.py
name_for #
Resolve agent_id to its registered name.
In-process reads the hub registry. Cross-process reads the local name cache (filled as passports / channel participants cross the wire); unknown ids fall back to default (or the id itself).
Source code in autogen/beta/network/client/hub_client.py
name_to_id_map #
Snapshot of the name → agent_id directory for reverse lookup.
Used by adapters that resolve target names to ids (e.g. the workflow adapter's handoff routing). In-process delegates to the hub; cross-process returns the local name cache.
Source code in autogen/beta/network/client/hub_client.py
get_task async #
list_tasks async #
Source code in autogen/beta/network/client/hub_client.py
observe_task async #
update_task async #
Source code in autogen/beta/network/client/hub_client.py
record_observation async #
Source code in autogen/beta/network/client/hub_client.py
checkpoint_task async #
Persist a task checkpoint through the hub's CheckpointStore path.
Source code in autogen/beta/network/client/hub_client.py
read_task_checkpoint async #
Read back a task checkpoint, or None if none is stored.
Source code in autogen/beta/network/client/hub_client.py
close async #
Close the connection and stop the receive loop. Idempotent.
Source code in autogen/beta/network/client/hub_client.py
shutdown async #
Unregister every AgentClient then close().