agentengine-sdk-python 0.8.7__py3-none-any.whl → 0.8.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {agentengine_sdk_python-0.8.7.dist-info → agentengine_sdk_python-0.8.9.dist-info}/METADATA +22 -20
- {agentengine_sdk_python-0.8.7.dist-info → agentengine_sdk_python-0.8.9.dist-info}/RECORD +259 -221
- ksadk/__init__.py +2 -1
- ksadk/_build_provenance.json +1 -1
- ksadk/_mcp_compat.py +305 -0
- ksadk/agent.py +29 -0
- ksadk/agui/_agent_kernel.py +176 -142
- ksadk/agui/agent.py +75 -6
- ksadk/agui/hosted.py +343 -0
- ksadk/agui/request_identity.py +11 -0
- ksadk/agui/routes.py +77 -2
- ksadk/builders/code_builder.py +30 -23
- ksadk/builders/container_builder.py +5 -5
- ksadk/builders/framework_requirements.py +1 -1
- ksadk/builders/mcp_builder.py +142 -0
- ksadk/builders/project_imports.py +66 -0
- ksadk/cli/cmd_mcp.py +1 -1
- ksadk/cli/cmd_run.py +6 -4
- ksadk/cli/cmd_web.py +12 -0
- ksadk/cli/runtime_bootstrap.py +4 -1
- ksadk/cli/runtime_logging.py +30 -0
- ksadk/common/cloud_headers.py +33 -6
- ksadk/compat/adk_compat.py +2 -0
- ksadk/compat/adk_stream.py +35 -0
- ksadk/configs/env_registry.py +31 -0
- ksadk/context_engine/capabilities.py +13 -9
- ksadk/conversations/context.py +5 -0
- ksadk/conversations/message_projection.py +28 -19
- ksadk/conversations/projector.py +6 -0
- ksadk/conversations/runtime_compaction.py +6 -2
- ksadk/conversations/runtime_input.py +4 -0
- ksadk/conversations/runtime_invocation.py +5 -1
- ksadk/conversations/runtime_metadata.py +6 -7
- ksadk/conversations/runtime_observability.py +1 -0
- ksadk/conversations/runtime_payloads.py +5 -1
- ksadk/conversations/runtime_persistence.py +23 -0
- ksadk/conversations/runtime_preparation.py +128 -5
- ksadk/detection/mcp_detector.py +80 -22
- ksadk/events/adapters/langgraph.py +53 -1
- ksadk/harness/__init__.py +3 -0
- ksadk/harness/service_presentation.py +44 -0
- ksadk/harness/service_runtime.py +1038 -0
- ksadk/interaction/providers/harness.py +9 -4
- ksadk/kernel/control.py +16 -22
- ksadk/kernel/history_projection.py +191 -58
- ksadk/kernel/ingress.py +50 -26
- ksadk/kernel/postgres_event_log.py +10 -2
- ksadk/kernel/postgres_store.py +81 -2
- ksadk/kernel/run_references.py +38 -0
- ksadk/kernel/worker.py +2 -2
- ksadk/kernel/worker_controls.py +11 -1
- ksadk/kernel/worker_identity.py +15 -8
- ksadk/knowledge_base/client.py +10 -3
- ksadk/mcp_runtime/oauth/_agent.py +77 -9
- ksadk/mcp_runtime/oauth/kernel.py +5 -0
- ksadk/mcp_runtime/oauth/langgraph.py +47 -15
- ksadk/mcp_runtime/oauth/local/broker.py +41 -9
- ksadk/mcp_runtime/oauth/local/protocol.py +3 -11
- ksadk/mcp_runtime/oauth/local/transport.py +9 -2
- ksadk/mcp_runtime/oauth/tools.py +46 -8
- ksadk/mcp_runtime/oauth/transport.py +19 -2
- ksadk/memory/adk/backends/sdk_ltm_backend.py +21 -12
- ksadk/memory/scope_ids.py +49 -0
- ksadk/plugins/providers/harness.py +65 -28
- ksadk/plugins/providers/harness_service.py +198 -0
- ksadk/plugins/providers/harness_service_context.py +175 -0
- ksadk/plugins/providers/harness_service_hooks.py +168 -0
- ksadk/plugins/providers/harness_service_memory.py +479 -0
- ksadk/plugins/providers/platform_resources.py +2 -2
- ksadk/resource_runtime/contracts.py +39 -1
- ksadk/resource_runtime/langgraph.py +7 -3
- ksadk/resource_runtime/managed_projection.py +8 -6
- ksadk/resource_runtime/mcp_server.py +3 -3
- ksadk/resource_runtime/worker.py +27 -5
- ksadk/runners/_adk_canonical_stream.py +53 -24
- ksadk/runners/_adk_tunnel_history.py +96 -0
- ksadk/runners/_langgraph_answer_contract.py +1 -7
- ksadk/runners/_langgraph_canonical_stream.py +29 -6
- ksadk/runners/_langgraph_context.py +265 -0
- ksadk/runners/_langgraph_factory.py +79 -0
- ksadk/runners/_langgraph_model_budget.py +397 -0
- ksadk/runners/_langgraph_runner_streams.py +13 -6
- ksadk/runners/_session_identity.py +8 -3
- ksadk/runners/adk_runner.py +104 -36
- ksadk/runners/langgraph_runner.py +145 -29
- ksadk/runners/usage_accumulator.py +40 -0
- ksadk/runtime/conversation_execution.py +26 -4
- ksadk/runtime/factory.py +17 -5
- ksadk/runtime/framework_adapters.py +10 -0
- ksadk/runtime/langgraph_checkpoint_view.py +28 -7
- ksadk/runtime/launch.py +2 -0
- ksadk/server/factory.py +58 -1
- ksadk/server/routes/common.py +2 -0
- ksadk/server/routes/control.py +24 -8
- ksadk/server/routes/harness_service_view.py +38 -0
- ksadk/server/routes/history_items.py +157 -0
- ksadk/server/routes/kernel_ingress.py +51 -12
- ksadk/server/routes/local_kernel_control.py +16 -0
- ksadk/server/routes/models.py +26 -0
- ksadk/server/routes/openai_compat.py +10 -3
- ksadk/server/routes/projection.py +4 -0
- ksadk/server/routes/run.py +4 -2
- ksadk/server/routes/sessions.py +20 -1
- ksadk/server/routes/ui_bootstrap.py +16 -2
- ksadk/server/static/assets/{ArtifactsPanel-Cdr5C_vM.js → ArtifactsPanel-iZ_6CAQ2.js} +1 -1
- ksadk/server/static/assets/{CodeBlock-BWRafud9.js → CodeBlock-D6uglm5n.js} +1 -1
- ksadk/server/static/assets/{MathMessageMarkdown-CFKeJIvy.js → MathMessageMarkdown-D6ojdxCG.js} +1 -1
- ksadk/server/static/assets/{MermaidBlock-BneAGUOd.js → MermaidBlock-Csk2ivT7.js} +6 -6
- ksadk/server/static/assets/{NativeTerminalPanel-BHI85zDO.js → NativeTerminalPanel-CCJA1XSH.js} +1 -1
- ksadk/server/static/assets/{OfficialA2uiRenderer-BOmT36lJ.js → OfficialA2uiRenderer-C06jus9N.js} +1 -1
- ksadk/server/static/assets/{abnfDiagram-VCTEODGH-DQvlOsBI.js → abnfDiagram-VCTEODGH-BhrF5tmL.js} +1 -1
- ksadk/server/static/assets/{arc-CGx0e4pN.js → arc-Btsh3kfy.js} +1 -1
- ksadk/server/static/assets/architecture-7GRP2DOG-BSXho3cq.js +1 -0
- ksadk/server/static/assets/{architectureDiagram-5GKGNRK7-WyybcNKX.js → architectureDiagram-5GKGNRK7-Cl8MfAmp.js} +1 -1
- ksadk/server/static/assets/{blockDiagram-NRAW4CY4-C9Cx_GVs.js → blockDiagram-NRAW4CY4-CeHSr8E_.js} +1 -1
- ksadk/server/static/assets/{c4Diagram-UCG6FXSJ-Bh7X3bGr.js → c4Diagram-UCG6FXSJ-BSD7RUKo.js} +1 -1
- ksadk/server/static/assets/channel-BpyDVKis.js +1 -0
- ksadk/server/static/assets/chunk-2Q5K7J3B-HLcpmPI2.js +1 -0
- ksadk/server/static/assets/{chunk-5VM5RSS4-cP9XupZj.js → chunk-5VM5RSS4-wz0pkBjp.js} +1 -1
- ksadk/server/static/assets/{chunk-F27PBJKO-Bm77fvR9.js → chunk-F27PBJKO-shjQ7cPM.js} +1 -1
- ksadk/server/static/assets/{chunk-G27WJ6UU-DDKNPesQ.js → chunk-G27WJ6UU-DL_MfUsu.js} +1 -1
- ksadk/server/static/assets/{chunk-JWPE2WC7-BqiUDB7s.js → chunk-JWPE2WC7-moUdwYpb.js} +1 -1
- ksadk/server/static/assets/{chunk-LCL6LL3I-C528mMZy.js → chunk-LCL6LL3I-B3QcDsZM.js} +1 -1
- ksadk/server/static/assets/{chunk-POPQ4Y6H-CzZ9g_Uf.js → chunk-POPQ4Y6H-BLBKb48A.js} +1 -1
- ksadk/server/static/assets/{chunk-RHFEMEQ7-CXj4tUZ-.js → chunk-RHFEMEQ7-CXR6ZzOx.js} +1 -1
- ksadk/server/static/assets/{chunk-SVP7TREG-BHyd85pS.js → chunk-SVP7TREG-DoR8BxkO.js} +1 -1
- ksadk/server/static/assets/{chunk-XXDRQBXY-Qe29PHGe.js → chunk-XXDRQBXY-8HJaIq0q.js} +1 -1
- ksadk/server/static/assets/classDiagram-DTDB5LWJ-DlNiRtSN.js +1 -0
- ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-DlNiRtSN.js +1 -0
- ksadk/server/static/assets/{cose-bilkent-JH36ORCC-maRKgeec.js → cose-bilkent-JH36ORCC-DnSSHHqS.js} +1 -1
- ksadk/server/static/assets/cynefin-OW5HDTMX-DxNym3qg.js +1 -0
- ksadk/server/static/assets/{cynefinDiagram-5FMLGOSQ-CoD0bEvn.js → cynefinDiagram-5FMLGOSQ-4eCi_Rw5.js} +1 -1
- ksadk/server/static/assets/{dagre-3AP2YEHR-BkpgQqyW.js → dagre-3AP2YEHR-DpPk9jsh.js} +1 -1
- ksadk/server/static/assets/{dagre-BUaTFrYa.js → dagre-G789Mawt.js} +1 -1
- ksadk/server/static/assets/{diagram-S7CK7UJ4-25HdTbjE.js → diagram-S7CK7UJ4-7x2FScRJ.js} +1 -1
- ksadk/server/static/assets/{diagram-UQ7AKVKN-KO-WqOIg.js → diagram-UQ7AKVKN-DGvliWDD.js} +1 -1
- ksadk/server/static/assets/{diagram-VSXAHHWV-B360BkDQ.js → diagram-VSXAHHWV-C0i4uEyS.js} +1 -1
- ksadk/server/static/assets/{diagram-VX7I27RA-COr1Oqsg.js → diagram-VX7I27RA-C7SmgIl5.js} +1 -1
- ksadk/server/static/assets/{diagram-Z3DM3KII-CgaKrIwB.js → diagram-Z3DM3KII-Xca7TB4U.js} +1 -1
- ksadk/server/static/assets/{dist-By-MVndb.js → dist-B3rsrE8r.js} +1 -1
- ksadk/server/static/assets/{dist-Bsuusoi0.js → dist-BM6KIyhr.js} +1 -1
- ksadk/server/static/assets/{dist-DzdXSBJb.js → dist-BMZKBrmN.js} +1 -1
- ksadk/server/static/assets/{dist-DmWw0IXB.js → dist-BUGNcOx8.js} +1 -1
- ksadk/server/static/assets/{dist-DXOlCAay.js → dist-BbIN_x76.js} +1 -1
- ksadk/server/static/assets/{dist--HftQyp9.js → dist-CGB89Aru.js} +1 -1
- ksadk/server/static/assets/{dist-DKG0OYnk.js → dist-CGIWL8mC.js} +1 -1
- ksadk/server/static/assets/{dist-DgJ57sRe.js → dist-CHeuPGXZ.js} +1 -1
- ksadk/server/static/assets/{dist-_0Xgu_07.js → dist-CMJq3QL-.js} +1 -1
- ksadk/server/static/assets/{dist-CwnkOyDn.js → dist-CiUeIDKz.js} +1 -1
- ksadk/server/static/assets/{dist-BoRn8a_t.js → dist-CmaZEf5M.js} +1 -1
- ksadk/server/static/assets/{dist-BQ116UdZ.js → dist-Cq4qlsg3.js} +1 -1
- ksadk/server/static/assets/{dist-CBo9AHUv.js → dist-DDVDyH7h.js} +1 -1
- ksadk/server/static/assets/{dist-DSw5Ju6-.js → dist-DDi9q5bO.js} +1 -1
- ksadk/server/static/assets/{dist-CxIl4t92.js → dist-DJ8mj6p4.js} +1 -1
- ksadk/server/static/assets/{dist-Brbrdmff.js → dist-DRGym1nc.js} +1 -1
- ksadk/server/static/assets/{dist-BEbS8Bag.js → dist-DcrTYAeW.js} +1 -1
- ksadk/server/static/assets/{dist-C9BTMVwS.js → dist-DpuxDDLa.js} +1 -1
- ksadk/server/static/assets/{dist-B3Jp5r1e.js → dist-EFGQ7G_k.js} +1 -1
- ksadk/server/static/assets/{dist-HHvdjADB.js → dist-IyCF0NNA.js} +1 -1
- ksadk/server/static/assets/{dist-Bxcu8Ca0.js → dist-Ny95vkRV.js} +1 -1
- ksadk/server/static/assets/{dist-CR61WJFC.js → dist-s5cohO5C.js} +1 -1
- ksadk/server/static/assets/{ebnfDiagram-PWID7BFC-DogDP2db.js → ebnfDiagram-PWID7BFC-DNwVczAJ.js} +1 -1
- ksadk/server/static/assets/{erDiagram-SSCWMZ5O-CeBDnUjR.js → erDiagram-SSCWMZ5O-OxFlhx6v.js} +1 -1
- ksadk/server/static/assets/eventmodeling-NTZA5JFV-C-gXDupK.js +1 -0
- ksadk/server/static/assets/flowDiagram-A5DVABFB-CkpCYD4e.js +1 -0
- ksadk/server/static/assets/{ganttDiagram-EL5Y4UJY-oIQL3MCp.js → ganttDiagram-EL5Y4UJY-D4krNgUz.js} +1 -1
- ksadk/server/static/assets/gitGraph-4MIJSDKK-0RSkEgC5.js +1 -0
- ksadk/server/static/assets/{gitGraphDiagram-WWUBYQGX-B7qz0cmZ.js → gitGraphDiagram-WWUBYQGX-BUSVPN1s.js} +1 -1
- ksadk/server/static/assets/index-B9UP7He9.css +2 -0
- ksadk/server/static/assets/index-COn4kn-G.js +1135 -0
- ksadk/server/static/assets/info-A6RAGUB7-C6KX7WO4.js +1 -0
- ksadk/server/static/assets/{infoDiagram-RXCK75RN-yQRC41Ya.js → infoDiagram-RXCK75RN-b6w3u3-O.js} +1 -1
- ksadk/server/static/assets/{ishikawaDiagram-5VMMS53U-BCu4HiwL.js → ishikawaDiagram-5VMMS53U-CsC7gzRt.js} +1 -1
- ksadk/server/static/assets/{journeyDiagram-EYS64GPL-JaqmO73K.js → journeyDiagram-EYS64GPL-BATLNoy1.js} +1 -1
- ksadk/server/static/assets/{kanban-definition-3QL26DDD-DQo4X8NO.js → kanban-definition-3QL26DDD-C49zL_s0.js} +1 -1
- ksadk/server/static/assets/{katex-t_DWylQw.js → katex-CDVgGGy2.js} +1 -1
- ksadk/server/static/assets/{linear-DWdnI35B.js → linear-DkyDumSy.js} +1 -1
- ksadk/server/static/assets/{mermaid-parser.core-BHrT2Pfe.js → mermaid-parser.core-BDX-LqSy.js} +2 -2
- ksadk/server/static/assets/{mindmap-definition-FBJOCRG2-PBVAhZYV.js → mindmap-definition-FBJOCRG2-DRPnzL2n.js} +1 -1
- ksadk/server/static/assets/packet-AYTQ26CC-CMMupxPW.js +1 -0
- ksadk/server/static/assets/{pegDiagram-XKGWAZYB-CU_cLfow.js → pegDiagram-XKGWAZYB-Zm-xrNrr.js} +1 -1
- ksadk/server/static/assets/pie-WAS4IAKB-Bfo0pa9v.js +1 -0
- ksadk/server/static/assets/{pieDiagram-E7YTZNPT-B1h0-_pW.js → pieDiagram-E7YTZNPT-a8C1Jxo4.js} +1 -1
- ksadk/server/static/assets/{quadrantDiagram-AXDQQJYC-DEMoGo5a.js → quadrantDiagram-AXDQQJYC-ihH8znBv.js} +1 -1
- ksadk/server/static/assets/radar-RG4KPBEZ-PRBiHoJx.js +1 -0
- ksadk/server/static/assets/railroad-74A4TZTK-BCJ-XMRJ.js +1 -0
- ksadk/server/static/assets/railroad-abnf-HS5TGJTU-Bbttj0Jz.js +1 -0
- ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-Bo18264J.js +1 -0
- ksadk/server/static/assets/railroad-peg-WCYAUIDC-xZDJTFLD.js +1 -0
- ksadk/server/static/assets/{railroadDiagram-O6MQD6OU-BTAob2wg.js → railroadDiagram-O6MQD6OU-DD9lFfXo.js} +1 -1
- ksadk/server/static/assets/{requirementDiagram-EFPCY7ZU-Dl0Q2SuO.js → requirementDiagram-EFPCY7ZU-CGn93Iyb.js} +1 -1
- ksadk/server/static/assets/{sankeyDiagram-P5KCCOFB-DeaTWkur.js → sankeyDiagram-P5KCCOFB-BuyjrHuW.js} +1 -1
- ksadk/server/static/assets/{sequenceDiagram-WJ2MYXX4-gFQYrsOd.js → sequenceDiagram-WJ2MYXX4-D-Iw-30A.js} +1 -1
- ksadk/server/static/assets/{sizeCapture-X5ZJPWSS-pGQzddMB.js → sizeCapture-X5ZJPWSS-B0EHLwrD.js} +1 -1
- ksadk/server/static/assets/{stateDiagram-HBIQ2CUA-DmpYOZt1.js → stateDiagram-HBIQ2CUA-k9Zyg69R.js} +1 -1
- ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-tUEVnq9-.js +1 -0
- ksadk/server/static/assets/{swimlanes-XN3QIQJK-BfuSAsrr.js → swimlanes-XN3QIQJK-D2BewKmp.js} +1 -1
- ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-CGBmsrCQ.js +8 -0
- ksadk/server/static/assets/{timeline-definition-24CTP7MA-CgJwrrxf.js → timeline-definition-24CTP7MA-czSzsYbz.js} +1 -1
- ksadk/server/static/assets/treeView-Q6P3EWNA-CrEvfC8M.js +1 -0
- ksadk/server/static/assets/treemap-WGGIJYW6-D1TmShtn.js +1 -0
- ksadk/server/static/assets/{vennDiagram-4TSXK5OY-CBSAgXDd.js → vennDiagram-4TSXK5OY-BJF_qZLF.js} +1 -1
- ksadk/server/static/assets/wardley-WFR3VGLG-0gZiSyL0.js +1 -0
- ksadk/server/static/assets/{wardleyDiagram-VM6X3IG4-013TZ2JZ.js → wardleyDiagram-VM6X3IG4-BfwUuJpr.js} +1 -1
- ksadk/server/static/assets/{xychartDiagram-S5SC5T6Z-u6Frp8xp.js → xychartDiagram-S5SC5T6Z-Ci6Nsp4p.js} +1 -1
- ksadk/server/static/index.html +2 -2
- ksadk/server/static/ui-source.json +6 -6
- ksadk/sessions/_postgres_history_backfill.py +80 -0
- ksadk/sessions/_postgres_schema.py +117 -0
- ksadk/sessions/_postgres_tables.py +6 -0
- ksadk/sessions/base.py +24 -0
- ksadk/sessions/history_tool_refs.py +244 -0
- ksadk/sessions/in_memory.py +42 -0
- ksadk/sessions/local_service.py +78 -0
- ksadk/sessions/model_history.py +20 -0
- ksadk/sessions/postgres_service.py +215 -19
- ksadk/sessions/resilient.py +24 -0
- ksadk/skills/mcp_server/server.py +239 -217
- ksadk/studio/contracts.py +8 -0
- ksadk/studio/mcp_runtime.py +23 -8
- ksadk/studio/native_mcp_disclosure.py +8 -6
- ksadk/studio/native_mcp_tool_port.py +3 -1
- ksadk/studio/native_memory_context.py +10 -8
- ksadk/studio/native_product.py +3 -4
- ksadk/studio/plugin_composition.py +8 -1
- ksadk/studio/plugin_native_activation.py +4 -2
- ksadk/studio/plugin_runtime.py +9 -0
- ksadk/studio/service.py +2 -0
- ksadk/studio/static/assets/{ChannelsPage-Do_mRmVu.js → ChannelsPage-Ot9iV_QP.js} +1 -1
- ksadk/studio/static/assets/{CodeBlock-DMIf4h33-CsO7rJKv.js → CodeBlock-DMIf4h33-Cfs6se0v.js} +1 -1
- ksadk/studio/static/assets/{MathMessageMarkdown-BesSeCYl-CiB60plG.js → MathMessageMarkdown-BesSeCYl-BIBDiQAl.js} +1 -1
- ksadk/studio/static/assets/{MessageMarkdown-CwMTvgFj-BzEmQkHH.js → MessageMarkdown-CwMTvgFj-CWM4n-9K.js} +2 -2
- ksadk/studio/static/assets/{OfficialA2uiRenderer-DI49Kpxu-BBxfdj3P.js → OfficialA2uiRenderer-DI49Kpxu-BZSumE9D.js} +1 -1
- ksadk/studio/static/assets/{TeamsPage-qNVYpcox.js → TeamsPage-CVOpMIMf.js} +2 -2
- ksadk/studio/static/assets/index-CW1D-Kqg.css +2 -0
- ksadk/studio/static/assets/index-DMexeQ1-.js +1155 -0
- ksadk/studio/static/index.html +3 -3
- ksadk/studio/static/ui-source.json +6 -6
- ksadk/tracing/setup.py +53 -3
- ksadk/tunnel/__init__.py +37 -0
- ksadk/tunnel/connector.py +384 -0
- ksadk/tunnel/discovery.py +107 -0
- ksadk/tunnel/failure.py +168 -0
- ksadk/tunnel/http_tools.py +100 -0
- ksadk/tunnel/langgraph.py +125 -0
- ksadk/tunnel/middleware.py +28 -0
- ksadk/tunnel/peers.py +872 -0
- ksadk/tunnel/protocol.py +97 -0
- ksadk/tunnel/registry.py +306 -0
- ksadk/tunnel/runtime.py +147 -0
- ksadk/tunnel/server.py +201 -0
- ksadk/tunnel/services.py +366 -0
- ksadk/tunnel/toolset.py +78 -0
- ksadk/version.py +1 -1
- ksadk_runtime_common/memory_backend/providers/mem0.py +20 -0
- ksadk/server/static/assets/architecture-7GRP2DOG-CFWjFkDL.js +0 -1
- ksadk/server/static/assets/channel-D6Dp_l74.js +0 -1
- ksadk/server/static/assets/chunk-2Q5K7J3B-CwmjhFYK.js +0 -1
- ksadk/server/static/assets/classDiagram-DTDB5LWJ-DsbvkCAV.js +0 -1
- ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-DsbvkCAV.js +0 -1
- ksadk/server/static/assets/cynefin-OW5HDTMX-CBZRVuc4.js +0 -1
- ksadk/server/static/assets/eventmodeling-NTZA5JFV-vXZWMkpn.js +0 -1
- ksadk/server/static/assets/flowDiagram-A5DVABFB-5LRgzKLv.js +0 -1
- ksadk/server/static/assets/gitGraph-4MIJSDKK-BUWSkncI.js +0 -1
- ksadk/server/static/assets/index-4g1ndaxW.js +0 -1132
- ksadk/server/static/assets/index-DEVfafsU.css +0 -2
- ksadk/server/static/assets/info-A6RAGUB7-CzJ_YrOs.js +0 -1
- ksadk/server/static/assets/packet-AYTQ26CC-CXoos6fx.js +0 -1
- ksadk/server/static/assets/pie-WAS4IAKB-CjF9NoIt.js +0 -1
- ksadk/server/static/assets/radar-RG4KPBEZ-BQGWs9nw.js +0 -1
- ksadk/server/static/assets/railroad-74A4TZTK-B6znvLUK.js +0 -1
- ksadk/server/static/assets/railroad-abnf-HS5TGJTU-Bzquz0As.js +0 -1
- ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-1IikGkb5.js +0 -1
- ksadk/server/static/assets/railroad-peg-WCYAUIDC-BKKgHzdc.js +0 -1
- ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-Dolxgkw3.js +0 -1
- ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-BuI1erYj.js +0 -8
- ksadk/server/static/assets/treeView-Q6P3EWNA-DtMdDH8N.js +0 -1
- ksadk/server/static/assets/treemap-WGGIJYW6-VoU8QtLZ.js +0 -1
- ksadk/server/static/assets/wardley-WFR3VGLG-YWSRB0Zm.js +0 -1
- ksadk/studio/static/assets/index-Cp9Unfkn.css +0 -2
- ksadk/studio/static/assets/index-HepnaEeR.js +0 -1152
- {agentengine_sdk_python-0.8.7.dist-info → agentengine_sdk_python-0.8.9.dist-info}/WHEEL +0 -0
- {agentengine_sdk_python-0.8.7.dist-info → agentengine_sdk_python-0.8.9.dist-info}/entry_points.txt +0 -0
- {agentengine_sdk_python-0.8.7.dist-info → agentengine_sdk_python-0.8.9.dist-info}/licenses/LICENSE +0 -0
- {agentengine_sdk_python-0.8.7.dist-info → agentengine_sdk_python-0.8.9.dist-info}/top_level.txt +0 -0
ksadk/resource_runtime/worker.py
CHANGED
|
@@ -14,7 +14,11 @@ import httpx
|
|
|
14
14
|
from pydantic import ConfigDict, Field, SecretStr, field_validator, model_validator
|
|
15
15
|
from requests.exceptions import RequestException
|
|
16
16
|
|
|
17
|
-
from ksadk.common.cloud_headers import
|
|
17
|
+
from ksadk.common.cloud_headers import (
|
|
18
|
+
DEFAULT_TRAFFIC_SOURCE,
|
|
19
|
+
resolve_component_env,
|
|
20
|
+
resolve_traffic_source,
|
|
21
|
+
)
|
|
18
22
|
from ksadk.knowledge_base.client import KnowledgeBaseClient
|
|
19
23
|
from ksadk.memory.adk.backends.sdk_ltm_backend import SdkLTMBackend
|
|
20
24
|
from ksadk.memory.models import MemorySearchRequest
|
|
@@ -24,6 +28,7 @@ from ksadk.resource_runtime.contracts import (
|
|
|
24
28
|
Identifier,
|
|
25
29
|
InvocationIdentity,
|
|
26
30
|
ResourceConfig,
|
|
31
|
+
collect_dataset_instructions,
|
|
27
32
|
validate_resource_bindings,
|
|
28
33
|
)
|
|
29
34
|
from ksadk.resource_runtime.discovery_receipts import DiscoverySkillReceipt, discovery_scope_key
|
|
@@ -72,12 +77,15 @@ class KnowledgeWorkerBinding(ExplicitWorkerBinding):
|
|
|
72
77
|
resource_kind: ClassVar[str] = "knowledge-base"
|
|
73
78
|
|
|
74
79
|
def create_service(
|
|
75
|
-
self, *, traffic_source: str = DEFAULT_TRAFFIC_SOURCE
|
|
80
|
+
self, *, traffic_source: str = DEFAULT_TRAFFIC_SOURCE, component_env: str = ""
|
|
76
81
|
) -> BoundKnowledgeService:
|
|
77
82
|
endpoint = urlsplit(self.endpoint)
|
|
83
|
+
# Collect all dataset IDs: primary binding + additional datasets.
|
|
84
|
+
all_ids = [self.config.binding.resource.id, *self.config.additional_dataset_ids]
|
|
78
85
|
client = KnowledgeBaseClient(
|
|
79
|
-
|
|
86
|
+
dataset_ids=all_ids,
|
|
80
87
|
traffic_source=traffic_source,
|
|
88
|
+
component_env=component_env,
|
|
81
89
|
region=self.config.binding.resource.region,
|
|
82
90
|
endpoint=endpoint.netloc,
|
|
83
91
|
scheme=endpoint.scheme,
|
|
@@ -85,6 +93,10 @@ class KnowledgeWorkerBinding(ExplicitWorkerBinding):
|
|
|
85
93
|
secret_key=self.secret_key.get_secret_value(),
|
|
86
94
|
session_token=self.session_token.get_secret_value(),
|
|
87
95
|
)
|
|
96
|
+
# Inject per-dataset custom instructions from retrieval + additional_retrievals.
|
|
97
|
+
instructions = collect_dataset_instructions(self.config)
|
|
98
|
+
if instructions:
|
|
99
|
+
client.dataset_instructions = instructions
|
|
88
100
|
return BoundKnowledgeService(self.config, client)
|
|
89
101
|
|
|
90
102
|
|
|
@@ -92,12 +104,17 @@ class MemoryWorkerBinding(ExplicitWorkerBinding):
|
|
|
92
104
|
resource_kind: ClassVar[str] = "memory-instance"
|
|
93
105
|
|
|
94
106
|
def create_provider(
|
|
95
|
-
self,
|
|
107
|
+
self,
|
|
108
|
+
identity: InvocationIdentity,
|
|
109
|
+
*,
|
|
110
|
+
traffic_source: str = DEFAULT_TRAFFIC_SOURCE,
|
|
111
|
+
component_env: str = "",
|
|
96
112
|
) -> AicpMemoryProvider:
|
|
97
113
|
endpoint = urlsplit(self.endpoint)
|
|
98
114
|
backend = SdkLTMBackend(
|
|
99
115
|
index="bound-resource",
|
|
100
116
|
traffic_source=traffic_source,
|
|
117
|
+
component_env=component_env,
|
|
101
118
|
memory_collection_id=self.config.binding.resource.id,
|
|
102
119
|
namespace=self.config.binding.resource.id,
|
|
103
120
|
agent_id=identity.agent_id,
|
|
@@ -233,6 +250,7 @@ class WorkerInitialization(PluginContractModel):
|
|
|
233
250
|
# Resolve in the trusted parent and serialize on stdin; never inherit the
|
|
234
251
|
# parent's environment or mutate global process state in a shared host.
|
|
235
252
|
traffic_source: str = Field(default_factory=resolve_traffic_source)
|
|
253
|
+
component_env: str = Field(default_factory=resolve_component_env)
|
|
236
254
|
resource_snapshot: ResourceSnapshot
|
|
237
255
|
bindings: tuple[
|
|
238
256
|
KnowledgeWorkerBinding
|
|
@@ -363,9 +381,13 @@ def main() -> int:
|
|
|
363
381
|
else binding.create_provider(
|
|
364
382
|
scopes[binding.config.binding.id].identity,
|
|
365
383
|
traffic_source=initialization.traffic_source,
|
|
384
|
+
component_env=initialization.component_env,
|
|
366
385
|
)
|
|
367
386
|
if isinstance(binding, MemoryWorkerBinding)
|
|
368
|
-
else binding.create_service(
|
|
387
|
+
else binding.create_service(
|
|
388
|
+
traffic_source=initialization.traffic_source,
|
|
389
|
+
component_env=initialization.component_env,
|
|
390
|
+
)
|
|
369
391
|
if isinstance(binding, KnowledgeWorkerBinding)
|
|
370
392
|
else binding.create_service()
|
|
371
393
|
)
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
import time
|
|
6
5
|
import logging
|
|
6
|
+
import time
|
|
7
7
|
import traceback
|
|
8
|
-
from pathlib import Path
|
|
9
8
|
from collections.abc import AsyncGenerator, AsyncIterator
|
|
9
|
+
from pathlib import Path
|
|
10
10
|
from typing import Any
|
|
11
11
|
|
|
12
12
|
from ksadk.events.adapters.adk import ADKAdapterContext, ADKEventAdapter
|
|
@@ -32,7 +32,8 @@ from ksadk.events.canonical import (
|
|
|
32
32
|
)
|
|
33
33
|
from ksadk.events.content import DataContent, TextContent, ToolCallContent, ToolResultContent
|
|
34
34
|
from ksadk.events.identity import stable_event_id, stable_scope_id
|
|
35
|
-
from ksadk.runners.usage_accumulator import
|
|
35
|
+
from ksadk.runners.usage_accumulator import ADKUsageAccumulator
|
|
36
|
+
from ksadk.runtime.usage import canonical_usage_payload
|
|
36
37
|
from ksadk.tools.gateway import approval_interrupt_info_from_result
|
|
37
38
|
|
|
38
39
|
|
|
@@ -49,13 +50,24 @@ async def canonical_events(
|
|
|
49
50
|
context = ADKAdapterContext(run_id=run_id)
|
|
50
51
|
adapter = ADKEventAdapter()
|
|
51
52
|
root_scope_id = stable_scope_id("adk", run_id)
|
|
53
|
+
usage_accumulator = ADKUsageAccumulator()
|
|
52
54
|
usage: dict[str, Any] = {}
|
|
53
|
-
last_usage: dict[str, Any] = {}
|
|
54
55
|
approval_ids: set[str] = set()
|
|
55
56
|
message_snapshots: dict[tuple[str, str], dict[str, str]] = {}
|
|
57
|
+
pending_tool_calls = set()
|
|
56
58
|
managed_descriptors = {}
|
|
57
59
|
root_transfer_target = None
|
|
58
60
|
|
|
61
|
+
def source() -> SourceRef:
|
|
62
|
+
return SourceRef(
|
|
63
|
+
framework="adk",
|
|
64
|
+
metadata={
|
|
65
|
+
"session_id": session_id,
|
|
66
|
+
**({"last_usage": usage_accumulator.last_usage} if usage_accumulator.last_usage else {}),
|
|
67
|
+
**({"usage": usage} if usage else {}),
|
|
68
|
+
},
|
|
69
|
+
)
|
|
70
|
+
|
|
59
71
|
def envelope(event_type: str, occurrence: str = "run") -> dict[str, Any]:
|
|
60
72
|
return {
|
|
61
73
|
"schema_version": 2,
|
|
@@ -72,17 +84,11 @@ async def canonical_events(
|
|
|
72
84
|
),
|
|
73
85
|
"seq": context.allocate_seq(),
|
|
74
86
|
"timestamp": time.time(),
|
|
75
|
-
"source":
|
|
76
|
-
framework="adk",
|
|
77
|
-
metadata={
|
|
78
|
-
"session_id": session_id,
|
|
79
|
-
**({"last_usage": last_usage} if last_usage else {}),
|
|
80
|
-
**({"usage": usage} if usage else {}),
|
|
81
|
-
},
|
|
82
|
-
),
|
|
87
|
+
"source": source(),
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
stream_failure: str | None = None
|
|
91
|
+
tunnel_outcome = None
|
|
86
92
|
stream_failure_code = "adk_stream_error"
|
|
87
93
|
yield RunStarted(**envelope("run.started"), status="running")
|
|
88
94
|
try:
|
|
@@ -94,13 +100,16 @@ async def canonical_events(
|
|
|
94
100
|
if target:
|
|
95
101
|
root_transfer_target = target
|
|
96
102
|
|
|
97
|
-
|
|
98
|
-
if event_usage:
|
|
99
|
-
usage = accumulate_usage(usage, event_usage)
|
|
100
|
-
last_usage = event_usage
|
|
103
|
+
usage_accumulator.observe(native_event, runner._extract_event_usage(native_event))
|
|
101
104
|
|
|
102
105
|
approval_signals = list(runner._extract_approval_signals(native_event))
|
|
103
106
|
for event in adapter.map(native_event, context):
|
|
107
|
+
if isinstance(event, ItemCompleted):
|
|
108
|
+
for part in event.snapshot.parts:
|
|
109
|
+
if isinstance(part, ToolCallContent):
|
|
110
|
+
pending_tool_calls.add((event.scope_id, part.call_id))
|
|
111
|
+
elif isinstance(part, ToolResultContent):
|
|
112
|
+
pending_tool_calls.discard((event.scope_id, part.call_id))
|
|
104
113
|
if isinstance(event, ItemCompleted) and event.item_kind in {"message", "artifact"}:
|
|
105
114
|
message_snapshots[(event.scope_id, event.item_id)] = {
|
|
106
115
|
part.part_id: part.text
|
|
@@ -176,6 +185,9 @@ async def canonical_events(
|
|
|
176
185
|
),
|
|
177
186
|
)
|
|
178
187
|
except Exception as exc: # noqa: BLE001
|
|
188
|
+
from ksadk.tunnel.failure import tunnel_failure
|
|
189
|
+
|
|
190
|
+
tunnel_outcome = tunnel_failure(exc)
|
|
179
191
|
if getattr(runner, "_managed_a2a_bootstrap", None) is not None:
|
|
180
192
|
# Keep diagnostic locations server-side. Never log exception text,
|
|
181
193
|
# source lines or local values: provider errors can embed credentials.
|
|
@@ -229,15 +241,32 @@ async def canonical_events(
|
|
|
229
241
|
)
|
|
230
242
|
context.mark_failed((scope_id, item_id))
|
|
231
243
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
cached_tokens=int(usage.get("cached_tokens") or 0),
|
|
239
|
-
reasoning_tokens=int(usage.get("reasoning_tokens") or 0),
|
|
244
|
+
usage = usage_accumulator.total()
|
|
245
|
+
for snapshot in usage_accumulator.snapshots.values():
|
|
246
|
+
fields = envelope("usage.reported", f"{snapshot.invocation_id}:{snapshot.response_id}")
|
|
247
|
+
fields["source"] = SourceRef(
|
|
248
|
+
framework="adk", native_run_id=snapshot.invocation_id or None,
|
|
249
|
+
metadata={"usage_contract": "adk_model_call_delta_v1"},
|
|
240
250
|
)
|
|
251
|
+
if snapshot.timestamp is not None:
|
|
252
|
+
fields["timestamp"] = snapshot.timestamp
|
|
253
|
+
counts = canonical_usage_payload(snapshot.usage, runtime_type="adk")
|
|
254
|
+
del counts["source"]
|
|
255
|
+
yield UsageReported(**fields, **counts)
|
|
256
|
+
|
|
257
|
+
if tunnel_outcome is not None:
|
|
258
|
+
from ksadk.tunnel.failure import failure_events
|
|
259
|
+
|
|
260
|
+
for event in failure_events(
|
|
261
|
+
tunnel_outcome,
|
|
262
|
+
run_id=run_id,
|
|
263
|
+
scope_id=root_scope_id,
|
|
264
|
+
source=source(),
|
|
265
|
+
allocate_seq=context.allocate_seq,
|
|
266
|
+
pending_calls=sorted(pending_tool_calls),
|
|
267
|
+
):
|
|
268
|
+
yield event
|
|
269
|
+
return
|
|
241
270
|
|
|
242
271
|
output_refs = context.output_refs
|
|
243
272
|
if not output_refs and managed_descriptors:
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""Keep a failed tunnel turn valid in ADK's own multi-turn model history."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from contextlib import aclosing
|
|
5
|
+
|
|
6
|
+
from ksadk.compat.adk_compat import Event
|
|
7
|
+
from ksadk.compat.adk_compat import genai_types as types
|
|
8
|
+
from ksadk.tunnel.failure import tunnel_failure
|
|
9
|
+
from ksadk.tunnel.protocol import TunnelError
|
|
10
|
+
|
|
11
|
+
logger = logging.getLogger(__name__)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
async def preserve_tunnel_history(events, *, session_service, app_name, user_id, session_id):
|
|
15
|
+
# A resumed invocation may contain older calls. Only close calls emitted by
|
|
16
|
+
# this iterator, in this session, for which ADK did not persist a response.
|
|
17
|
+
call_events = set()
|
|
18
|
+
deferred_error = None
|
|
19
|
+
try:
|
|
20
|
+
async with aclosing(events):
|
|
21
|
+
async for event in events:
|
|
22
|
+
# Workflow-backed ADK emits an error event just before raising
|
|
23
|
+
# the original exception. Give it one iteration to propagate
|
|
24
|
+
# the typed failure; preserve ordinary error-only streams.
|
|
25
|
+
if deferred_error is not None:
|
|
26
|
+
yield deferred_error
|
|
27
|
+
deferred_error = None
|
|
28
|
+
if event.error_code in {"TunnelError", "ExceptionGroup"}:
|
|
29
|
+
deferred_error = event
|
|
30
|
+
continue
|
|
31
|
+
if not event.partial and event.get_function_calls():
|
|
32
|
+
call_events.add(event.id)
|
|
33
|
+
yield event
|
|
34
|
+
if deferred_error is not None:
|
|
35
|
+
yield deferred_error
|
|
36
|
+
except Exception as exc:
|
|
37
|
+
failure = tunnel_failure(exc)
|
|
38
|
+
if failure is not None and call_events:
|
|
39
|
+
outcome = failure
|
|
40
|
+
try:
|
|
41
|
+
session = await session_service.get_session(
|
|
42
|
+
app_name=app_name, user_id=user_id, session_id=session_id
|
|
43
|
+
)
|
|
44
|
+
if session is not None:
|
|
45
|
+
pending = _pending_calls(session, call_events)
|
|
46
|
+
outcome = failure.for_unanswered_calls(sum(map(len, pending.values())))
|
|
47
|
+
await _close_pending_calls(session_service, session, pending, outcome)
|
|
48
|
+
except Exception as storage_error:
|
|
49
|
+
# Persistence failures must not erase the user's outcome-unknown notification.
|
|
50
|
+
logger.warning(
|
|
51
|
+
"Could not persist ADK tunnel failure (%s)", type(storage_error).__name__
|
|
52
|
+
)
|
|
53
|
+
if outcome != failure:
|
|
54
|
+
raise TunnelError(outcome.result_code, indeterminate=outcome.indeterminate) from exc
|
|
55
|
+
raise
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _pending_calls(session, call_events):
|
|
59
|
+
pending = {}
|
|
60
|
+
for event in session.events:
|
|
61
|
+
if event.partial:
|
|
62
|
+
continue
|
|
63
|
+
scope = (event.invocation_id, event.branch, event.author)
|
|
64
|
+
if event.id in call_events:
|
|
65
|
+
for call in event.get_function_calls():
|
|
66
|
+
if call.id and call.id not in (event.long_running_tool_ids or ()):
|
|
67
|
+
pending.setdefault(scope, {})[call.id] = call
|
|
68
|
+
if scope in pending:
|
|
69
|
+
for response in event.get_function_responses():
|
|
70
|
+
pending[scope].pop(response.id, None)
|
|
71
|
+
return pending
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
async def _close_pending_calls(service, session, pending, failure):
|
|
75
|
+
for (invocation_id, branch, author), calls in pending.items():
|
|
76
|
+
if not calls:
|
|
77
|
+
continue
|
|
78
|
+
parts = [
|
|
79
|
+
types.Part(
|
|
80
|
+
function_response=types.FunctionResponse(
|
|
81
|
+
id=call.id, name=call.name, response=failure.tool_result
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
for call in calls.values()
|
|
85
|
+
]
|
|
86
|
+
origin = dict(invocation_id=invocation_id, branch=branch, author=author)
|
|
87
|
+
await service.append_event(
|
|
88
|
+
session, Event(**origin, content=types.Content(role="user", parts=parts))
|
|
89
|
+
)
|
|
90
|
+
await service.append_event(
|
|
91
|
+
session,
|
|
92
|
+
Event(
|
|
93
|
+
**origin,
|
|
94
|
+
content=types.Content(role="model", parts=[types.Part(text=failure.message)]),
|
|
95
|
+
),
|
|
96
|
+
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Preserve final-answer snapshot precedence without suppressing model tokens."""
|
|
2
2
|
|
|
3
3
|
from collections.abc import Mapping
|
|
4
4
|
|
|
@@ -20,12 +20,6 @@ def has_explicit_answer_field(graph) -> bool:
|
|
|
20
20
|
return "output" in properties or "answer" in properties
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
def uses_explicit_answer_contract(graph) -> bool:
|
|
24
|
-
"""Use only the graph's public output schema; unknown shapes stay streaming."""
|
|
25
|
-
properties = _output_properties(graph)
|
|
26
|
-
return "messages" not in properties and ("output" in properties or "answer" in properties)
|
|
27
|
-
|
|
28
|
-
|
|
29
23
|
def internal_model_event(event: RuntimeEvent) -> RuntimeEvent:
|
|
30
24
|
"""Keep model traces observable without publishing them as graph answers."""
|
|
31
25
|
if getattr(event, "item_kind", None) not in {"message", "reasoning"}:
|
|
@@ -14,8 +14,8 @@ from ksadk.events.runtime_event import RuntimeEvent
|
|
|
14
14
|
from ksadk.runners._langgraph_answer_contract import (
|
|
15
15
|
has_explicit_answer_field,
|
|
16
16
|
internal_model_event,
|
|
17
|
-
uses_explicit_answer_contract,
|
|
18
17
|
)
|
|
18
|
+
from ksadk.runners._langgraph_model_budget import model_budget_scope
|
|
19
19
|
from ksadk.runners._langgraph_fresh_turn import fresh_memory_input, fresh_user_checkpoint
|
|
20
20
|
from ksadk.runtime.skill_eval_result import skill_eval_response_fields
|
|
21
21
|
from ksadk.runtime.timing import extract_timing
|
|
@@ -62,6 +62,7 @@ class _LangGraphCanonicalStreamMixin:
|
|
|
62
62
|
yield event
|
|
63
63
|
|
|
64
64
|
@fresh_user_checkpoint
|
|
65
|
+
@model_budget_scope
|
|
65
66
|
async def _stream_native_canonical_events(
|
|
66
67
|
self, input_data: Dict[str, Any]
|
|
67
68
|
) -> AsyncIterator[RuntimeEvent]:
|
|
@@ -84,6 +85,7 @@ class _LangGraphCanonicalStreamMixin:
|
|
|
84
85
|
from ksadk.events.canonical import (
|
|
85
86
|
ErrorInfo,
|
|
86
87
|
InteractionRequested,
|
|
88
|
+
ItemStarted,
|
|
87
89
|
OutputRef,
|
|
88
90
|
RunCompleted,
|
|
89
91
|
RunFailed,
|
|
@@ -175,10 +177,8 @@ class _LangGraphCanonicalStreamMixin:
|
|
|
175
177
|
state = resume_value
|
|
176
178
|
elif is_resume and not is_gateway_approval_resume:
|
|
177
179
|
state = self._unwrap_resume_value(resume_value)
|
|
178
|
-
elif self._has_prepare_state_hook():
|
|
179
|
-
state = self._prepare_state_with_hook(payload, session_id, history)
|
|
180
180
|
else:
|
|
181
|
-
state = self.
|
|
181
|
+
state = await self._prepare_new_turn_state(payload, session_id, history, config=config)
|
|
182
182
|
|
|
183
183
|
if not is_resume and not is_checkpoint_resume:
|
|
184
184
|
state = await fresh_memory_input(self._agent, config, state)
|
|
@@ -344,7 +344,6 @@ class _LangGraphCanonicalStreamMixin:
|
|
|
344
344
|
from ksadk.runners._langgraph_final_answer import answer_update_fields
|
|
345
345
|
|
|
346
346
|
updated_answer_fields: set[str] = set()
|
|
347
|
-
explicit_answer = uses_explicit_answer_contract(self._agent)
|
|
348
347
|
explicit_snapshot_answer = has_explicit_answer_field(self._agent)
|
|
349
348
|
final_result_fields: dict[str, Any] = {}
|
|
350
349
|
|
|
@@ -365,7 +364,7 @@ class _LangGraphCanonicalStreamMixin:
|
|
|
365
364
|
run_stream = await self._agent.astream_events(stream_input, **stream_kwargs)
|
|
366
365
|
async for event in adapter.stream_run(run_stream, adapter_context):
|
|
367
366
|
updated_answer_fields.update(answer_update_fields(event))
|
|
368
|
-
if (
|
|
367
|
+
if (
|
|
369
368
|
explicit_snapshot_answer
|
|
370
369
|
and event.source.metadata.get("message_delivery") == "snapshot"
|
|
371
370
|
):
|
|
@@ -374,6 +373,14 @@ class _LangGraphCanonicalStreamMixin:
|
|
|
374
373
|
# output when no model/custom text was streamed. Keep their
|
|
375
374
|
# snapshots observable and let final_answer_events select it.
|
|
376
375
|
event = internal_model_event(event)
|
|
376
|
+
if (isinstance(event, ItemStarted)
|
|
377
|
+
and event.item_kind in {"message", "reasoning"}
|
|
378
|
+
and event.source.metadata.get(
|
|
379
|
+
"conversation_visibility", event.source.metadata.get("visibility")
|
|
380
|
+
) in {"internal", "hidden"}):
|
|
381
|
+
# Explicitly private model calls cannot own the public
|
|
382
|
+
# final answer or suppress the graph's fallback answer.
|
|
383
|
+
event = event.model_copy(update={"phase": "commentary"})
|
|
377
384
|
if isinstance(event, RunInterrupted) or (
|
|
378
385
|
isinstance(event, RunProgress)
|
|
379
386
|
and authority is not None
|
|
@@ -430,6 +437,22 @@ class _LangGraphCanonicalStreamMixin:
|
|
|
430
437
|
if timing := extract_timing(final_state):
|
|
431
438
|
final_result_fields["timing"] = timing
|
|
432
439
|
except Exception as exc:
|
|
440
|
+
from ksadk.tunnel.failure import failure_events, tunnel_failure
|
|
441
|
+
|
|
442
|
+
if failure := tunnel_failure(exc):
|
|
443
|
+
for event in failure_events(
|
|
444
|
+
failure,
|
|
445
|
+
run_id=run_id,
|
|
446
|
+
scope_id=run_scope_id,
|
|
447
|
+
source=run_source,
|
|
448
|
+
allocate_seq=adapter_context.allocate_placeholder_seq,
|
|
449
|
+
open_items=(
|
|
450
|
+
(item.scope_id, item.item_id, item.item_kind)
|
|
451
|
+
for item in reducer.snapshot().items if item.status == "open"
|
|
452
|
+
),
|
|
453
|
+
):
|
|
454
|
+
yield event
|
|
455
|
+
return
|
|
433
456
|
from ksadk.runners._langgraph_interactions import (
|
|
434
457
|
persisted_interactions,
|
|
435
458
|
submission_progress,
|