Hub
autogen.beta.network.hub.core.Hub #
Hub(store, *, auth=None, clock=None, ttl_sweep_interval=30.0, expectation_sweep_interval=10.0, invite_ack_timeout=30.0)
In-process registry, dispatcher, session state-machine, persistence root.
Construct with :meth:open for production (hydrates from disk and spawns sweepers); the sync __init__ is for tests that need fine-grained control.
Source code in autogen/beta/network/hub/core.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 | |
open async classmethod #
open(store, *, auth=None, clock=None, ttl_sweep_interval=30.0, expectation_sweep_interval=10.0, invite_ack_timeout=30.0, register_default_adapters=True)
Construct + hydrate from disk + start sweepers. Production entry point.
register_default_adapters=True (default) registers the built-in adapters (consulting@v1, conversation@v1, discussion@v1) and the built-in expectation evaluators / violation handlers (acks_within / reply_within / max_silence, audit / notify_session / auto_close) so simple test setups don't need explicit registration calls.
Set expectation_sweep_interval=0 to disable the expectation sweeper entirely (tests usually do this to avoid background timer noise).
Source code in autogen/beta/network/hub/core.py
hydrate async #
Walk the store; rebuild caches. Idempotent.
Loads identities, sessions, and tasks from disk. Active session WALs are re-folded through their adapter so the _adapter_states cache is rebuilt deterministically.
Source code in autogen/beta/network/hub/core.py
start async #
Spawn the TTL + expectation sweepers. Idempotent.
ttl_sweep_interval=0 disables the TTL sweeper; expectation_sweep_interval=0 disables the expectation sweeper.
Source code in autogen/beta/network/hub/core.py
close async #
Cancel sweepers + endpoint tasks; drain queues. Idempotent.
Source code in autogen/beta/network/hub/core.py
register_adapter #
Register a SessionAdapter keyed by (type, version).
Re-registering at the same key replaces the prior adapter; the old key's existing in-flight sessions keep their snapshotted manifest for life.
Source code in autogen/beta/network/hub/core.py
register_expectation_evaluator #
Register an evaluator keyed by evaluator.name.
Re-registering the same name replaces the prior evaluator.
Source code in autogen/beta/network/hub/core.py
register_violation_handler #
Register a violation handler keyed by handler.name.
Re-registering the same name replaces the prior handler.
Source code in autogen/beta/network/hub/core.py
register async #
Source code in autogen/beta/network/hub/core.py
unregister async #
Source code in autogen/beta/network/hub/core.py
get_agent async #
Source code in autogen/beta/network/hub/core.py
get_resume async #
get_skill async #
Source code in autogen/beta/network/hub/core.py
list_agents async #
Source code in autogen/beta/network/hub/core.py
set_resume async #
Source code in autogen/beta/network/hub/core.py
set_skill async #
Source code in autogen/beta/network/hub/core.py
set_rule async #
Source code in autogen/beta/network/hub/core.py
record_observation async #
Update Resume.observed[capability] from a terminal task event.
Called by TaskMirror when an owner's task ends with a capability tag set on its TaskSpec. Updates the capability index so the agent appears under that capability even if it wasn't in their original claimed_capabilities.
Outcome must be one of the terminal task states (COMPLETED / FAILED / EXPIRED); other states are ignored. latency_ms, when provided, replaces the prior p50_latency_ms (single-sample stand-in for a future reservoir).
task_id (when provided) is used to dedup: a single task contributing twice to Resume.observed.n (e.g. cascade EXPIRED + owner-emitted COMPLETED) is recorded only once.
Source code in autogen/beta/network/hub/core.py
agents_with_capability #
Return agent_ids matching capability (claimed or observed).
create_session async #
create_session(*, creator_id, manifest_type, manifest_version=1, participants, required_acks=None, ttl=None, knobs=None, intent=None, labels=None)
Allocate session_id, post invites, await acks, return metadata.
Posts EV_SESSION_INVITE to every invitee, awaits an EV_SESSION_INVITE_ACK from each (the handshake is all-or-nothing — any reject fails creation), transitions to ACTIVE, and broadcasts EV_SESSION_OPENED. Times out after invite_ack_timeout if the acks do not arrive.
Source code in autogen/beta/network/hub/core.py
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 | |
close_session async #
get_session async #
can_send #
True if the adapter would accept a substantive send from sender_id against the current state.
Wraps adapter.validate_send with a probe envelope so the default notify handler doesn't need to reach into private hub state to figure out whether it's the agent's turn.
Source code in autogen/beta/network/hub/core.py
default_view_policy #
Return the adapter-declared default view policy for this participant on this session. Wraps adapter.default_view_policy so callers don't need adapter registry access.
Source code in autogen/beta/network/hub/core.py
list_sessions async #
Source code in autogen/beta/network/hub/core.py
read_wal async #
Source code in autogen/beta/network/hub/core.py
observe_task async #
Register a task observed via the agent's stream.
Hub does not create, assign, or cancel — it stores TaskMetadata, persists it, and starts TTL accounting.
On first observation, enforces the owner's Rule.limits.max_concurrent_tasks cap (0 disables).
Source code in autogen/beta/network/hub/core.py
get_task async #
update_task async #
Update an observed task's lifecycle. Used by task_mirror.
Terminal-state transitions stamp completed_at. Idempotent — terminal-on-terminal is a no-op (further events ignored).
Source code in autogen/beta/network/hub/core.py
list_tasks async #
Source code in autogen/beta/network/hub/core.py
expire_due async #
Walk active sessions and tasks; expire ones past their TTL.
Cascades non-terminal tasks under closing sessions (via :meth:_transition_session).
Source code in autogen/beta/network/hub/core.py
post_envelope async #
Validate sender + adapter + WAL append + dispatch.
Per-session lock makes validate_send / fold / on_accepted see a consistent state. Dispatch and post-accept transitions happen outside the lock so the broadcast of EV_SESSION_CLOSED does not deadlock on the same lock.
Source code in autogen/beta/network/hub/core.py
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 | |