Files
agentik/docs/diagrams/04-sub-agents.svg
T
subochev 25771a0c33
ci / JVM build + tests (push) Failing after 1m57s
docs(diagrams): agent architecture overview with pre-rendered SVG
PlantUML diagrams for future agent architecture (Android, multi-user
chat, sub-agents, A2A):
- 01-module-layers.md — целевая модульная структура
- 02-agent-composition.md — AgentBuilder DSL + MemoryBackend.exposesTools()
- 03-multi-user-chat.md — mention-detection sequence
- 04-sub-agents.md — spawnChild + Flow<SubAgentEvent> + A2A
- 05-android-stack.md — что меняется на Android vs Standalone

Каждый .md включает пред-рендеренный SVG (показывается во всех markdown
viewers без PlantUML plugin) + PlantUML source в code block (для
редактирования). SVG нужен потому что PlantUML требует Graphviz dot
для рендеринга — без него IntelliJ/VSCode выдают ошибку.

Регенерация SVG после правки PlantUML-source:
  docker run --rm -v "$PWD:/work" plantuml/plantuml -tsvg /work/docs/diagrams/*.md
2026-09-18 20:02:41 +03:00

1 line
14 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" data-diagram-type="DESCRIPTION" style="width:1288px;height:709px;background:#FFFFFF;" width="1288px" height="709px" viewBox="0 0 1288 709" zoomAndPan="magnify" preserveAspectRatio="none" contentStyleType="text/css"><?plantuml 1.2026.8?><defs/><g font-family="sans-serif" lengthAdjust="spacing"><g class="title" data-source-line="8"><text x="407.051" y="22.995" fill="#000" font-size="14" textLength="467.79" font-weight="700">Sub-agents + A2A между агентами (точка 2+3 из планов)</text></g><!--cluster Orch--><g class="cluster" data-qualified-name="Orch" id="ent0001" data-source-line="11"><rect x="321.12" y="386.727" width="374" height="170.6" fill="none" style="stroke:#181818;stroke-width:1;" rx="2.5" ry="2.5"/><text x="434.036" y="401.722" fill="#000" font-size="14" textLength="148.169" font-weight="700">OrchestratorAgent</text><text x="428.974" y="418.019" fill="#000" font-size="14" textLength="158.293" font-weight="700">(BaseAgent + tools)</text></g><!--cluster Sub--><g class="cluster" data-qualified-name="Sub" id="ent0007" data-source-line="29"><rect x="588.12" y="99.897" width="395" height="170.6" fill="none" style="stroke:#181818;stroke-width:1;" rx="2.5" ry="2.5"/><text x="747.079" y="114.892" fill="#000" font-size="14" textLength="77.082" font-weight="700">SubAgent</text><text x="690.207" y="131.189" fill="#000" font-size="14" textLength="190.825" font-weight="700">(изолированный scope)</text></g><!--entity MainConv--><g class="entity" data-qualified-name="Orch.MainConv" id="ent0002" data-source-line="12"><rect x="344.93" y="480.727" width="146.376" height="52.594" fill="#F1F1F1" style="stroke:#181818;stroke-width:0.5;" rx="2.5" ry="2.5"/><text x="354.93" y="503.722" fill="#000" font-size="14" textLength="126.376">ConversationLoop</text><text x="354.93" y="520.019" fill="#000" font-size="14" textLength="80.89">(main user)</text></g><!--entity SubConv--><g class="entity" data-qualified-name="Sub.SubConv" id="ent0008" data-source-line="30"><rect x="792.93" y="193.897" width="146.376" height="52.594" fill="#F1F1F1" style="stroke:#181818;stroke-width:0.5;" rx="2.5" ry="2.5"/><text x="802.93" y="216.892" fill="#000" font-size="14" textLength="126.376">ConversationLoop</text><text x="802.93" y="233.189" fill="#000" font-size="14" textLength="44.16">(child)</text></g><!--entity SubBg--><g class="entity" data-qualified-name="Sub.SubBg" id="ent0009" data-source-line="31"><rect x="612.24" y="193.897" width="145.761" height="52.594" fill="#F1F1F1" style="stroke:#181818;stroke-width:0.5;" rx="2.5" ry="2.5"/><text x="622.24" y="216.892" fill="#000" font-size="14" textLength="125.761">backgroundScope</text><text x="622.24" y="233.189" fill="#000" font-size="14" textLength="122.821">(lifecycle scoped)</text></g><!--entity SpawnAPI--><g class="entity" data-qualified-name="SpawnAPI" id="ent0003" data-source-line="16"><rect x="7" y="177.607" width="198.24" height="85.188" fill="#F1F1F1" style="stroke:#181818;stroke-width:0.5;" rx="2.5" ry="2.5"/><text x="17" y="200.602" fill="#000" font-size="14" textLength="71.955">subAgent(</text><text x="25.9" y="216.899" fill="#000" font-size="14" textLength="84.868">task: String,</text><text x="25.9" y="233.196" fill="#000" font-size="14" textLength="138.366">config: AgentConfig</text><text x="17" y="249.493" fill="#000" font-size="14" textLength="178.24">): Flow&lt;SubAgentEvent></text></g><g class="entity" data-qualified-name="GMN4" id="ent0005" data-source-line="18"><path d="M240.22,154.667 L240.22,216.197 L205.56,220.197 L240.22,224.197 L240.22,285.729 A0,0 0 0 0 240.22,285.729 L564.029,285.729 A0,0 0 0 0 564.029,285.729 L564.029,164.667 L554.029,154.667 L240.22,154.667 A0,0 0 0 0 240.22,154.667" style="stroke:#181818;stroke-width:0.5;" fill="#FEFFDD"/><path d="M554.029,154.667 L554.029,164.667 L564.029,164.667 L554.029,154.667" style="stroke:#181818;stroke-width:0.5;" fill="#FEFFDD"/><text x="246.22" y="171.734" fill="#000" font-size="13" textLength="245.8">Spawn API — НЕ отдельный модуль,</text><text x="246.22" y="186.867" fill="#000" font-size="13" textLength="225.202">а convenience поверх BaseAgent:</text><text x="246.22" y="201.999" fill="#000" font-size="13" textLength="244.493">val sub = agent.spawnChild(config) {</text><text x="262.749" y="217.132" fill="#000" font-size="13" textLength="137.662">systemPrompt = "..."</text><text x="262.749" y="232.265" fill="#000" font-size="13" textLength="192.029">tools = [ReadTool, WriteTool]</text><text x="262.749" y="247.398" fill="#000" font-size="13" textLength="286.279">memory = EmptyMemory // изолированно</text><text x="246.22" y="262.531" fill="#000" font-size="13">}</text><text x="246.22" y="277.663" fill="#000" font-size="13" textLength="159.231">sub.events.collect { ... }</text></g><!--entity AgentA--><g class="entity" data-qualified-name="AgentA" id="ent0010" data-source-line="35"><rect x="802.89" y="643.327" width="106.454" height="52.594" fill="#F1F1F1" style="stroke:#181818;stroke-width:0.5;" rx="2.5" ry="2.5"/><text x="812.89" y="666.322" fill="#000" font-size="14" textLength="55.467">Agent A</text><text x="812.89" y="682.619" fill="#000" font-size="14" textLength="86.454">(BaseAgent)</text></g><!--entity AgentB--><g class="entity" data-qualified-name="AgentB" id="ent0011" data-source-line="36"><rect x="1109.89" y="643.327" width="106.454" height="52.594" fill="#F1F1F1" style="stroke:#181818;stroke-width:0.5;" rx="2.5" ry="2.5"/><text x="1119.89" y="666.322" fill="#000" font-size="14" textLength="55.494">Agent B</text><text x="1119.89" y="682.619" fill="#000" font-size="14" textLength="86.454">(BaseAgent)</text></g><!--entity A2ASrv--><g class="entity" data-qualified-name="A2ASrv" id="ent0012" data-source-line="37"><rect x="948.58" y="480.727" width="111.075" height="52.594" fill="#F1F1F1" style="stroke:#181818;stroke-width:0.5;" rx="2.5" ry="2.5"/><text x="958.58" y="503.722" fill="#000" font-size="14" textLength="78.422">A2A Server</text><text x="958.58" y="520.019" fill="#000" font-size="14" textLength="91.075">(:a2a-server)</text></g><!--link AgentA to A2ASrv--><g class="link" data-entity-1="ent0010" data-entity-2="ent0012" id="lnk13" data-source-line="39" data-link-type="dependency"><path d="M874.4,642.877 C887.52,624.997 906.01,600.947 924.12,581.327 C939.58,564.577 954.546,550.589 969.986,537.009" style="stroke:#181818;stroke-width:1;" fill="none" id="AgentA-to-A2ASrv"/><polygon points="973.74,533.707,964.34,536.647,969.986,537.009,969.624,542.654,973.74,533.707" fill="#181818" style="stroke:#181818;stroke-width:1;stroke-linejoin:miter;stroke-miterlimit:10;"/><text x="960.137" y="594.394" fill="#000" font-size="13" textLength="42.777">POST /</text><text x="925.12" y="609.527" fill="#000" font-size="13" textLength="112.811">(application/json)</text></g><!--link A2ASrv to AgentA--><g class="link" data-entity-1="ent0012" data-entity-2="ent0010" id="lnk16" data-source-line="42" data-link-type="dependency"><path d="M948.44,509.757 C897.37,514.667 824.34,530.787 788.12,581.327 C772.9,602.557 789.085,622.808 811.315,639.998" style="stroke:#181818;stroke-width:1;" fill="none" id="A2ASrv-to-AgentA"/><polygon points="815.27,643.057,810.597,634.387,811.315,639.998,805.703,640.716,815.27,643.057" fill="#181818" style="stroke:#181818;stroke-width:1;stroke-linejoin:miter;stroke-miterlimit:10;"/><text x="789.12" y="601.894" fill="#000" font-size="13" textLength="100.045">SSE / JSON-RPC</text></g><!--link A2ASrv to AgentB--><g class="link" data-entity-1="ent0012" data-entity-2="ent0011" id="lnk14" data-source-line="40" data-link-type="dependency"><path d="M1018.21,533.477 C1031.61,556.177 1053.36,589.437 1078.12,613.327 C1089.52,624.327 1099.2,631.73 1112.42,640.2" style="stroke:#181818;stroke-width:1;" fill="none" id="A2ASrv-to-AgentB"/><polygon points="1116.63,642.897,1111.21,634.674,1112.42,640.2,1106.894,641.41,1116.63,642.897" fill="#181818" style="stroke:#181818;stroke-width:1;stroke-linejoin:miter;stroke-miterlimit:10;"/><text x="1079.12" y="601.894" fill="#000" font-size="13" textLength="123.906">dispatch(message)</text></g><!--link AgentB to A2ASrv--><g class="link" data-entity-1="ent0011" data-entity-2="ent0012" id="lnk15" data-source-line="41" data-link-type="dependency"><path d="M1190.45,643.067 C1206.33,625.057 1220.77,600.767 1207.12,581.327 C1174.07,534.247 1112.631,517.904 1064.761,511.854" style="stroke:#181818;stroke-width:1;" fill="none" id="AgentB-to-A2ASrv"/><polygon points="1059.8,511.227,1068.227,516.324,1064.761,511.854,1069.231,508.387,1059.8,511.227" fill="#181818" style="stroke:#181818;stroke-width:1;stroke-linejoin:miter;stroke-miterlimit:10;"/><text x="1213.56" y="601.894" fill="#000" font-size="13" textLength="59.332">response</text></g><!--link Orch to SpawnAPI--><g class="link" data-entity-1="ent0001" data-entity-2="ent0003" id="lnk17" data-source-line="45" data-link-type="dependency"><path d="M517.686,386.285 C517.577,386.08 517.468,385.874 517.357,385.669 C517.137,385.26 516.913,384.852 516.686,384.446 C515.779,382.821 514.822,381.226 513.813,379.665 C511.795,376.541 509.571,373.552 507.12,370.727 C420.84,271.287 344.45,337.607 223.12,286.497 C207.26,279.817 195.181,273.929 179.781,265.539" style="stroke:#181818;stroke-width:1;" fill="none" id="Orch-to-SpawnAPI"/><polygon points="175.39,263.147,181.38,270.965,179.781,265.539,185.207,263.94,175.39,263.147" fill="#181818" style="stroke:#181818;stroke-width:1;stroke-linejoin:miter;stroke-miterlimit:10;"/><text x="497.81" y="343.794" fill="#000" font-size="13" textLength="29.11">calls</text></g><!--link SpawnAPI to Sub--><g class="link" data-entity-1="ent0003" data-entity-2="ent0007" id="lnk18" data-source-line="46" data-link-type="dependency"><path d="M132.75,177.257 C153.4,148.317 184.91,112.527 223.12,96.037 C297.79,63.797 893.2,43.297 955.12,96.037 C956.388,97.116 957.597,98.241 958.752,99.409 C958.896,99.555 955.561,96.109 955.704,96.256" style="stroke:#181818;stroke-width:1;" fill="none" id="SpawnAPI-to-Sub"/><polygon points="959.182,99.849,955.795,90.6,955.704,96.256,950.048,96.165,959.182,99.849" fill="#181818" style="stroke:#181818;stroke-width:1;stroke-linejoin:miter;stroke-miterlimit:10;"/><text x="391.62" y="71.964" fill="#000" font-size="13" textLength="175.957">creates with custom config</text></g><!--link Sub to SubBg--><g class="link" data-entity-1="ent0007" data-entity-2="ent0009" id="lnk19" data-source-line="47" data-link-type="dependency"><path d="M959.182,99.849 C959.039,99.701 958.896,99.555 958.752,99.409 C957.597,98.241 956.388,97.116 955.12,96.037 C894.22,44.157 846.38,59.677 775.12,96.037 C735.28,116.367 711.007,158.921 697.627,188.911" style="stroke:#181818;stroke-width:1;" fill="none" id="Sub-to-SubBg"/><polygon points="695.59,193.477,702.91,186.888,697.627,188.911,695.604,183.628,695.59,193.477" fill="#181818" style="stroke:#181818;stroke-width:1;stroke-linejoin:miter;stroke-miterlimit:10;"/><text x="829.62" y="71.964" fill="#000" font-size="13" textLength="73.55">has its own</text></g><!--link Orch to Orch--><g class="link" data-entity-1="ent0001" data-entity-2="ent0001" id="lnk20" data-source-line="48" data-link-type="dependency"><path d="M702.12,506.497 C713.99,484.457 737.2,484.627 737.2,507.027 C737.2,529.427 716.36,533.999 704.49,511.949" style="stroke:#181818;stroke-width:1;" fill="none" id="Orch-to-Orch"/><polygon points="702.12,507.547,702.864,517.368,704.49,511.949,709.908,513.576,702.12,507.547" fill="#181818" style="stroke:#181818;stroke-width:1;stroke-linejoin:miter;stroke-miterlimit:10;"/><text x="743.2" y="511.594" fill="#000" font-size="13" textLength="130.819">main flow continues</text></g><!--link Sub to Orch--><g class="link" data-entity-1="ent0007" data-entity-2="ent0001" id="lnk21" data-source-line="49" data-link-type="dependency"><path d="M964.705,270.72 C964.657,270.827 964.609,270.934 964.561,271.041 C964.368,271.47 964.172,271.896 963.972,272.321 C963.173,274.022 962.316,275.694 961.398,277.324 C959.562,280.585 957.48,283.678 955.12,286.497 C921.078,327.157 877.589,361.153 831.436,389.288 C808.359,403.356 784.617,415.959 761.055,427.198 C749.274,432.817 737.539,438.095 725.954,443.045 C720.162,445.52 714.408,447.912 708.705,450.224 C705.853,451.38 703.014,452.516 700.19,453.632 C698.777,454.19 702.027,452.926 700.622,453.474" style="stroke:#181818;stroke-width:1;" fill="none" id="Sub-to-Orch"/><polygon points="695.964,455.291,705.802,455.747,700.622,453.474,702.895,448.294,695.964,455.291" fill="#181818" style="stroke:#181818;stroke-width:1;stroke-linejoin:miter;stroke-miterlimit:10;"/><text x="935.894" y="328.794" fill="#000" font-size="13" textLength="192.201">Flow&lt;SubAgentEvent> emits</text><text x="920.46" y="343.927" fill="#000" font-size="13" textLength="223.069">(Started / ToolCalled / ToolResult /</text><text x="922.155" y="359.059" fill="#000" font-size="13" textLength="219.68">AssistantMessage / Done / Failed)</text></g><!--link Orch to A2ASrv--><g class="link" data-entity-1="ent0001" data-entity-2="ent0012" id="lnk22" data-source-line="51" data-link-type="dependency"><path d="M696.348,507.027 C697.032,507.027 697.716,507.027 698.401,507.027 C786.093,507.027 881.985,507.027 943.12,507.027" style="stroke:#181818;stroke-width:1;" fill="none" id="Orch-to-A2ASrv"/><polygon points="948.12,507.027,939.12,503.027,943.12,507.027,939.12,511.027,948.12,507.027" fill="#181818" style="stroke:#181818;stroke-width:1;stroke-linejoin:miter;stroke-miterlimit:10;"/><text x="625.53" y="500.094" fill="#000" font-size="13" textLength="225.151">can also delegate to remote agent</text></g><?plantuml-src ZLNDRXit4BxlKmnygOHO4k3UX2R0IdM0175jU0Fq4FT0K_IAzIufa9GD8GXWEmXoI8_9iOU-GP36ZUk_l0Bt5V8a_SYLrexoW-eWSMQ--Viu7DbzgIRCi9AuBYTQ2UKoDoi46S4TKtaXaiH91qKstUsm77PBToXTIybV-bF_ZtzVFIV_rlyDuQewmUdIdr4Bf-lgfJ_tRsdjpe_ap_m7yX_z1UnN_jg_QoV93zJfT6ZJyB6mpZ2dJL0aJM9QkMrBG-eTrHemA-8PLJYj2zjU8MPZ67gQ43wt0WorEX36CYUrUgJr1FubaugcLfZQRmDYG2NF5WKrVPATi4ErN9ETxiRqhHr5v9ZTxrFcZ5JvQb1mhVPatgS86KPXHxNxTB_GXpzbSzVr0tpTY-cpa2BTUf0exS2vpCUEzDwDElGJ1O94duvUa__Jlo5mU-BVW_6BwW-m_ih_6sxZEjn5KAr6Fr3FG_zA2iL5O1-y-zFgg7f13Olz23rW1Q4nkaknysxiV3YMnQXLTzIUSni-TcQTABSCviN1OwNRxQuqndWbq3xP5cpq6C8g_Mga4-7uMuCgHQdD3B1rn9Xjr1BrUd5EKEQ5FwkEOhbXN30mqVDP_4QTNH4Oj5skYm8tGqy9DS0ir8W2aOkhzA_Z4A9bn3WB93LpIgslfwgvF8SY3FEfFw-EgvFsyX0iRXBpz9qmbkk9gCSC3lzhEddWl769WxdajCluVcxqL8so41u-XTmJVCPXZ0blt0VvpLGlFzWh73-WrdUe-nWzNABYy72_UCbBdTTFBxtz4EjyyPX-2Hry0phu38hgCc701j1zjiOwDafp_5gQcOCagLDGvzvSGttQsimUKmzER38f98zKzdwtMhMJEIQWOpwWHnA3xVYuLGfhCUdjP6xgt8vfXCKYjAA9i0YHmfXbwzIZXzdcBvtjhM4pQ7zL9xX-l4UCJirPN4ZmN3nb-79M53Pf5C68iO3U2EQ4fKFfniIdrkbolaYI0AXnWnp8CTYGMC3wK3K9uc-VubxRmve9hawggR2rzmtaAqk8H8buu2zpp3WnGc_XfGvHQIDi2pijN60vjLPQt9dRgFa3u6VyPU3dFfDmm59VLDMmoPaYLbXD8r6877rYHO3YCkoxk6oI_m00?></g></svg>