Threads and conversations¶
octomate.managers.thread ¶
The thread chat ledger: threads, their messages, bindings to model messages, handoffs, and history search.
BindRefusal ¶
Bases: ValueError
A bind refused by policy — a thread that is not work, or one already bound —
carrying the sentence a model may be told and correct from. A ValueError
still, so nothing that never told the two apart changes.
Source code in octomate/managers/thread.py
ThreadManager ¶
Bases: Manager, Locks[ThreadKey]
Owns durable thread chat ledger persistence.
Source code in octomate/managers/thread.py
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 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 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 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 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 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 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 | |
ensure
async
¶
ensure(
address_or_key: ChannelAddress | ThreadKey,
*,
project: Project | None = None,
title: str | None = None,
new: bool = False,
native: bool = False,
owner_id: UUID7 | None = None,
entry_message_id: UUID7 | None = None,
) -> Thread
The thread this key names, created if it is new.
A key names a surface, so it resolves the thread nobody opened. A chat room's sub-threads share its address and are reached by id, through it.
A channel-supplied title refreshes the surface's stored name, including
existing groups and DMs previously named from an opening line.
project attributes a thread being created and is ignored for one that
already exists: a thread's project is frozen once the row is written, so
declaring a project later attributes new threads rather than rewriting old
ones. It is not part of the key either — the key is what the thread's history
is filed under, and attribution must never move it.
Only a thread and a native thread can take one; naming a project for a DM or a group chat raises rather than dropping it silently.
new=True refuses an existing surface under the creation lock. A native
provider claiming a fresh session cannot thereby attach an existing one.
native=True marks a tailed thread at creation, independently of its
configured agent's address, and refuses an existing ordinary thread.
owner_id records the first registered caller without replacing one.
Native intake additionally requires that owner; driven access is governed
by its existing caller authorization, independently of this attribution.
DMs require an owner and never claim existing ownerless history.
entry_message_id links a new platform task to its group-main request;
an existing task cannot acquire a different entry.
Source code in octomate/managers/thread.py
172 173 174 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 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | |
open_sub_thread
async
¶
open_sub_thread(
parent: Thread,
*,
owner_id: UUID7 | None = None,
entry_message_id: UUID7 | None = None,
) -> Thread
The thread one kick in parent does its work in.
Flat group channels use internal tasks while their messages stay in the group ledger. Platforms with subthreads use their own destinations.
Opened, never looked up: a sub-thread has no address of its own to be found by, and each kick wants its own. A redelivered event therefore opens a second — that is a duplicate to stop where it is made, in the ledger, not here.
Source code in octomate/managers/thread.py
enter
async
¶
enter(
address_or_key: ChannelAddress | ThreadKey,
*,
current: Thread | None = None,
owner_id: UUID7 | None = None,
) -> Thread
The thread a turn arriving at this surface does its work in.
DMs keep a continuous conversation on their main surface, just as platform threads and native threads keep theirs. A group main is admitted only as a source; routing opens its platform task thread before execution.
current is the thread the turn is already in, and it is kept when this
surface is the chat room that thread was opened in: an agent taking the
conversation over in place is still answering the same kick, and a second
sub-thread would split one answer across two model contexts.
An existing task requires its recorded owner, including after the platform profile is unlinked or linked to another user.
Source code in octomate/managers/thread.py
surface
async
¶
The surface this thread is on: itself, or the chat room it was opened in.
A sub-thread has none of its own — no address, no chat ledger, no prompt cursor — so this is the one place the split between where a run happens and where it is seen gets made. Nesting is one level, so it never walks.
Source code in octomate/managers/thread.py
fork_title
staticmethod
¶
What a fork of source, from thread, is first called: what the source
goes by, the name its runtime gave the session or else the thread's title.
None when it goes by nothing, and the fork takes a name the way a new thread
does.
Source code in octomate/managers/thread.py
rename
async
¶
Give the thread the name the runtime running it grabbed for itself.
Unlike the opening line store_message falls back to, this is a name for
the work rather than for how it was asked for, so it overwrites — and goes
on overwriting, because the runtime revises it as the session goes on. A
name with nothing in it is not one, and leaves the thread as it was.
A group's main chat keeps its platform name, and a DM keeps the bot's
name; only their work sub-threads take generated titles.
Source code in octomate/managers/thread.py
bind
async
¶
Attribute a thread that is in no project to project, once.
The one exception to a project being written when the row is created: a chat thread exists before anyone has said what it is about, so the attribution has to be able to arrive later. It arrives once. A second bind is refused rather than switching — the first project's workspace holds work nobody has reviewed yet, and a thread whose project moved is a record of what it did somewhere it no longer says it was. A different project is a different thread.
A DM and a group chat are refused for the reason ATTRIBUTABLE_KINDS
gives: they outlive every project in them. Both refusals are BindRefusal;
a thread that does not exist is a plain ValueError, a wiring bug.
No workspace is made here. A run's working directory is fixed when its process spawns, so this takes effect on the thread's next turn and the caller has to say so.
Source code in octomate/managers/thread.py
get
async
¶
get(
thread_id: UUID7 | ThreadKey,
*,
with_messages: bool = True,
user_id: UUID7 | None = None,
) -> Thread | None
The thread by primary key, or by the key it is filed under, or None —
its handoffs with the row, its ledger only when asked for. A key never
creates one, unlike ensure.
with_messages=True is the whole ledger, deliberately: it is what a reader
rebuilding a thread wants, and it is unbounded in a room, so a caller after
one row wants find_message and a caller after the recent ones wants
chat_messages_before.
Either way the model ledger stays behind: it hangs off a message, and
related_model_messages is how a caller asks for it — dragging it here
would put a query per message behind every thread read.
user_id restricts access to participation in the thread's own ledger or entry;
messages inherited from another thread grant no access.
Source code in octomate/managers/thread.py
list_threads
async
¶
list_threads(
channel_tentacle_id: str | None = None,
*,
limit: int = 100,
user_id: UUID7 | None = None,
chat_id: str | None = None,
offset: int = 0,
) -> list[Thread]
Threads most recently touched first — one channel's, or every
channel's when channel_tentacle_id is None. Sub-threads are not listed;
the threads a chat room's kicks work in are reached through the chat room.
Handoffs come with the rows (lazy="selectin", one batched pass); the ledgers do not. A listing that loaded them would read every message of every thread it names, and no caller has ever wanted that — the one reader of a thread's messages asks for that thread.
Source code in octomate/managers/thread.py
publish
async
¶
Publish committed thread events to each eligible user's topic.
Resolve registered participants once for the supplied events, without a cache, matching listing and access checks. Inherited history grants no access. Sub-threads are not listed. Token events never call this method.
Source code in octomate/managers/thread.py
store_message
async
¶
Persist a ledger row.
The row is touched, not only appended to. updated_at fires on an update
of the thread and writing to its ledger is not one, so a session being
tailed right now would keep the timestamp it was created with and sink, in
a listing ordered by it, under threads nothing has ever said a word in.
A thread nobody has named takes its name from this row when a person wrote
it. The listing carries no messages, so the first thing said is the only
name a row has until a runtime grabs one of its own (rename).
Source code in octomate/managers/thread.py
record_artifact
async
¶
record_artifact(
thread_id: UUID7,
artifact: Artifact,
*,
sender: UserProfile,
agent_tentacle_id: str,
) -> ThreadArtifact
Commit an artifact and its ledger reference together before publication.
Source code in octomate/managers/thread.py
record_command_outcome
async
¶
Persist an outcome without mutating a caller's receipt snapshot. Under the
thread's lock, only the outcome and the thread's updated_at are written.
Source code in octomate/managers/thread.py
record_inbound
async
¶
record_inbound(
event: MessageEvent,
*,
actor_kind: ChannelActorKind = "human",
agent_tentacle_id: str | None = None,
happened_at: datetime | None = None,
) -> ThreadMessage
Write the event to the thread's ledger, or hand back the row it is already on.
A platform re-sends a message when it misses an ack — Slack does — and the second send is the same message, not a second one. Writing it twice would put a duplicate in everyone's scroll-back, so one delivery is one row and asking again is answered with the row that exists.
Only a message the platform named can be recognised — an event with no
message_id is always recorded, because there is nothing to match it on.
Two deliveries racing this read both reach the insert, and the ledger's
unique key refuses the loser loudly rather than letting it through.
Recording is idempotent; answering is not. A caller that wakes a turn on
what it records asks find_message first, because a row that already exists
is a message somebody is already answering.
Swaps event.sender for its registry row as a side effect, so the
event's sender line resolves the owning identity via event.sender.user.
Pass happened_at only to overrule the event's own clock: a transcript replay
knows when the turn really happened, which a hook-built event cannot carry.
Left out, the event's clock is used, and failing that the moment it arrived —
the row is never undated, because an undated row has no place in the order.
Source code in octomate/managers/thread.py
record_outbound
async
¶
record_outbound(
thread_or_address: Thread | ChannelAddress | ThreadKey,
*,
agent_tentacle_id: str,
segments: list[MessageSegment],
platform_message_id: str | None = None,
reply_id: str = "",
happened_at: datetime | None = None,
sender: UserProfile,
owner_id: UUID7 | None = None,
actor_kind: ChannelActorKind = "agent",
message_text: str | None = None,
raw: str = "",
) -> ThreadMessage
Write the agent's reply to the thread's ledger.
Pass happened_at only when something knows better than this moment — a
transcript replay does; an agent answering now does not.
Source code in octomate/managers/thread.py
mark_presented
async
¶
Name the platform message a ledger row was rendered as, once the channel that rendered it knows; a rendering with no id leaves it be.
Source code in octomate/managers/thread.py
redate_message
async
¶
Overrule a ledger row's clock after the fact: a transcript replay knows
when a message really happened, while a row the live hooks wrote was stamped
at receipt — a beat later than the transcript line, which is enough to sort a
run's work above the prompt that caused it. Under the thread's lock, only the
row's happened_at is written.
Source code in octomate/managers/thread.py
pending_prompt_messages
async
¶
pending_prompt_messages(
thread: Thread,
trigger_message_id: UUID7,
active_agent_id: str,
*,
trigger_only: bool = False,
) -> list[ThreadMessage]
Source code in octomate/managers/thread.py
advance_prompt_cursor
async
¶
Source code in octomate/managers/thread.py
record_fork
async
¶
record_fork(
source: Conversation,
target: Thread,
*,
sender: UserProfile,
title: str | None,
) -> Thread
Publish a user-attributed system notice after a successful fork. It names
the source by title, the source's own name that the fork starts with, or by
the source's id when it goes by nothing.
Source code in octomate/managers/thread.py
record_handoff
async
¶
record_handoff(
thread_or_address: Thread | ChannelAddress | ThreadKey,
*,
to_agent_tentacle_id: str,
source_agent_tentacle_id: str | None = None,
to_model: AgentRouteModelName | None = None,
reason: str = "",
hint: str = "",
brief: str = "",
source_conversation_id: UUID7 | None = None,
target_conversation_id: UUID7 | None = None,
source_run_id: str | None = None,
source_model_message_id: UUID7 | None = None,
) -> Handoff
Source code in octomate/managers/thread.py
record_kick
async
¶
File a kick that just fell asleep on thread, timed from woke_at.
Source code in octomate/managers/thread.py
chat_message
async
¶
The chat message handle names within this person's history — the threads
they have spoken in, on this account or any the registry links to it. A row
id, or the #msg:<id> handle shown beside it: the platform's own id, which
is what a brief written from the other side of a handoff has to cite.
Source code in octomate/managers/thread.py
find_message
async
¶
find_message(
thread_id: UUID7,
platform_message_id: str,
direction: ThreadMessageDirection | None,
) -> ThreadMessage | None
The row delivered to the thread for one platform message — a turn's prompt, or the reply that answered it. Oldest wins, as scanning the ordered ledger did. A row the thread shows from a ledger a fork froze into it was delivered elsewhere, so it is never this one.
Both halves of the key are indexed. The hooks and tailers ask this per turn, on a ledger with no ceiling, so the row has to be found by the index rather than by reading the room's whole tenure to match one id in Python.
Source code in octomate/managers/thread.py
is_task_entry
async
¶
Whether quoting this public message addresses a task's agent.
Source code in octomate/managers/thread.py
quoted_task
async
¶
Resolve an owner's quoted task within the group where it was published.
A quote can name its original request, a platform thread's opener, or an answer bound to a run. Run ownership identifies the original task, never a fork that inherited that run. A different caller receives no task and may use only the public quoted message as context for fresh work.
Source code in octomate/managers/thread.py
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 | |
record_native_prompt
async
¶
record_native_prompt(
address: ChannelAddress,
*,
message_id: str,
text: str | TextContent,
sender: UserProfile,
timestamp: datetime,
actor_kind: ChannelActorKind = "human",
) -> ThreadMessage
Record a transcript input once, before the run commits.
The native message identity survives reconnects. The caller holds its session lock across this lookup and write; the row grants the stream's owner access to a new thread while its model history is still folding.
Source code in octomate/managers/thread.py
bind_native_run
async
¶
bind_native_run(
address: ChannelAddress,
run: ExternalAgentRun,
*,
prompts: dict[UUID7, UUID7],
answer: str,
sender: UserProfile,
) -> UUID7 | None
Bind transcript prompts and the final reply after the run commits.
Each prompt maps its ledger id to its committed model message id. The caller holds the session lock and publishes run_ended
only after this returns, so a reader can immediately reload the ledger.
Source code in octomate/managers/thread.py
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 | |
bind_messages
async
¶
bind_messages(
thread_message_ids: list[UUID7],
model_message_id: UUID7,
*,
kind: MessageBindingKind,
run_id: str,
tool_call_id: str | None = None,
) -> list[MessageBinding]
Source code in octomate/managers/thread.py
bind_assistant_replies
async
¶
Source code in octomate/managers/thread.py
search_chat_messages
async
¶
search_chat_messages(
profile: UserProfile,
query: str,
*,
actor_kind: ChannelActorKind | None = None,
limit: int = 10,
) -> list[ThreadMessage]
The messages matching every English term in query across this person's
history — the threads they have spoken in, on this account or any the registry
links to it. Best lexical match first, newest first when scores tie. A
visitor's history is one account's.
Source code in octomate/managers/thread.py
chat_messages_before
async
¶
chat_messages_before(
thread_id: UUID7,
anchor_id: UUID7,
*,
limit: int = 5,
actor_kind: ChannelActorKind | None = None,
) -> list[ThreadMessage]
The rows standing before anchor_id in the thread, oldest last of them
first. Neighbours in the conversation, which is what the ledger's order means —
so the anchor is compared on the same key the rows are sorted by.
Source code in octomate/managers/thread.py
chat_messages_after
async
¶
The rows standing after anchor_id in the thread, oldest first — the mirror
of chat_messages_before, and anchored on the same key.
Source code in octomate/managers/thread.py
messages_page
async
¶
messages_page(
thread_id: UUID7,
cursor: str | None = None,
*,
unbound: bool = False,
limit: int,
) -> Page[ThreadMessage]
The rows the thread shows — its own ledger's, and a forked parent's up to
the cut — a page at a time, newest first, continued from an Arcanus
cursor. Ids are uuid7 and a ledger is appended to, so id order is the
order rows were written in.
unbound keeps to the rows no model message of the thread's own
conversations was built from or answered with: a fork or teleport notice,
or a chat room's talk, whose work runs in sub-threads. Everything else is
read through those model messages, which carry the rows bound to them.
Source code in octomate/managers/thread.py
related_model_messages
async
¶
Source code in octomate/managers/thread.py
history_match_query ¶
An English plain-text query expressed safely in FTS5's query language.
Each whitespace-delimited term is its own quoted phrase, so every term must match while operators and punctuation supplied by a caller stay literal.
Source code in octomate/managers/thread.py
message_text_from_segments ¶
Source code in octomate/managers/thread.py
keyed ¶
The row a key names. A sub-thread shares its chat room's address, so a key names the thread nobody opened — the line the unique index draws.
Source code in octomate/managers/thread.py
shown_by ¶
The messages shown by the threads threads picks out of thread_ledgers:
those delivered to one of their ledgers, up to that ledger's cut.
Source code in octomate/managers/thread.py
in_ledger ¶
in_history_of ¶
Messages in threads these senders participated in, including task entries.
Inherited messages are readable history, not participation in the destination.
Source code in octomate/managers/thread.py
thread_title ¶
A name for a thread, out of one line of what was said in it.
Whitespace is folded because a directive arrives with its own newlines and a listing has one line to give it. A message with nothing in it names nothing, and the row goes on falling back to its surface.
Source code in octomate/managers/thread.py
octomate.managers.conversation ¶
Agent conversations and their model message history.
request_usage_adapter
module-attribute
¶
ConversationNotFound ¶
IncompleteCompactionContext ¶
ConversationManager ¶
Bases: Manager, Locks[ConversationKey | CompactionSessionKey]
Resolves and persists agent Conversation entities, and owns their model
message history.
A Conversation is one agent's model context within a Thread — not a human
chat log; the user-facing chat ledger is ThreadManager's ThreadMessage
rows. A thread owns one conversation per agent, so the identity is
(thread_id, agent_tentacle_id, subagent_id): every sender in a group thread
keys to the same owning agent's conversation, regardless of who woke it.
Source code in octomate/managers/conversation.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 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 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 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 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 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 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 | |
get
async
¶
get(
conversation_id: UUID7,
*,
with_runs: bool = True,
with_messages: bool = False,
) -> Conversation
Read an existing conversation by id; raise on an unknown id.
with_runs loads runs and their messages. Independently, with_messages
loads effective context, cumulative usage, and deferred tool requests for
an agent run, with upstream's persistence cursor. Disable both for a
metadata-only read. Thread ownership is established by ensure().
Source code in octomate/managers/conversation.py
history
async
¶
history(
conversation_id: UUID7,
*,
limit: NonNegativeInt | None = None,
) -> list[ModelRequest | ModelResponse]
Read original run messages in order, including history replaced by compaction.
A limit selects the most recent messages. Shared fork runs are included; compaction-owned replacements belong to get(..., with_messages=True).
Source code in octomate/managers/conversation.py
has_history
async
¶
Whether the conversation has any archived run messages.
Source code in octomate/managers/conversation.py
effective_messages
async
¶
effective_messages(
conversation: Conversation,
*,
pending: tuple[UUID7, ...] = (),
) -> list[ModelRequest | ModelResponse]
Load only the bodies remaining after replaying complete compactions.
Source code in octomate/managers/conversation.py
effective_message_ids
async
¶
effective_message_ids(
conversation: Conversation,
*,
pending: tuple[UUID7, ...] = (),
) -> list[UUID7]
Replay complete, ordered rewrites over the run archive.
Each input must match the effective prefix at that boundary. Later run messages follow its replacement; unknown membership or order cannot be replayed safely and is refused rather than reviving the archive. Only message ids are replayed; bodies are loaded for the final context.
Native adapters may exclude their pending boundaries while proving the next rewrite. Agent context reads never exclude a boundary.
Source code in octomate/managers/conversation.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |
record_context_compaction
async
¶
record_context_compaction(
conversation: Conversation,
*,
before: list[ModelRequest | ModelResponse],
after: list[ModelRequest | ModelResponse],
trigger: CompactionTrigger,
happened_at: AwareDatetime | None = None,
usage: RunUsage | None = None,
) -> str | None
Persist an exact history rewrite after its original run messages exist.
Retained inputs keep their ids and ownership. New replacement messages belong to the compaction, whose two ordered stages include every input and output message. A later suffix already archived by the run is allowed. Return the saved revision, or None for unchanged membership. The supplied conversation keeps its runtime context and persistence cursor. When supplied, cumulative usage is saved with the rewrite in the same transaction.
Source code in octomate/managers/conversation.py
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |
native_compactions
async
¶
Read canonical native records across driven and transcript owners.
Source code in octomate/managers/conversation.py
session_run_ids
async
¶
Read native-session ownership without hydrating the archived messages.
Source code in octomate/managers/conversation.py
record_native_memberships
async
¶
Complete proven replacements; missing or split source identities stay unknown.
Source code in octomate/managers/conversation.py
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 | |
record_compaction_memberships
async
¶
record_compaction_memberships(
conversation: Conversation,
rewrites: list[CompactionRewrite],
) -> None
Complete an ordered native prefix using existing archive identities.
Previously completed snapshots are immutable. All reads and writes are batched, and inherited links acquire the proven order without copying either messages or compactions.
Source code in octomate/managers/conversation.py
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 | |
record_driven_compaction
async
¶
record_driven_compaction(
conversation: Conversation,
*,
native_session_id: str,
native_compaction_id: str,
trigger: CompactionTrigger,
happened_at: AwareDatetime | None,
messages: list[ModelRequest | ModelResponse]
| None = None,
) -> Compaction | None
Persist a completed native item once, without inventing unavailable content.
Source code in octomate/managers/conversation.py
record_external_compaction
async
¶
record_external_compaction(
conversation: Conversation,
*,
native_session_id: str,
source: str,
start_offset: int | None,
end_offset: int | None,
happened_at: AwareDatetime,
messages: list[ModelRequest | ModelResponse],
native_compaction_id: str | None = None,
trigger: CompactionTrigger = "unknown",
) -> ExternalCompaction | None
Record one completed transcript observation, including driven sessions.
Replaying the same byte range is a no-op. An active runtime binding owns the observation when present; otherwise the native conversation does.
Source code in octomate/managers/conversation.py
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 | |
latest_model
async
¶
Read the last reported model without loading the conversation's history.
Source code in octomate/managers/conversation.py
latest_context_window
async
¶
The latest run's capacity, including None when its route reported none.
Source code in octomate/managers/conversation.py
latest_cwd
async
¶
The last run's directory, for harnesses whose session cannot relocate.
Source code in octomate/managers/conversation.py
ensure
async
¶
ensure(
thread_id: UUID7,
*,
agent_tentacle_id: str,
subagent_id: str = "",
name: str | None = None,
parent_conversation_id: UUID7 | None = None,
with_runs: bool = True,
native: bool = False,
) -> Conversation
Resolve the conversation owned by agent_tentacle_id in thread_id,
creating it if it does not yet exist. The owning agent is part of the
identity — two agents in the same thread keep separate conversations — so callers must always
supply it. subagent_id narrows to one subagent's own context; empty is
the agent's long-lived conversation in the thread. A subagent context
names the conversation that spawned it, and only a subagent context may.
with_runs loads the run relationship, including each run's messages.
Disable it when only identity, permissions, or the native resume id is
needed. Effective context is loaded through get(..., with_messages=True).
Native ingest sets native=True to resolve its uploaded thread's context.
A native context belongs to one configured agent; another owner is refused.
The thread's persisted native kind remains unchanged.
Source code in octomate/managers/conversation.py
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 | |
link_parent_run
async
¶
link_parent_run(
run_id: str,
*,
parent_run_id: str | None,
parent_tool_call_id: str | None,
) -> None
Stamp a recorded run's place in the run tree, after the fact. The runner stays ignorant of why it ran; the caller that spawned it links the turn to its own run and tool call once the child returns. MCP callers supply only the tool call id; saving the parent's tool result supplies its run id. A run that recorded nothing has no row to link — not an error.
Source code in octomate/managers/conversation.py
subagents
async
¶
The subagent conversations spawned from parent_conversation_id — the
live accomplices a whisper can reach. Rows only; callers resolve a
chosen one through ensure.
Source code in octomate/managers/conversation.py
for_thread
async
¶
The thread's agent conversations, subagents included, each with its runs.
Run messages are not loaded: a reader after the messages pages through
them with messages_page.
Source code in octomate/managers/conversation.py
messages_page
async
¶
messages_page(
thread_id: UUID7,
cursor: str | None = None,
*,
limit: int,
conversation_id: UUID7 | None = None,
) -> Page[ModelRequest | ModelResponse]
The model messages of the thread's own conversations, newest first, a
page at a time and continued from an Arcanus cursor. Ids are uuid7 and a
run's messages are appended in processing order, so id order preserves
each transcript's sequence across committed turns.
Each carries the chat rows bound to it — the ones a request was built from,
the ones a response was delivered as — so a reader has who said what
without the prompt's dressing. Without conversation_id, subagents stay
out; selecting a conversation reads only its own messages.
Source code in octomate/managers/conversation.py
usage
async
¶
The tokens the thread's own conversations spent, every response's usage summed, or just the selected conversation's, including a subagent's. Only the usage column is read: summing a thread must not load its parts.
Source code in octomate/managers/conversation.py
thread_id
async
¶
Source code in octomate/managers/conversation.py
record_agent_run
async
¶
record_agent_run(
conversation: Conversation,
run_id: str,
messages: Sequence[ModelMessage],
*,
name: str | None = None,
model_name: str | None = None,
context_window: int | None = None,
context_used: int | None = None,
permission_mode: AgentPermissionMode | None = None,
cwd: Path | None = None,
external_id: str | None = None,
native_turn_id: str | None = None,
parent_run_id: str | None = None,
parent_tool_call_id: str | None = None,
) -> AgentRun | None
Persist an agent run's archive, completing its registration if present.
cwd is the directory the run happened in, None when its caller has none.
external_id, when given, updates the conversation's resumable agent
session handle in the same commit (external-runtime agents own their own
session). The parent pair marks a subagent's turn: the run whose tool
call spawned it, and which call it answers.
Source code in octomate/managers/conversation.py
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 | |
record_run_metadata
async
¶
record_run_metadata(
run_id: str,
*,
name: str,
model_name: str | None,
context_window: int | None,
context_used: int | None,
permission_mode: AgentPermissionMode | None,
cwd: Path | None,
returned_calls: set[str],
parent_run_id: str | None = None,
parent_tool_call_id: str | None = None,
) -> None
Complete a stored run's metadata and returned child links without loading its archive.
Source code in octomate/managers/conversation.py
driven_run
async
¶
Find the driven owner of a native turn without loading its messages.
Source code in octomate/managers/conversation.py
record_external_run
async
¶
record_external_run(
conversation: Conversation,
run_id: str,
messages: Sequence[ModelMessage] = (),
*,
name: str | None = None,
model_name: str | None = None,
context_window: int | None = None,
context_used: int | None = None,
permission_mode: AgentPermissionMode | None = None,
cwd: Path | None = None,
native_session_id: str,
source: str | None = None,
start_offset: int | None = None,
end_offset: int | None = None,
last_line_uuid: str | None = None,
parent_run_id: str | None = None,
parent_tool_call_id: str | None = None,
) -> ExternalAgentRun | None
Reserve or complete a native turn without duplicating a driven run.
Empty input reserves its identity and can identify its spawning call. A stored end_offset marks a completed transcript; replay returns None. Completing an unfinished run replaces provisional messages atomically.
The native session becomes the conversation's resumable external_id; cwd records the directory reported by the hook or transcript.
Source code in octomate/managers/conversation.py
1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 | |
persist_run
async
¶
Persist the supplied run and its messages in one transaction. Registered runs already have a conversation link. The run's native session ID updates the conversation's resumable handle in the same commit.
Only the supplied run and its messages are added, never the caller's whole
conversation graph: re-merging it (prior runs and their message
collections) can make SQLAlchemy believe a message was dropped from a
stale run collection and null its NOT NULL run_id, raising an
IntegrityError.
Source code in octomate/managers/conversation.py
fork
async
¶
fork(
source: Conversation,
target: Conversation,
*,
carry_external_id: bool = False,
external_id: str | None = None,
transcript: Jsonl | None = None,
end_offset: int | None = None,
permission_mode: AgentPermissionMode | None = None,
) -> str | None
Continue source's history in an empty target, in one transaction.
Nothing is copied. The target's history points at the source's runs through
conversation_runs, and its thread shows the source thread's ledgers through
thread_ledgers, each frozen where it stands now: whatever either side says
afterwards is its own. Only the selected conversation receives the
independently forked runtime handle.
A native import passes end_offset, where the transcript's last completed
turn ends (an uploaded snapshot's size by default), to leave out the turns
and compactions that end past it and cut the source's ledger before their
chat. Compactions with unknown boundaries cannot be cut safely. Inherited
compactions keep their identities and any unknown membership or order.
carry_external_id moves the existing handle instead, for runtimes whose
continuation requires it. Return the id of the last run the target's history
includes, if any.
Source code in octomate/managers/conversation.py
1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 | |
transcript_offsets
async
¶
transcript_offsets(
conversation: Conversation,
*,
owner_id: UUID7,
provider: FileProviderName,
) -> TranscriptOffsets
Read retained sizes for this invocation and its direct subagents.
Source code in octomate/managers/conversation.py
store_transcript
async
¶
store_transcript(
uploaded: UploadFile,
start: int,
*,
conversation: Conversation,
files: FileManager,
owner_id: UUID7,
) -> FileVariant
Persist new bytes of a native conversation's owner-scoped transcript.
Create the first file and conversation reference in one transaction; subsequent uploads append to that file. Never mutate the caller's conversation.
Source code in octomate/managers/conversation.py
set_external_id
async
¶
Bind the runtime session, clearing its transcript reference when the ID changes.
Source code in octomate/managers/conversation.py
set_permission_mode
async
¶
set_permission_mode(
conversation: Conversation,
mode: AgentPermissionMode | None,
) -> Conversation
Store the approval posture this conversation's agent works under.
Callers selecting a mode validate against the running agent's catalog. Native observers also store modes that are no longer selectable. None clears the selection and lets the agent's configured default decide.
This method only persists the selection. User changes go through the owning agent tentacle, which also updates its live runtime when supported.
Source code in octomate/managers/conversation.py
set_effort
async
¶
Store the reasoning effort this conversation's runs ask for.
Callers validate the level against the route the conversation runs on; None clears it and lets the runtime's own default decide.
Source code in octomate/managers/conversation.py
set_name
async
¶
Store the name the runtime running this session grabbed for itself.
Only a runtime that names its own sessions has one to store, and it revises it as the session goes on, so this overwrites. A name with nothing in it is not one, and leaves the conversation as it was.
Source code in octomate/managers/conversation.py
grant_session_tool
async
¶
Persist an allow for session grant on the conversation, so the tool
auto-approves on later turns.
Source code in octomate/managers/conversation.py
search_messages
async
¶
search_messages(
conversation_id: UUID7,
query: str,
*,
role: Literal["user", "assistant"] | None = None,
limit: int = 10,
) -> list[ModelMessage]
Conversation messages whose message_text contains query
(case-insensitive), ordered chronologically. One polymorphic select spans
both kinds, so an unfiltered search returns user and assistant hits in a
single pass; role narrows it when set. Tool-call/thinking messages carry
no message_text and never match — reach them via
messages_before/messages_after.
Source code in octomate/managers/conversation.py
messages_before
async
¶
messages_before(
conversation_id: UUID7,
anchor_id: UUID7,
*,
limit: int = 5,
) -> list[ModelMessage]
The limit messages immediately preceding anchor_id in the
conversation (all kinds), oldest-first.
Source code in octomate/managers/conversation.py
messages_after
async
¶
messages_after(
conversation_id: UUID7,
anchor_id: UUID7,
*,
limit: int = 5,
) -> list[ModelMessage]
The limit messages immediately following anchor_id in the
conversation (all kinds), oldest-first.
Source code in octomate/managers/conversation.py
related_chat_messages
async
¶
Source code in octomate/managers/conversation.py
ConversationStore
dataclass
¶
Bases: ConversationStore
Upstream conversation bookkeeping over the shared conversation manager.
Loading delegates to the manager; record_conversation appends run messages and carryover state through Arcanus. Linked-entry persistence is not implemented, so upstream save, branch, fork, listing, and deletion remain unavailable.
Source code in octomate/managers/conversation.py
2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 | |
conversation_id_adapter
class-attribute
¶
load
async
¶
load(
conversation_id: str,
*,
limit: int | None = None,
scope: str | None = None,
) -> Conversation | None
Source code in octomate/managers/conversation.py
record_conversation
async
¶
Append new run messages and replace carryover state in one transaction.
Follows upstream load/save bookkeeping, returning the new archive rows instead of wrapping them in ConversationEntry objects. Runs retain their ownership; compaction replacements must be recorded through manager.record_context_compaction before loading or saving the context. This store does not treat an unrecorded rewrite as an implicit branch. Keep the passed conversation to retain its updated revision and cursor.
Source code in octomate/managers/conversation.py
2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 | |
record_compaction
async
¶
record_compaction(
conversation: Conversation,
*,
after: list[ModelMessage],
trigger: CompactionTrigger,
) -> None
Record an accepted rewrite of an already archived context.
Resolve retained objects to their existing rows only when a rewrite occurs. Copies with changed parts are new compaction-owned messages. Advance the supplied conversation's revision and cursor for the remaining run.
Source code in octomate/managers/conversation.py
read_record
async
¶
read_records
async
¶
write_record
async
¶
write_record(
record: ConversationRecord,
*,
new_entries: Sequence[ConversationEntry] = (),
expected_revision: str | None,
) -> None
Source code in octomate/managers/conversation.py
delete_record
async
¶
own_runs ¶
The runs in the history of the thread's own conversations — its agents', not the subagents' those agents spawned. A fork's history holds the runs it was forked with, so those are its own too. A selected conversation scopes the read to that conversation, including a subagent.
Source code in octomate/managers/conversation.py
octomate.managers.deferred ¶
Persistence of deferred-action batches — the questions and approvals a run parks for a human — and their resolution from replies.
DeferredActionManager
dataclass
¶
Bases: Manager
Persists deferred-action batches and resolves them from user replies.
Source code in octomate/managers/deferred.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 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 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |
publish_update
async
¶
Announce committed state to every existing reader of this batch.
Source code in octomate/managers/deferred.py
create_batch
async
¶
create_batch(
*,
conversation: Conversation,
agent_tentacle_id: str,
run_name: str | None,
source_address: ChannelAddress,
target_address: ChannelAddress,
target_mode: ResponseTargetMode,
decision: SummonDecision | None,
requests: DeferredToolRequests,
response_mode: DeferredResponseMode,
batch_id: UUID7 | None = None,
) -> DeferredActionBatch
Source code in octomate/managers/deferred.py
pending_for_thread
async
¶
The thread's unanswered batches, oldest first, so a channel can re-present waiting questions and approvals when the thread is reloaded.
Source code in octomate/managers/deferred.py
get_batch
async
¶
get_batch(
batch_id: UUID7,
*,
channel_tentacle_id: str | None = None,
user_id: str | None = None,
) -> DeferredActionBatch
Load a batch's actions after checking any supplied channel user owns it.
Source code in octomate/managers/deferred.py
resolve_batch
async
¶
resolve_batch(
awake: DeferredActionBatchResponse,
*,
finalize: bool = True,
) -> DeferredActionBatch
Apply replies, allowing question answers to change while the batch is open.
With finalize=False, save question drafts without marking them answered; the owner validates them before calling submit_questions.
Source code in octomate/managers/deferred.py
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 254 255 | |
review_questions
async
¶
review_questions(
batch_id: UUID7,
*,
errors: dict[UUID7, str],
reset: UUID7,
) -> DeferredActionBatch
Keep invalid fields editable and require an explicit resubmission.
Source code in octomate/managers/deferred.py
submit_questions
async
¶
Finalize an owner's validated draft answers, including omitted fields.
Source code in octomate/managers/deferred.py
mark_action_presented
async
¶
Source code in octomate/managers/deferred.py
mark_batch
async
¶
Source code in octomate/managers/deferred.py
expire_live
async
¶
Expire every live request still pending. Its waiter lived in the process that asked, so after a restart a reply has nowhere to go; expired, the reply is refused rather than accepted and lost.
Source code in octomate/managers/deferred.py
octomate.managers.gateway ¶
Gateway policy: where a conversation can go, decided the same way for every agent.
OctomateSession is one turn's gateway — the route and destination resolution, the
validation of what a spell names, and the typed decision it records for the reflex
graph to act on after the turn. MCP exposes the spells and translates refusals
into tool errors for every runtime. GatewayManager is the in-process registry
an external runtime's tool call resolves its driving turn's session from.
ACCOMPLICE_INSTRUCTION
module-attribute
¶
ACCOMPLICE_INSTRUCTION = "You are an accomplice: another agent commissioned you, and your reply is\nyour report back to it. There is no user here to ask, and anything that needs a\nhuman approval is declined immediately — work from the brief you were given within\nwhat you can do unaided; if something is under-specified or unapprovable, state the\nassumption or the blocker in your report and proceed.\n"
PrivateBlocker
module-attribute
¶
PRIVATE_REFUSALS
module-attribute
¶
PRIVATE_REFUSALS: dict[PrivateBlocker, str] = {
"no_surface": "This channel has no direct messages.",
"already_private": "This conversation is already that user's direct messages, so there is nowhere to move it to.",
"no_user": "This run has no single user whose direct messages could be opened.",
}
GatewayRefusal ¶
Bases: Exception
A spell that cannot proceed as named, with the sentence that teaches the caller what to name instead. MCP returns it as a tool error the model can correct from — one refusal, worded once, for every runtime.
Source code in octomate/managers/gateway.py
OctomateSession
dataclass
¶
One turn's gateway: the policy the spells share, and the decision they record.
Built per turn by whoever drives one — the react node for a driven agent — and read again when the turn ends: a deciding spell stores its typed decision here, and the reflex graph performs the move. The spells themselves are projected onto each runtime's own tool mechanism by a thin adapter that owns nothing but the translation.
Source code in octomate/managers/gateway.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 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 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 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 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 | |
channels
class-attribute
instance-attribute
¶
conversation_address
class-attribute
instance-attribute
¶
decision
class-attribute
instance-attribute
¶
other_routes
class-attribute
instance-attribute
¶
destination_cache
class-attribute
instance-attribute
¶
allow_here
property
¶
Whether summon here may hand this conversation over in place.
False on a group's main channel, where pinning an owner would route every gated-in message, from any user, to one agent — and false for a native session, which has no conversation Octomate could hand over.
private_blocked_by
property
¶
Why scheme has nowhere to land from this run, or None when it does.
A gateway that knows no channels can reach no direct messages.
lands_privately
property
¶
Whether a landing should open so only its user can read it: this conversation is theirs alone, and moving it should not change that.
operations
async
property
¶
Offer addresses and channel routes without introducing another target type.
summon_unavailable
property
¶
Why this conversation cannot be handed to another agent where it is.
teleport_unavailable
property
¶
Only a stored, owned history can be imported from a native runtime.
commission_deps ¶
Require the core dependencies for running an accomplice.
Source code in octomate/managers/gateway.py
owner
async
¶
Load the authenticated account when an operation needs its details.
run_accomplice
async
¶
run_accomplice(
*,
conversations: ConversationManager,
commission_timeout: float = COMMISSION_TIMEOUT,
parent_run_id: str | None,
parent_tool_call_id: str | None,
child: Conversation,
run_name: str,
prompt: str,
model: Model | str | None,
effort: str | None,
) -> str
Source code in octomate/managers/gateway.py
publish
async
¶
Put what a served spell did on the nerve, heard on the thread at
address: on the kick's stream when one drives this turn, so the thread
the kick was asked on hears it too unless it is private, else on that
thread alone.
Source code in octomate/managers/gateway.py
destinations
async
¶
Cache optional address suggestions; execution validates its address independently.
Source code in octomate/managers/gateway.py
list_addresses
async
¶
List one level of a connected channel when it is opened, as the requester's linked identity.
A listed address is a suggestion: execution validates the one it is given.
Source code in octomate/managers/gateway.py
is_compatible_agent ¶
A driven source keeps its agent; native history needs a matching importer.
Source code in octomate/managers/gateway.py
channel_profile
async
¶
The requester's identity usable by this channel, never supplied by a tool.
Source code in octomate/managers/gateway.py
prepare_address
async
¶
Verify identity, then let the owning channel validate its address.
Source code in octomate/managers/gateway.py
direct_destination
async
¶
Resolve the requesting user's DM on the selected channel.
Source code in octomate/managers/gateway.py
resolve_route ¶
resolve_route(
agent_id: str,
model: str,
effort: str | None,
*,
spell: str,
offered: list[AgentRoute] | None = None,
) -> AgentRoute
The offered route for (agent_id, model), with the requested effort
validated against its model metadata — the shared gatekeeping of summon and
commission. Both arrive as free strings, so this is where an unrouteable
pair is caught; callers build from the returned route, never from the args.
offered is the list to check against, defaulting to this channel's. A
summon that crosses passes the far channel's, since that is who will be
asked to run it.
Source code in octomate/managers/gateway.py
projects
async
¶
A page of the caller's enabled projects, without filesystem paths.
Source code in octomate/managers/gateway.py
resolve_send
async
¶
The address a send delivers to, or None for this conversation itself.
Being in their direct messages already stops a scheme — nowhere to move
the conversation to — but never a send: that is where it was asked to go,
so it lands here rather than being refused.
Source code in octomate/managers/gateway.py
attach_native_thread
async
¶
Bind a native call to the thread its own session is filed under, as Trunkline's thread operations bind theirs, so a spell it casts acts on that history. The caller must own the thread and have written to it.
Source code in octomate/managers/gateway.py
thread_operation ¶
Package a validated user action for the graph's existing-thread entry.
Source code in octomate/managers/gateway.py
native_handoff ¶
This native session's recorded decision, packaged to be kicked as its own turn. Only a native spell leaves one, so anything else asking is a wiring bug, not a refusal a model could correct from.
Source code in octomate/managers/gateway.py
inspect
async
¶
inspect(
reveal: Literal["routes"],
channel: str | None = None,
inside: str | None = None,
*,
cursor: str | None = None,
limit: int | None = None,
) -> list[AgentRoute]
inspect(
reveal: InspectFacet,
channel: str | None = None,
inside: str | None = None,
*,
cursor: str | None = None,
limit: int | None = None,
) -> (
list[AgentRoute]
| list[ChannelAddress]
| Page[ProjectSummary]
)
Reveal current or selected-channel routes, addresses, or projects.
Only the requested facet is computed. Destinations with no channel are the
suggested addresses; with one they are a level of that channel, the top
or what inside holds, as list_addresses lists it. Neither limits which
addresses execution can validate.
Source code in octomate/managers/gateway.py
summon
async
¶
summon(
*,
agent_id: str,
model: str,
hint: str,
reason: str,
brief: str,
destination: ChannelAddress | None = None,
effort: str | None = None,
project: str | None = None,
ref: str | None = None,
) -> str | ChannelAddress
Hand over here, or open independent work at a destination.
Without a destination, record the decision for this turn's graph. With one, validate and open a thread, then kick a separate summon there. The graph creates its ledger, project workspace and handoff. Return the new address without waiting for the agent; the source decision stays put. Native sessions need a destination, but no uploaded history.
Source code in octomate/managers/gateway.py
778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 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 | |
teleport
async
¶
teleport(
*,
hint: str,
destination: ChannelAddress | None = None,
new_thread: bool = True,
project: str | None = None,
ref: str | None = None,
resume: bool = False,
prompt: str | None = None,
) -> TeleportDecision
Validate and record a teleport decision — the same agent continuing somewhere else, its history with it. How the move happens is the graph's: the run ends on the decision and the Teleport node performs it.
A thread about a project carries it: the graph lands the move in a thread
about the same project, with the work as it stands, so a teleport never
switches one and naming a project there is refused. A project binds a
thread about none: the thread landed in — a new sub-thread or crossing,
or this thread when new_thread is false, the one case a teleport may
stay put. The project and the ref are validated here, where a refusal
reaches the model; the binding itself is the graph's, on the thread that
turns out to be landed in. Binding is a trust act (a project's own
AGENTS.md reaches the agent as instructions), so it takes a registered
user; only a thread binds, so staying put is refused for a DM or a group,
before a mirror is synced for nothing.
Native history requires a stored thread and a runtime that can import its uploaded transcript.
Source code in octomate/managers/gateway.py
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 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 | |
dismiss
async
¶
Record that this thread's workspace may go: its agent has said the work in it is done. Validated here, where a refusal reaches the model; the release is the graph's, once the turn ends and its work is saved, so no tree is pulled out from under a run still in it.
Only the requesting user's tree is released. A thread about no project has nothing to release — its tree goes with the turn — and a native session runs in a directory of its own that Octomate never forked.
Source code in octomate/managers/gateway.py
scheme
async
¶
Validate and record a scheme decision, returning the sentence the scheming agent is told. The move itself is the graph's, after the turn.
Source code in octomate/managers/gateway.py
commission
async
¶
commission(
*,
conversations: ConversationManager,
commission_timeout: float = COMMISSION_TIMEOUT,
parent_id: UUID7,
parent_run_id: str | None,
parent_tool_call_id: str | None,
name: str,
agent_id: str,
model: str,
brief: str,
effort: str | None = None,
) -> str
Source code in octomate/managers/gateway.py
whisper
async
¶
whisper(
*,
conversations: ConversationManager,
commission_timeout: float = COMMISSION_TIMEOUT,
parent_id: UUID7,
parent_run_id: str | None,
parent_tool_call_id: str | None,
name: str,
message: str,
) -> str
Source code in octomate/managers/gateway.py
GatewayManager ¶
Bases: Manager
The live Octomate sessions, one per driven turn, keyed by conversation id.
In-process on purpose: a session is only meaningful while its turn is in flight, so a restart rightly forgets them all. An external runtime's tool call presents a conversation id, and this is where it finds the session of the turn driving it.
Source code in octomate/managers/gateway.py
1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 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 | |
register ¶
Hold the conversation for session, first arrival only.
Nothing else serialises turns of one conversation, so two can overlap; an external caller naming the conversation must find exactly one session, and a second run racing the first would otherwise have its calls land on the first's. So the second is refused outright rather than queued or ignored.
Source code in octomate/managers/gateway.py
unregister ¶
Source code in octomate/managers/gateway.py
get ¶
available_routes ¶
available_routes(
channels: dict[str, ChannelTentacle],
agents: dict[str, AgentTentacle],
) -> dict[str, list[AgentRoute]]
What each channel can route to: every connected agent it exposes, each answering with its own discovered or configured model routes.
The one computation behind both ReflexDeps.available_routes and the
served gateway's ephemeral native session, so a driven turn and a native
call cannot disagree about what a channel offers.
Source code in octomate/managers/gateway.py
driving
async
¶
driving(
session: OctomateSession | None,
*,
conversation_id: UUID7 | None = None,
) -> AsyncGenerator[None]
The registration span of one driven turn: external tool calls reach
session only while the run that mounted it is in flight, and a second
turn of the same conversation is refused at the door. A caller without
gateway spells supplies its conversation id to hold the same guard
without exposing a gateway session. Calls with neither remain untracked.
Source code in octomate/managers/gateway.py
octomate.managers.todos ¶
Conversation-scoped todo persistence.
TodoManager ¶
Bases: Manager
Conversation-scoped todo persistence, keyed on the short hex ref.
Persistence only — event derivation and cycle/blocking validation live in the todo capability, which owns the agent-facing behaviour.
Source code in octomate/managers/todos.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
list_todos
async
¶
Source code in octomate/managers/todos.py
get_todo
async
¶
Source code in octomate/managers/todos.py
add_todo
async
¶
add_todo(
conversation_id: UUID7,
*,
content: str,
active_form: str,
parent_ref: str | None = None,
) -> Todo
Source code in octomate/managers/todos.py
update_todo
async
¶
update_todo(
conversation_id: UUID7,
ref: str,
*,
content: str | None = None,
status: TodoStatus | None = None,
active_form: str | None = None,
parent_ref: str | None = None,
depends_on: list[str] | None = None,
) -> Todo | None
Source code in octomate/managers/todos.py
remove_todo
async
¶
Source code in octomate/managers/todos.py
write_todos
async
¶
Replace the conversation's todos with items; return (deleted, created).