+
    lHàj‚È  ã                   óŽ  € R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHtHtH	t	H
t
 ^ RIHt ^ RIHt ]P                   ! ]4      t^ RIHtHtHtHtHtHtHtHtHtHtHtHtH t  ^ RI!H"t"H#t#H$t$H%t%H&t&H't'H(t(H)t)H*t*H+t+H,t,H-t-H.t.H/t/H0t0H1t1H2t2 ^ RI3H4t4H5t5H6t6H7t7 ^ R	I8H9t9H:t:H;t;H<t<H=t=H>t>H?t?H@t@HAtAHBtBHCtCHDtD ^ R
IEHFtFHGtGHHtHHItIHJtJHKtKHLtLHMtMHNtNHOtOHPtPHQtQHRtRHStSHTtT ^ RIUHVtVHWtWHXtXHYtYHZtZ ^ RI[H\t\ ^ RI]H^t^H_t_H`t`Hata ^ RIbHctcHdtdHeteHftf ]g! RR04      thR R ltiR R ltj^útk^tl^tm^(tnRtoR R ltpR R ltqR R ltrRtsR R lttR R  ltuRnR! R" lltvRoR#RR$RR%R/R& R' llltwR( R) ltxR* R+ ltyR,R/R- R. lltzR/ R0 lt{R1 R2 lt|R3 R4 lt}RpR5 R6 llt~R7R/R8 R9 lltR:t€R;t�R< R= lt‚R> R? ltƒR@ RA lt„RBRCRDRERFRGRHRIRJRGRKRL^RMRGRHRIRN]„! RORP4      RQ]„! RORR4      RS]„! RHRT4      RU]„! RKRVRGRO/RW7      RX]„! RORY4      /RZRN./RDR[/R\]„! ROR]. RqOR^7      R_]„! ROR`4      Ra]„! RORb4      /RZ. //t…^ RcI†H‡t‡Hˆtˆ RrRd Re llt‰RfRg0tŠRh Ri lt‹]‡EP                  ! RCRj]…Rk ]pRl]ƒRm7       R# )sa  
Delegate Tool -- Subagent Architecture

Spawns child AIAgent instances with a fresh conversation, their own task_id
(terminal session, file-ops cache), the parent's toolsets minus child-blocked
tools, and a focused system prompt built from goal + context. Single-task and
batch (parallel) modes; top-level model calls run in the background while
orchestrator children wait for their own workers. The parent only ever sees
the delegation call and the summary result, never the child's intermediate
tool calls or reasoning.
N)ÚPath)ÚAnyÚDictÚListÚOptional)Úset_approval_callback)Úis_truthy_value)Ú	_ChildRunÚ_attach_childÚ_build_child_goal_messageÚ_close_childÚ_detach_childÚ_build_result_entryÚ!_dump_subagent_timeout_diagnosticÚ_fabricated_entryÚ_lease_child_credentialÚ_merge_late_steerÚ_register_childÚ_start_heartbeatÚ_validate_child_output_schema)Ú _DEFAULT_MAX_CONCURRENT_CHILDRENÚ_get_child_timeoutÚ_get_max_async_childrenÚ_get_max_concurrent_childrenÚ_get_max_spawn_depthÚ_get_oneshot_max_childrenÚ_get_orchestrator_enabledÚ_get_subagent_approval_callbackÚ_get_worktree_isolationÚ_inherit_parent_capabilitiesÚ_load_configÚ_merge_request_overridesÚ_resolve_child_credential_poolÚ_resolve_child_runtimeÚ_resolve_delegation_credentialsÚ_subagent_auto_approveÚ_subagent_auto_deny)Ú_BatchÚ_announce_batchÚ_capture_originÚ
_run_batch)ÚDelegateEventÚSUBAGENT_FAILURE_STATUSESÚ_batch_prefixÚ_build_child_progress_callbackÚ_build_child_system_promptÚ_clean_error_textÚ_emit_parent_consoleÚ_quietÚ_resolve_workspace_hintÚ_safe_progressÚformat_batch_tagÚformat_subagent_failure_line)Ú_CONTROL_ACTIONSÚ_active_subagentsÚ_active_subagents_lockÚ _capture_gateway_steer_authorityÚ_handle_control_actionÚ_is_descendant_ofÚ_owns_subagent_recordÚ_register_subagentÚ_unregister_subagentÚget_subagent_attributionÚinterrupt_subagentÚis_spawn_pausedÚlist_active_subagentsÚset_spawn_pausedÚsteer_subagent)Ú_MAX_TASK_IMAGESÚ_coerce_task_imagesÚ_coerce_task_schemasÚ_normalize_task_imagesÚ_normalize_task_list)Úpin_child_service_tier)ÚDELEGATE_BLOCKED_TOOLSÚ_expand_parent_toolsetsÚ_resolve_child_toolsetsÚ_strip_blocked_tools)Ú_apply_summary_budgetÚ$_build_child_preserving_parent_toolsÚ_run_child_lifecycleÚ_summarize_tool_argumentsÚleafÚorchestratorc                óF   € V ^8„  d   QhR\         R\        \        ,          /# )é   Úparent_agentÚreturn)r   r   r   )Úformats   "Ú8/home/ubuntu/.hermes/hermes-agent/tools/delegate_tool.pyÚ__annotate__r\   @   s   € ÷ ñ ¤Cð ¬H´T­Nñ ó    c                óú   € \        \        V RR4      RR4      p\        V\        \        34      '       d   \        V4      P                  # Ve   \
        P                  RV4       R# \
        P                  R4       R# )u�  Resolve the live transcripts' profile home from parent-owned state.

The parent's per-profile SessionDB sits directly under its profile home
(``<home>/state.db``), so the db path's parent IS the home. Returns None
when the parent exposes no usable SessionDB â€” the caller then falls back
to the ambient resolve, which is exactly the #91996 failure mode, so the
skip is logged rather than silent.
Ú_session_dbNÚdb_pathzÉdelegate_task: parent _session_db.db_path is %r (not a str/Path); live-transcript home pinning skipped, falling back to ambient HERMES_HOME resolve (transcripts may land in a different profile, #91996)z»delegate_task: parent agent exposes no _session_db; live-transcript home pinning skipped, falling back to ambient HERMES_HOME resolve (transcripts may land in a different profile, #91996))ÚgetattrÚ
isinstanceÚstrr   ÚparentÚloggerÚdebugÚwarning)rX   Ú	parent_dbs   & r[   Ú_parent_live_homeri   @   sw   € ô œ ¨m¸TÓBÀIÈtÓT€Iô
 �)œc¤4˜[×)Ò)Ü�I‹×%Ñ%Ð%ØÒÜ�‰ðXð ô		
ñ Ü
‡N�Nð	@ôñ
 r]   c                óF   € V ^8„  d   QhR\         \        ,          R\        /# )rW   ÚrrY   )r   rc   )rZ   s   "r[   r\   r\   b   s   € ÷ ñ ”x¤•}ð ¬ñ r]   c                ó®   € V '       d(   \        V 4      P                  4       P                  4       MRpV\        9  d   \        P                  RV 4       R# V# )zF'leaf' | 'orchestrator'; None/empty/unknown -> 'leaf' (unknown warns).rT   z1Unknown delegate_task role=%r, coercing to 'leaf')rc   ÚstripÚlowerÚ_ROLESre   rg   )rk   Úr_norms   & r[   Ú_normalize_rolerq   b   s=   € ç'(ŒS�‹V�\‰\‹^×!Ñ!Ô#¨f€FØ”VÔÜ�‰ÐJÈAÔNÙØ€Mr]   g       @c                ó$   € V ^8„  d   QhR\         /# ©rW   rY   )Úbool)rZ   s   "r[   r\   r\   w   s   € ÷ ñ ¤Tñ r]   c                 ó   € R# )z<Delegation has no external requirements -- always available.T© rv   r]   r[   Úcheck_delegate_requirementsrw   w   s   € ár]   c                ó$   € V ^8„  d   QhR\         /# rs   ©r   )rZ   s   "r[   r\   r\   |   s   € ÷ ñ ¬Cñ r]   c                óz  € ^ RI HpHpHp \	        V RR4      pV! 4       '       g   \        WA4      '       d(   \        WA4      '       g	   V! R4      h^ RIHp V! V4      # Vf   R# \        RRR7      ;_uu_ 4        ^ R	I	H
p \	        VR
R4      pVe	   V! V4      MV! 4       uuRRR4       #   + '       g   i     R# ; i)aV  DEDICATED SessionDB handle for the child, or None: the parent's handle can be closed by its own lifecycle while
a background child still flushes (transcript silently dropped). It MUST open the same db FILE as the parent's
handle (non-launch profiles), else lineage / session_search break; released by the child's close() via
_owns_session_db.)ÚRuntimeSessionStoreÚWorkerPersistenceErrorÚis_worker_processr_   NÚ"worker_child_registration_required)Úreserve_child_storezHsubagent: failed to open dedicated SessionDB; child persistence disabledT©Úexc_info)Úacquirer`   )Úagent.runtime_session_storer{   r|   r}   ra   rb   Úagent.runtime_session_childr   r2   Úhermes_state_registryr‚   )rX   r{   r|   r}   Úparent_session_dbr   r‚   Ú_parent_db_paths   &       r[   Ú_open_child_session_dbrˆ   |   s§   € ÷ kÑjÜ ¨m¸TÓBÐÙ×ÒœjÐ):×PÒPô Ð+×AÒAÙ(Ð)MÓNÐNÝCÙ"Ð#4Ó5Ð5ØÒ ÙÜ	ÐZÐei×	jÖ	jÝ1Ü!Ð"3°YÀÓEˆØ+:Ò+F‰w�Ô'ÉGËI÷ 
k×	j×	jÑ	jñ ús   Á8&B)Â)B:	c                ó   € V ^8„  d   QhRR/# ©rW   rY   Nrv   )rZ   s   "r[   r\   r\   ›   s   € ÷  ñ   Tñ  r]   c                ó<   € \        V RR4      R8X  d
   RV n        R# R# )a[  A delegated child never uses the 1h cache tier. The tier is priced for a person who steps
away between turns (2x write vs 1.25x for 5m, #14971); a subagent calls every few seconds for
minutes and is gone, so it pays the 2x on every tool result and never collects the retention.
Caching itself stays exactly as configured (disabled stays disabled).Ú
_cache_ttlNÚ1hÚ5m)ra   rŒ   )Úchilds   &r[   Ú_apply_child_cache_ttlr�   ›   s"   € ô
 ˆu�l DÓ)¨TÔ1ØˆÖñ 2r]   i€>  c                ó2   € V ^8„  d   QhR\         R,          /# rŠ   )Úint)rZ   s   "r[   r\   r\   ¦   s   € ÷ ñ ¬#°­*ñ r]   c                ó  € V e   V RJ g   V ^ 8X  d   R# \        V \        4      '       g1   \        V \        \        34      '       d   \        V 4      \        8  d   \
        P                  RV \        4       R# \        V 4      # )aÎ  Validated ``delegation.compression_threshold_tokens``: an int >= 16000, or None for "no cap".

Unset / ``0`` / ``false`` / ``null`` mean no subagent-specific cap: the child compacts at the
same ratio trigger as everyone else (0.50 x window). A bool ``true`` (YAML) would coerce to 1
and make every call compress; a string like ``"200k"`` would silently read as no cap. Both are
config errors: warn and treat as unset so a typo never changes compaction behaviour.NFzudelegation.compression_threshold_tokens=%r is not a token count >= %d; ignoring it (children keep the ratio trigger).)rb   rt   r’   ÚfloatÚ_CHILD_CAP_MINre   rg   )Úraws   &r[   Ú_child_compression_cap_tokensr—   ¦   se   € ð ‚{�c˜U“l c¨Q¤hÙÜ�#”t×Ò¤J¨s´S¼%°L×$AÒ$AÄSÈÃXÔP^ÔE^Ü�‰ð1Ø25´~ô	
ñ Üˆs‹8€Or]   c                ó(   € V ^8„  d   QhR\         RR/# )rW   Údelegation_cfgrY   N©Údict)rZ   s   "r[   r\   r\   ¸   s   € ÷ )ñ )¼ð )Àñ )r]   c                ó\  € ^ RI Hp \        V RR4      p\        W24      '       g   R# \	        T;'       g    / P                  R4      4      pVf   R# VP                  p\        V\        4      '       d   V^ 8”  d   \        WE4      MTVn        VP                  e   VP                  4        R# R# )av  Optional absolute cap on the child's compaction trigger, ``delegation.compression_threshold_tokens``
(lower of it and any global ``compression.threshold_tokens``). Off by default: a 1M-window child
compacts where its parent does. The compressor applies the cap on first window resolution, which
happens after construction, so setting it here is exactly equivalent to config.)ÚContextCompressorÚcontext_compressorNÚcompression_threshold_tokens)Úagent.context_compressorr�   ra   rb   r—   ÚgetÚthreshold_tokens_capr’   ÚminÚ_threshold_tokensÚ_apply_threshold_tokens_cap)r�   r™   r�   ÚccÚcapÚexistings   &&    r[   Ú_apply_child_compression_capr©   ¸   s—   € õ
 ;ä	�Ð,¨dÓ	3€BÜ�b×,Ò,ÙÜ
'¨×)=Ð)=¸2×(BÑ(BÐCaÓ(bÓ
c€CØ
‚{ÙØ×&Ñ&€HÜ4>¸xÌ×4MÒ4MÐRZÐ]^ÔR^œc #Ô0Ðdg€BÔØ	×ÑÒ'Ø
×&Ñ&Ö(ñ (r]   c          '      óŠ  € V ^8„  d   QhR\         R\        R\        \        ,          R\        \        \        ,          ,          R\        \        ,          R\         R\         R\        \        ,          R	\        \        ,          R
\        \        ,          R\        \        ,          R\        \        \        \
        3,          ,          R\        \        ,          R\        \        \        ,          ,          R\        \        \        \
        3,          ,          R\        R\
        R\        \        ,          R\        \        ,          /# )rW   Ú
task_indexÚgoalÚcontextÚtoolsetsÚmodelÚmax_iterationsÚ
task_countÚoverride_providerÚoverride_base_urlÚoverride_api_keyÚoverride_api_modeÚoverride_request_overridesÚoverride_acp_commandÚoverride_acp_argsÚrouting_cfgÚroleÚoverride_reasoning_effortÚprofile_homeÚoverride_service_tier)r’   rc   r   Úlistr›   r   r   )rZ   s   "r[   r\   r\   Ë   s+  € ÷ ]ñ ]Üð]ä
ð]ô ”c�]ð]ô ”tœC•yÕ!ð	]ô
 ”C�=ð]ô ð]ô ð]ô  ¤•}ð]ô  ¤•}ð]ô œs•mð]ô  ¤•}ð]ô !)¬¬c´3¨h­Õ 8ð]ô" #¤3�-ð#]ô$  ¤¤S¥	Õ*ð%]ô, œ$œs¤C˜x�.Õ)ð-]ô0 ð1]ô6  #ð7]ô8 œ4•.ð9]ô: $¤C�=ñ;]r]   c                óÀ  a+€ ^ RI p^ RIHp ^ RIHp ^ RIHp \        VR^ 4      ^,           p\        4       p\        4       '       d
   VV8  d   RMRpRV  R	VP                  4       P                  R
,           2p\        VRR4      p\        4       p\        WsV4      w  pp\        W\        V4      VVVR7      p \        VRR4      p!V!'       g.   \!        VR4      '       d   VP"                  P%                  R4      p!/ p"\'        YYvTT\)        ^ V^,
          4      T;'       g    \        VRR4      VV"R7
      o+V! V4      ;_uu_ 4        \+        VVV!WHWšVVVVVR7      p#V'       d   VV#R&   Ve   \-        V4      p$M*V'       d   / M\-        \        VR/ 4      ;'       g    / 4      p$\        VRR4      p%\/        V4      p&V! 4       ;_uu_ 4         T! R>/ V#B/ RVbR\        VRR4      bRVbRVbRRbRV bRRV  R2bRR bR!RbR"RbR#RbR$RbR%S+'       d   V+3R& lMRbR'V&bR(V%bRV$bR\        V&R)R4      bR*S+bR+RbBVe   R,R/M/ B p' RRR4       \9        T#R.,          Te   RMTT#R/,          T#P%                  R04      R17      p)RRR4       \        TR2R4      X'n        \=        T'4       X&e   RT'n        \        T'RR34      ;'       g    R3T"R&   T"T'n         TTuT'n!        T'n"        TTuT'n#        T'n$        \K        T'T4        \L        PN                  ! T4      T'n(        X%'       d   \        T'R4R4      e   T%T'PT                  R5&   TT'n+        X)e   T)T'n,        \[        TT'4       \]        S+R6TR77       \3        R8RR97      ;_uu_ 4        ^ R:I/H0p* T*! R;T%\        TR<R34      ;'       g    R3T\        T'RR4      TTTR=7       RRR4       T'#   \0         dE    T&e?   \3        R4      ;_uu_ 4        ^ R-IHp( T(! T&4       RRR4       h   + '       g   i     h ; ih i ; i  + '       g   i     ELÔ; i  + '       g   i     EL®; i  \R         d    RT'n(         EL7i ; i  + '       g   i     T'# ; i)?a>  Build (don't run) a child AIAgent on the main thread. override_* (from delegation config) replace parent
inheritance so children can run on a different provider:model pair. ``profile_home`` builds (and later runs,
see ``_ChildRun.await_child``) the child inside that profile's scope; it never shares the parent's pool.N)ÚAIAgent)Údelegated_child_context)Údelegated_profile_scopeÚ_delegate_depthrU   rT   zsa-Ú-:Né   NÚ_subagent_id)Úworkspace_pathrº   Úmax_spawn_depthÚchild_depthÚapi_keyÚ_client_kwargsr¯   )Úsubagent_idÚ	parent_idÚdepthr¯   r®   Úsession_ref)	r¯   r²   r³   r´   rµ   r·   r¸   r¹   r»   Úservice_tierÚrequest_overridesÚ
session_idr°   Úprefill_messagesÚenabled_toolsetsÚdisabled_toolsetsÚ
quiet_modeTÚephemeral_system_promptÚ
log_prefixú
[subagent-Ú]ÚplatformÚsubagentÚ
side_agentÚskip_context_filesÚskip_memoryÚclarify_callbackÚthinking_callbackc                 ó2   <€ V '       d   \        SR V 4      # R# )Ú	_thinkingN)r4   )ÚtextÚchild_progress_cbs   &€r[   Ú<lambda>Ú$_build_child_agent.<locals>.<lambda>,  s   ø€ ×^b¤nÐ5FÈÐUYÓ&ZÐ&lÐhlÐ&lr]   Ú
session_dbÚparent_session_idÚreserved_session_idÚtool_progress_callbackÚiteration_budgetÚload_soul_identity)Úrelease_or_closeÚproviderÚbase_urlÚrequested_provider)Úeffective_requested_providerÚ	_print_fnÚ Ú_session_init_model_configÚ_delegate_fromzsubagent.spawn_requested©Úpreviewz%subagent_start hook invocation failedr€   )Úinvoke_hookÚsubagent_startÚ_current_turn_id)ré   Úparent_turn_idÚparent_subagent_idÚchild_session_idÚchild_subagent_idÚ
child_roleÚ
child_goalrv   )1ÚuuidÚ	run_agentrÀ   Úagent.delegation_contextrÁ   Útools.delegate_tool_routesrÂ   ra   r   r   Úuuid4Úhexr    rN   r/   r3   ÚhasattrrË   r¡   r.   Úmaxr#   r›   rˆ   ÚBaseExceptionr2   r…   rî   r"   ró   r�   Ú_owns_session_dbÚ_progress_identity_refrÃ   Ú_delegate_rolerÆ   Ú_parent_subagent_idr©   ÚweakrefÚrefÚ_delegate_parent_refÚ	TypeErrorrõ   Ú_delegate_profile_homeÚ_credential_poolr
   r4   Úhermes_cli.lifecyclerù   ),r«   r¬   r­   r®   r¯   r°   r±   rX   r²   r³   r´   rµ   r¶   r·   r¸   r¹   rº   r»   r¼   r½   Ú_uuidrÀ   rÁ   rÂ   rÉ   Ú	max_spawnÚeffective_rolerÌ   rý   r™   Úchild_toolsetsÚchild_disabled_toolsetsÚchild_promptÚparent_api_keyÚchild_session_refÚrtrÑ   Ú
parent_sidÚchild_session_dbr�   rî   Ú
child_poolÚ_invoke_hookrå   s,   &&&&&&&&&&&&&&&&&&&&                       @r[   Ú_build_child_agentr#  Ë   së  ø€ óD Ý!Ý@ÝBô ˜,Ð(9¸1Ó=ÀÕA€KÜ$Ó&€IÜ'@×'BÒ'BÀ{ÐU^ÔG^‘^Ðdj€Nð ˜
�| 1 U§[¡[£]×%6Ñ%6°rÕ%:Ð$;Ð<€KÜ  ¨~¸tÓDÐô
 "“^€NÜ.EÀlÐ^lÓ.mÑ+€NÐ+Ü-ØÔ&=¸lÓ&KÐR`Ø!¨{ô€Lô ˜\¨9°dÓ;€Nß¤¨Ð6F× GÒ GØ%×4Ñ4×8Ñ8¸ÓCˆð )+ÐÜ6Ø˜,ÀÐWiÜ�!�[ 1•_Ó%Ø×;Ð;”w˜|¨W°dÓ;ÀnÐbsôÐñ
 
! ×	.Õ	.Ü#Ø˜.¨.ÀØ/ÐfwØ!5Ø/Ø#Ð?Xô
ˆ÷ !Ø!6ˆBˆ~ÑØ%Ò1ô !%Ð%?Ó @Ñç&7¡¼TÄ'È,ÐXkÐmoÓBp×BvÐBvÐtvÓ=wÐÜ˜\¨<¸Ó>ˆ
Ü1°,Ó?ÐÙ$×&Õ&ðÙñ ØòÙ)7ðÜJQÐR^Ð`rÐtxÔJyðá%3ðáG^ðákoðñ -9ðð HRÐR\ÐQ]Ð]^ÑE_ðñ kuðñ  $ð	ñ
 (,ðñ
 :>ðñ
 QUð÷ -õ mØ26øðñ  0ðñ DNðñ bsðô  'Ð'7Ð9NÐPTÔUðñ ,=ðñ &*ðð 8DÒ7OÐ,¨dÑ3ÐUWñ‘÷ 'ô8 4Øˆz�N LÒ$<™DÀ,ÐPRÐS]ÕP^Ø)+¯©Ð0DÓ)Eô
ˆ
÷] 
/ôd ˜l¨K¸Ó>€E„OÜ˜5Ô!ØÒ#Ø!%ˆÔô '.¨e°\À2Ó&F×&LÐ&LÈ"Ð�lÑ#Ø#4€EÔ Ø2=¸~Ð/€EÔ˜5Ô/Ø4?ÐASÐ1€EÔ˜Ô1Ü  ¨Ô7ð*Ü%,§[¢[°Ó%>ˆÔ"÷
 ”g˜eÐ%AÀ4ÓHÒTØ=Gˆ×(Ñ(Ð)9Ñ:Ø#/€EÔ ØÒØ!+ˆÔä�, Ô&ô Ð$Ð&@È$ÕOÜ	Ð7À$×	GÖ	GÝDÙØ°
Ü" <Ð1CÀRÓH×NÐNÈBÐcuÜ$ U¨L¸$Ó?ÐS^Ø%°$õ		
÷ 
Hð €Løôe !ô à#Ò/Ü Ÿ�ÝJÙ(Ð)9Ô:÷ &ð ÷ &žð ú�ðú÷' '×&Ð&ú÷% 
/×	.Ð	.ûôB ô *Ø%)ˆ×"ð*ú÷ 
HÖ	Gð €Lúsy   Å:PÅ?PÆ.PÇP	Ç
A5N9É :PË6P3 Í87QÎ9"PÏO3Ï*	PÏ3PÏ>
PÐP	ÐPÐ	PÐP0	Ð3Q	ÑQ	ÑQ	Úowner_session_idÚowner_transportÚowner_session_recordc                ó˜   € V ^8„  d   QhR\         R\        R\        \        ,          R\        R\        R\        \        \        3,          /# )rW   r«   r¬   r$  r%  r&  rY   )r’   rc   r   r   r›   )rZ   s   "r[   r\   r\   j  sT   € ÷ ?Eñ ?EÜð?EÜð?EÜT\Ô]`ÕTað?Eäð?Eä7:ð?Eô 
Œ#Œsˆ(…^ñ?Er]   c               ó°  € \        VRR4      p\        V4      w  rš\        W#V 4      p\        W#WVVR7      p\	        W#WWÈVR7      pRp VP                  4        \        VRVR7       VP                  4        VP                  4       w  pppVe   VVP                  W¹W®R7       # \        W/WP                  VP                  4      p\        WüV4       V'       d?   \        VR	4      '       d-   \        R
4      ;_uu_ 4        VP!                  4        RRR4       VP#                  4       p\%        W/V VV4      pVP'                  V4       VP)                  V4       VP+                  VVV4       VP-                  V4      VP                  W¹W®R7       #   + '       g   i     L‡; i  \.         d“   pTP1                  4       p\2        P4                  ! RT  R24       TP7                  \9        T R\;        T4      Y-P#                  4       4      T\;        T4      \;        T4      RR7      u Rp?TP                  Y¹Y®R7       # Rp?ii ; i  TP                  Y¹Y®R7       i ; i)u¬  Run a pre-built child agent (called from a worker thread) and return its result entry.

Contract, derived from the child's structured completion fields:
  status      âˆˆ {completed, interrupted, failed} â€” a structured failure
                (failed=True / non-empty error) or an invalid terminal state
                is "failed" even when a summary exists.
  exit_reason âˆˆ {completed, max_iterations, interrupted, error} â€”
                "max_iterations" only for genuine budget exhaustion
                (completed=False with no failure fields), never for errors.
  truncated   == (exit_reason == "max_iterations").

* ``"completed"``       â€” normal finish. See #97655.
rë   N)r$  r%  r&  )Ú	heartbeatFzsubagent.startr÷   )r)  r!  Úleased_cred_idÚclose_deferredÚ_flushz"Progress callback flush failed: %srÙ   z] failedÚerrorÚfailed)rø   ÚsummaryÚstatus)ra   r   r   r   r	   Ústartr4   Úseed_workspaceÚawait_childÚcleanupr   Úchild_task_idÚ
relay_textr   r  r2   r,  Úelapsedr   Úappend_sibling_write_reminderÚaccount_background_processesÚemit_completeÚattach_worktreeÚ	ExceptionÚclose_steeringÚloggingÚ	exceptionÚfinish_failedr   rc   )r«   r¬   r�   rX   r$  r%  r&  Ú_kwargsrå   r!  r*  r)  rÆ   ÚrunÚ_child_close_deferredÚresultÚfailure_entryÚschemaÚdurationÚentryÚexcÚ_late_pending_steers   &&&&$$$,              r[   Ú_run_single_childrK  j  s,  € ô"   Ð'?ÀÓFÐÜ!8¸Ó!?Ñ€Jô ! °jÓA€Iô #Ø˜TÐVeØ1ô€Lô �E¨¸<ÐfoÔ
p€Cð "ÐðEØ�‰ÔÜÐ(Ð*:ÀDÕIØ×ÑÔØ7:·±Ó7HÑ4ˆ�Ð4ØÒ$Ø ð2 	�‰˜iÈ~ˆõ  	Eô/ /¨u¸j×J[ÑJ[Ð]`×]kÑ]kÓlˆÜ˜&°Ô6ç¤Ð):¸H×!EÒ!EÜÐ<×=Õ=Ø!×(Ñ(Ô*÷ >ð —;‘;“=ˆÜ# E°:¸xÈÓPˆØ×)Ñ)¨%Ô0Ø×(Ñ(¨Ô/Ø×Ñ˜& %¨Ô2Ø×"Ñ" 5Ó)ð 	�‰˜iÈ~ˆõ  	E÷' >×=ûô ô 
à!×0Ñ0Ó2ÐÜ×Ò˜J z l°(Ð;Ô<à× Ñ Ü˜j¨'´3°s³8¸UÇKÁKÃMÓRÐTgÜ˜“H¤c¨#£h°xð !ó 
ô 	
ð
 	�‰˜iÈ~ˆõ  	Eûð
ûð 	�‰˜iÈ~ˆõ  	EúsR   ÁAF  Â#AF  Ã=FÄA+F  ÆF	ÆF  Æ H=Æ+A4H8ÈH=È I  È8H=È=I  É Ic                ó¢   € V ^8„  d   QhR\         \        \        3,          R\         \        \        3,          R\         \        \        3,          /# )rW   Úcredsr¹   rY   )r›   rc   r   )rZ   s   "r[   r\   r\   ¬  s>   € ÷ 
ñ 
¤¤c¬3 h¥ð 
¼dÄ3ÌÀ8½nð 
ÔQUÔVYÔ[^ÐV^ÕQ_ñ 
r]   c                óÚ   € RV R,          RV R,          RV R,          RV R,          R	V P                  R
4      RV P                  R4      RV P                  R4      RV P                  R4      RV/	# )zn``_build_child_agent`` override kwargs for a resolved credential bundle (delegate_task and the lifecycle API).r²   rï   r³   rð   r´   rÊ   rµ   Úapi_moder¶   rÑ   r·   Úcommandr¸   Úargsr½   rÐ   r¹   )r¡   )rM  r¹   s   &&r[   Ú_credential_overridesrR  ¬  st   € ð 	˜U :Õ.Ð0CÀUÈ:ÕEVØ˜E )Õ,Ð.AÀ5ÈÕCTØ$ e§i¡iÐ0CÓ&DØ §	¡	¨)Ó 4Ø˜UŸY™Y vÓ.Ø §¡¨>Ó!:Ø�{ðð r]   c                óR   € V ^8„  d   QhR\         R\        \        \         3,          /# )rW   ÚrouterY   )r   r›   rc   )rZ   s   "r[   r\   r\   ¹  s"   € ÷ ñ œCð ¤D¬¬c¨¥Nñ r]   c                óz   € / \        V P                  V P                  4      CRV P                  RV P                  /C# )z\``_build_child_agent`` kwargs for one task route (``tools.delegate_tool_routes.TaskRoute``).r»   r¼   )rR  rM  r¹   Úreasoning_effortr¼   )rT  s   &r[   Ú_route_overridesrW  ¹  s?   € ðÜ
 §¡¨U×->Ñ->Ó
?ðà# U×%;Ñ%;¸^ÈU×M_ÑM_ñð r]   Útask_imagesc                óÜ  € V ^8„  d   QhR\         \        \        \        3,          ,          R\         \        \        \        \        3,          ,          ,          R\         \        ,          R\        R\
        R\        \        ,          R\         R\        \         \        \         \        ,          ,          ,          ,          R	\        \         \        ,          \        \        ,          3,          /	# )
rW   Ú	task_listÚtask_schemasÚroutesÚtop_roler°   Úlive_deleg_idÚlive_writersrX  rY   )r¾   r›   rc   r   r   r’   Útuple)rZ   s   "r[   r\   r\   Á  s°   € ÷ 6ñ 6Ü”Dœœc˜•NÕ#ð6Ü37¼ÄÄcÌ3ÀhÅÕ8PÕ3Qð6Ü[_Ô`cÕ[dð6äð6ä#&ð6ô œC•=ð6ô 15ð6ô DLÌDÔQYÔZ^Ô_bÕZcÕQdÕLeÕCfð6ô Œ4”�;œ¤�Ð%Õ&ñ	6r]   c               óR  € ^ RI Hp	 ^ RIHp
 . p\	        V 4       EF  w  rÍW,,          pVP
                  '       d   K"  V\        V4      8  d	   W,          MRpVP                  R4      pVe
   V
! VV4      p \        RRTRVR,          RTRRRVP                  R,          R	TR
\        V 4      RTR\        VP                  R4      ;'       g    T4      /	\        V4      B p\!        TTP                  4       Te%   \#        RT4      ;_uu_ 4        TTn        RRR4       T'       d   T\        T4      8  d	   YŒ,          MRpT'       d%   \#        RT4      ;_uu_ 4        TTn        RRR4       T\        T4      8  d	   Y|,          MRpTe4   T	! \)        TRR4      T4      Tn        \        TP,                  4      Tn        TP1                  4       e   TP1                  4       Tn        T'       d0   TTn        \)        TRR4      p\7        T\8        4      '       d   TTR&   TP;                  YÍT34       EK  	  VR3#   \         d?   pT F  w   pp\        TT4       \        TR4       K!  	  . \        T4      3u Rp?u # Rp?ii ; i  + '       g   i     ELv; i  + '       g   i     EL<; i)z¯Build every child on the main thread (construction is not thread-safe), each on its task's route;
``(children, None)`` or ``([], error)`` on an explicit-pin preflight failure.)Úwrap_progress_callback)Úappend_output_contractNr­   r«   r¬   r®   r¯   r°   r±   rX   rº   z-Failed to close child after a refused siblingz*Could not attach output schema to child %dz#Could not attach images to child %drë   r  Údelegation_idrv   )Útools.delegation_live_logrb  Útools.delegation_output_schemarc  Ú	enumerater-  Úlenr¡   rQ   rM  rq   rW  Ú
ValueErrorr   r   rc   rK   r2   Ú_delegate_output_schemaÚ_delegate_imagesra   rë   ÚpathÚ_live_transcript_pathÚreportÚ_delegate_routeÚ_delegation_idrb   r›   Úappend)rZ  r[  r\  r]  r°   rX   r^  r_  rX  rb  rc  ÚchildrenÚiÚtrT  Ú_task_schemaÚ_child_contextr�   rI  Ú_ÚbuiltÚ	_t_imagesÚ_writerÚ
_ident_refs   &&&$$$$$$               r[   Ú_build_childrenr|  Á  s‡  € õ AÝEØ€HÜ˜)×$‰ˆØ•	ˆØ�;�;ˆ;ÙØ*+¬c°,Ó.?Ô*?�|–ÀTˆØŸ™˜yÓ)ˆØÒ#Ù3°NÀLÓQˆNð	 Ü8ñ ØðØ#$ V¥9ðØ6Dðàðð —k‘k 'Õ*ðð <Jðô WZÐZcÓVdðð *ð	ô 1@ÀÇÁÀfÃ×@YÐ@YÐQYÓ0Zð	ô _oÐotÓ^uñ	ˆEô 	˜u e§k¡kÔ2ØÒ#ÜÐDÀa×HÕHØ0<�Ô-÷ I÷ '2°a¼#¸kÓ:JÔ6J�K–NÐPTˆ	ßÜÐ=¸q×AÕAØ)2�Ô&÷ Bð &'¬¨\Ó):Ô%:�,–/ÀˆØÒÙ+AÄ'È%ÐQiÐkoÓBpÐryÓ+zˆEÔ(Ü*-¨g¯l©lÓ*;ˆEÔ'Ø�<‰<‹>Ò%Ø$)§L¡L£NˆEÔ!ßØ#0ˆEÔ Ü  Ð(@À$ÓGˆJÜ˜*¤d×+Ò+Ø.;�
˜?Ñ+Ø�‰˜˜u˜×&ñW %ðX �Tˆ>Ðøô; ô 	 ã'‘��1�eÜ˜l¨EÔ2Ü˜UÐ$SÖTñ  (ð ”s˜3“x�<×ûð	 ú÷ I×HÐHú÷
 B×AÐAús7   Á5A)H5ÄJÅJÈ5I>É 1I9É1I>É9I>ÊJÊJ&c                ó4  € V ^8„  d   QhR\         \        \        \        3,          ,          R\        \        \        3,          R\        \        \        \        3,          ,          R\        R\
        \         \        ,          \        \        ,          3,          /# )rW   rZ  ÚcfgÚcredentials_cfgrX   rY   )r¾   r›   rc   r   r   r`  )rZ   s   "r[   r\   r\   ú  sk   € ÷ *ñ *œ4¤¤S¬# X¥Õ/ð *´d¼3Ä¸8µnð *ÔW_Ô`dÔehÔjmÐemÕ`nÕWoð *Ü!ð*Ü&+¬D´­I´xÄµ}Ð,DÕ&Eñ*r]   c                ó²   € ^ RI HpHp Vf
   V! WV4      #  V! W#4      pT.\        T 4      ,          R3#   \         d   p. \	        T4      3u Rp?# Rp?ii ; i)uº   Per-task routes: an internal caller's explicit ``credentials_cfg`` (e.g. /review â†’ auxiliary.review) owns
every task's route; otherwise the active delegation provider decides each one.)Úresolve_task_routesÚroute_for_configN)r  r�  r‚  ri  rc   rh  )rZ  r~  r  rX   r�  r‚  rT  rI  s   &&&&    r[   Ú_routes_forrƒ  ú  sb   € ÷ QØÒÙ" 9°<Ó@Ð@ðÙ  Ó?ˆð ˆ7”S˜“^Õ# TÐ)Ð)øô ô Ø”3�s“8ˆ|Õûðús   —4 ´A¿AÁAÁAc          
      óš   € V ^8„  d   QhR\         \        \        \        3,          ,          R\        \        ,          R\         R\        RR/# )rW   Úrefusedr^  r_  Ú	live_homerY   N)r¾   r›   rc   r   r   )rZ   s   "r[   r\   r\     sK   € ÷ Vñ V¬¬d´3¼°8­nÕ)=ð VÌhÔWZÍmð VÔkoð VÜ+.ðVØ37ñVr]   c                 ó  € ^ RI Hp V  F`  pVR,          \        V4      8  d   W%R,          ,          MRpVf   K1  \        RRR7      ;_uu_ 4        VP	                  V4       RRR4       Kb  	  V! WVRR7       R#   + '       g   i     K‚  ; i)	é    )Úupdate_manifest_statusesr«   NzLive transcript finalize failedTr€   F)ÚhomeÚ	completed)re  r‰  rh  r2   Úfinalize)r…  r^  r_  r†  r‰  rH  rz  s   &&&&   r[   Ú_settle_refused_transcriptsr�    sw   € åBÛˆØ7<¸\Õ7JÌSÐQ]ÓM^Ô7^�, \Õ2Ö3ÐdhˆØÔÜÐ9ÀD×IÖIØ× Ñ  Ô'÷ JÑIñ ñ
 ˜]¸)Èu×U÷ J×IÐIús   ÁA:Á:Bc                óR   € V ^8„  d   QhR\         R\        R\        \        ,          /# )rW   rX   Ú	requestedrY   )r   r’   r   rc   )rZ   s   "r[   r\   r\     s%   € ÷ ñ ¬ð ¼ð ÄÌÅñ r]   c                ó¶   € ^ RI Hp V! 4       '       g   R# \        4       pV^ 8:  d   R# \        V R^ 4      pWA,           V8”  d
   RV RV R2# WA,           V n        R# )zÔCharge *requested* children against the finite one-shot session's total (delegation.oneshot_max_children);
the error text tells the model to do the work inline. Interactive and gateway sessions are never charged.)Úis_single_query_sessionNÚ_oneshot_children_spawnedz6Delegation budget for this one-shot run is exhausted (Ú/uÄ    subagents used; delegation.oneshot_max_children). Do the remaining work yourself in this session â€” reviewing your own diff and running the tests inline is expected here, not a delegated review.)Úagent.oneshot_footprintr‘  r   ra   r’  )rX   r�  r‘  r§   Úspents   &&   r[   Ú_oneshot_spawn_budgetr–    so   € õ @Ù"×$Ò$ÙÜ
#Ó
%€CØ
ˆa„xÙÜ�LÐ"=¸qÓA€EØÕ˜3ÔàDÀUÀGÈ1ÈSÈEð Rcð dð	
ð
 .3Õ->€LÔ*Ùr]   c                óN  € V ^8„  d   QhR\         \        ,          R\         \        ,          R\         \        \        \        \        3,          ,          ,          R\         \
        ,          R\         \        ,          R\         \        ,          R\         \        \        \        3,          ,          R\         \        \        ,          ,          R	\         \        ,          R
\         \        ,          R\         \        ,          R\         \        \        \        3,          ,          R\        /# )rW   r¬   r­   Útasksr°   rº   Ú
backgroundÚoutput_schemaÚimagesÚactionrÌ   Úmessager  rY   )r   rc   r¾   r›   r   r’   rt   )rZ   s   "r[   r\   r\   '  sò   € ÷ q)ñ q)Ü
”3�-ðq)Ü)1´#­ðq)ÜFNÌtÔTXÔY\Ô^aÐYaÕTbÕOcÕFdðq)äœS•Mðq)ä08¼µðq)äRZÔ[_ÕR`ðq)ô œD¤¤c �NÕ+ðq)ô =EÄTÌ#ÅYÕ<Oðq)ô aiÔilÕ`mðq)ô œ#•ð	q)ô 19¼µð	q)ô
 œd¤3¬ 8�nÕ-ðq)ô 	ñq)r]   c                ór  a&€ Vf   \        R4      # T;'       g    RP                  4       P                  4       pV\        9   d   \	        WÙW«4      # V'       d   VR8w  d   \        RV R24      # \        4       '       d   \        R4      # \        V4      pVe   \        VRR7      MRp\        VR	^ 4      p\        4       pVV8¼  d   \        R
V RV R24      # \        4       pVP                  R\        4      pVe   VV8w  d   \        P                  RVV4       \        4       p\!        WW&VV4      w  ppV'       g   \#        VV4      w  ppV'       g   \%        VV4      w  ppV'       g   \'        VVWË4      w  ppV'       d   \        V4      # X Uu. uF  pVP(                  '       d   K  VNK  	  upo&S&'       g5   \        RP+                  \,        P/                  R V 4       4      4      4      # \1        V4       UUu. uF+  w  ppVP(                  '       g   K  VP3                  V4      NK-  	  ppp\4        ;QJ d    V&3R lS& 4       F  '       d   K   RM	  RM! V&3R lS& 4       4      '       d   S&^ ,          P6                  M%\,        P/                  S&^ ,          P6                  4      p\9        V\;        S&4      4      pV'       d   \        V4      # \<        P>                  ! 4       p\A        V4      p^ RI!H"p V! VVVP                  R4      VP                  R4      VR7      w  p p!p"V'       d   \G        VV V!V4       \I        V\;        V4      V 4       \K        4       p#\M        VXVVVVV V!XR7	      w  p$pV'       d   \        V4      # \O        VV$VVWVV V!V".
V#OVN5RVRV/ p%\Q        V%V4      # u upi u uppi )am  Spawn child agents (single ``goal`` or ``tasks=[...]`` batch) or control running ones. ``action``
list/steer/stop run synchronously and bypass the pause gate, depth limit and async dispatch. ``role`` is legacy
(per-task beats top-level; capability is depth-derived). Returns JSON with one results entry per task, or a
dispatch handle when running in the background.z.delegate_task requires a parent agent context.rô   ÚspawnzUnknown action 'z-'. Use spawn (default), list, steer, or stop.zzDelegation spawning is paused. Clear the pause via the TUI (`p` in /agents) or the `delegation.pause` RPC before retrying.F)ÚdefaultrÃ   z&Delegation depth limit reached (depth=z, max_spawn_depth=z‡). Raise delegation.max_spawn_depth in config.yaml if deeper nesting is required (no hard ceiling, but each level multiplies API cost).r°   zidelegate_task: ignoring caller-supplied max_iterations=%s; using delegation.max_iterations=%s from configÚ c              3   ó8   "  € T F  qP                   x € K  	  R # 5i©N)r-  )Ú.0rk   s   & r[   Ú	<genexpr>Ú delegate_task.<locals>.<genexpr>k  s   é € Ð0IÁ&¸Q·¶Ã&ùs   ‚c              3   ób   <"  € T F$  qP                   S^ ,          P                   8H  x € K&  	  R# 5i)rˆ  N)rM  )r¤  rk   Úrunnables   & €r[   r¥  r¦  o  s"   øé € Ð$TÉ8Àa§W¡W°¸µ×0AÑ0AÖ%AË8ùs   ƒ,/T)Úcreate_live_transcriptsr¯   rï   )r¯   rï   rŠ  )r]  r°   rX   r^  r_  rX  r†  r…  ))Ú
tool_errorrm   rn   r7   r;   rB   rq   r   ra   r   r    r¡   ÚDEFAULT_MAX_ITERATIONSre   rf   r   rJ   rH   rG   rƒ  r-  Újoinr›   Úfromkeysrg  Úrefused_entryÚallrM  r–  rh  ÚtimeÚ	monotonicri   re  r©  r�  r(   r)   r|  r'   r*   )'r¬   r­   r˜  r°   rº   r™  rš  r›  rœ  rÌ   r�  rX   r  Únormalized_actionr]  rÎ   r  r~  Údefault_max_iterÚmax_childrenrZ  Úerrr[  rX  r\  rk   rs  r…  rM  Úoverall_startÚ
_live_homer©  r^  r_  Ú
live_pathsÚoriginrr  Úbatchr¨  s'   &&&&&&&&&&&&&                         @r[   Údelegate_taskr»  '  sƒ  ø€ ð ÒÜÐJÓKÐKàŸ˜ 2×,Ñ,Ó.×4Ñ4Ó6ÐØÔ,Ô,Ü%Ð&7ÀgÓ\Ð\ßÐ.°'Ô9ÜÐ,¨V¨HÐ4aÐbÓcÐcô ×ÒÜðNó
ð 	
ô
 ˜tÓ$€Hð @JÒ?U” °UÕ;Ð[`€Jä�LÐ"3°QÓ7€EÜ$Ó&€IØ�	ÔÜØ4°U°GÐ;MÈiÈ[ð Y$ð %ó
ð 	
ô ‹.€CØ—w‘wÐ/Ô1GÓHÐð Ò! nÐ8HÔ&HÜ�‰ØwØÐ,ô	
ô 0Ó1€LÜ)¨$¸ÈxÐYeÓf�N€IˆsßÜ0°¸MÓJÑˆ�cßÜ.¨y¸&ÓAÑˆ�Sßô
 " )¨S°/ÓP‰ˆ�ß
Ü˜#‹Ðñ "Ó1™6�a¨¯­—�™6Ñ1€HßÜ˜#Ÿ(™(¤4§=¡=Ñ0IÁ&Ó0IÓ#IÓJÓKÐKÜ.7¸Ô.?ÔKÑ.?¡d a¨À1Ç7Å7Ô!ˆq�‰˜qÖ!Ñ.?€GÑK÷ "%£Ô$TÉ8Ó$T§§¢Ô$TÉ8Ó$T×!TÒ!TˆH�Q�K×ÒÔZ^×ZgÑZgÐhpÐqrÕhs×hyÑhyÓZz€EÜ
 ¬c°(«mÓ
<€Cß
Ü˜#‹Ðä—N’NÓ$€Mô # <Ó0€JåAÙ.EØ�7 %§)¡)¨GÓ"4¸u¿y¹yÈÓ?TØô/Ñ+€M�< ÷ Ü# G¨]¸LÈ*ÔUÜ�L¤# i£.°-Ô@ÜÓ€Fä#Ø�< °(ÐK[ÐjvØ#°,ÈKô�M€Hˆc÷ Ü˜#‹ÐÜØ�8˜\¨5°'À\Ø�| Zðà28ðà:Gòð ðð '.ñ€Eô
 �e˜ZÓ(Ð(ùò_ 2ùó Ls   ÆN.Æ*N.Ç=N3ÈN3Úindependent_completionsc                ó$   € V ^8„  d   QhR\         /# rs   ©rc   )rZ   s   "r[   r\   r\   �  s   € ÷ _ñ _ÄSñ _r]   c                ó$  €  \        4       ^8¬  ;'       d    \        4       pV'       d   R\        4        R2pMRp^ RIHp V f   V! 4       p V '       d   RMRp\
        P                  VR7      V,           \        ,           #   \         d    Rp Lmi ; i)	z�delegate_task description: ONLY guidance stated nowhere else in the schema
(limits live in the 'tasks' parameter description, rebuilt per get_definitions()).Fz|- Children cannot call clarify, memory, or cronjob.
- Children can themselves delegate while depth remains (max_spawn_depth=z6); the runtime derives this from depth automatically.
zC- Children cannot call delegate_task, clarify, memory, or cronjob.
©Ú_get_independent_completionsz0each ungrouped task / `group` returns on its ownzone message per call)Údelivery)r   r   r<  Útools.delegate_tool_configrÁ  Ú_DESCRIPTION_HEADrZ   Ú_DESCRIPTION_TAIL)r¼  Úorchestration_availableÚrestrictions_rulerÁ  rÂ  s   $    r[   Ú_build_top_level_descriptionrÈ  �  s«   € ð(Ü"6Ó"8¸AÑ"=×"]Ð"]ÔB[ÓB]Ð÷
 ðWÜWkÓWmÐVnð o?ð?ñ 	ð cÐÝGàÒ&Ù">Ó"@Ð÷ #ñ 	;Ø(>ð ô ×#Ñ#¨XÐ#Ó6Ð9JÕJÔM^Õ^Ð^øô) ô (Ø"'Òð(ús   ‚A? –A? Á?BÂBuØ  Spawn subagents in isolated contexts; each gets its own conversation, terminal session, and toolset, and only its final summary returns to you. Pass every task in `tasks` â€” one entry spawns one subagent, several run in parallel (limit in the tasks description).

Sessions without a later-result consumer (including one-shot CLI and cron) join parallel children and return results in this tool call. Otherwise runs in the background: dispatch returns live transcript paths and results re-enter as a new message when subagents finish ({delivery}). Background results are delivered only BETWEEN your turns: finish whatever does not depend on them, then give a one-line status and END YOUR TURN. Never wait or poll on transcripts, artifact files, or CI for a child. While children run, `action` (list/steer/stop) controls them live.

USE FOR: reasoning-heavy subtasks, work that would flood your context, or independent parallel workstreams.
DO NOT USE FOR (use these instead):
- Mechanical multi-step work with no reasoning needed -> execute_code
- A single tool call -> call the tool directly
- Tasks needing user interaction -> subagents cannot ask questions
- Durable work that must survive this session -> cronjob or terminal(background=True, notify=True); /stop, /new, or process exit halts running subagents (whole tree); each returns an 'interrupted' completion with partial output.

RULES:
- Children know nothing of this conversation: pass everything needed via 'context', including any required output language, tone, or style (e.g. "respond in Chinese").
- Child summaries are SELF-REPORTS, not verified facts: a child claiming "uploaded successfully" or "file written" may be wrong. For external side effects (uploads, remote writes, publishing), require a verifiable handle (URL, ID, absolute path) and verify it yourself before telling the user the operation succeeded.
- Children cannot close tracked work: a child asked to close it returns findings instead; the parent applies the transition.
zl- Children inherit the parent model unless pinned via delegation.provider / delegation.model in config.yaml.c                ó$   € V ^8„  d   QhR\         /# rs   r¾  )rZ   s   "r[   r\   r\   Ø  s   € ÷ ñ ¬ñ r]   c                 óR   €  \        4       p RV  R2#   \         d
    \        p  Li ; i)zICompose the 'tasks' parameter description with current concurrency limit.zThe task(s), up to zÏ in parallel for this user (set via delegation.max_concurrent_children). Each entry spawns one subagent with isolated context and terminal session; a single task is a one-entry array. Required when spawning.)r   r<  r   )r´  s    r[   Ú_build_tasks_param_descriptionrË  Ø  s=   € ð8Ü3Ó5ˆð ˜l˜^ð ,8ð 	8ðøô ô 8Ü7Šð8ús   ‚
 ’&¥&c                ó$   € V ^8„  d   QhR\         /# rs   rš   )rZ   s   "r[   r\   r\   å  s   € ÷ ñ ¬ñ r]   c                 óÄ  € ^ RI Hp  V ! 4       p/ \        R,          Cp\        R,          R,          P                  4        UUu/ uF  w  r4V\	        V4      bK  	  uppVR&   \        4       VR,          R,          R&   V'       g\   VR,          R,          p/ VR,          CRVR,          R,          P                  4        UUu/ uF  w  r4VR8w  g   K  W4bK  	  upp/CVR&   ^ RIHp V! \        4       4      w  rxV'       d5   VR,          R,          p/ VR,          CR/ VR,          R,          CVC/CVR&   \        VR	7      p	RV'       d   V	 R
V 2RV/# T	RV/# u uppi u uppi )z“Per-call schema overrides (ToolEntry.dynamic_schema_overrides): every
get_definitions() pass rewrites the descriptions to the user's actual limits.rÀ  Ú
parametersÚ
propertiesr˜  ÚdescriptionÚitemsÚgroup)Úschema_extension)r¼  Ú
)
rÃ  rÁ  ÚDELEGATE_TASK_SCHEMArÑ  r›   rË  r  rÓ  r    rÈ  )
rÁ  r¼  Úoverrides_paramsÚkÚvr˜  rÓ  Úextra_paramsÚaddendumrÐ  s
             r[   Ú_build_dynamic_schema_overridesrÛ  å  sy  € õ Há:Ó<ÐØ=Ô.¨|Õ<Ð=Ðä=QÐR^Õ=_Ð`lÕ=m×=sÑ=sÔ=uÔ%vÑ=u±T°Q a¬¨a«¢jÑ=uÒ%vÐ�\Ñ"Ü=[Ó=]Ð�\Õ" 7Õ+¨MÑ:ç"Ø  Õ.¨wÕ7ˆð˜E '�Nð ¨LØ" 7�^¨LÕ9×?Ñ?ÔAô;
ÙA‘T�QÀQÈ'Á\ŒDˆAŠDÑAò;
ñ ˆˆg‰õ <Ù-¬l«nÓ=Ñ€LßØ  Õ.¨wÕ7ˆØk˜E '�NÐk¨LÐ:j¸UÀ7½^ÈLÕ=YÐ:jÐ]iÐ:jÑkˆˆg‰Ü.ÐG^Ô_€Kà·x˜+˜ b¨¨
Ð3ØÐ&ðð ØEPØÐ&ðð ùó# &wùó
;
s   ÁEÂ?E
ÃE
c                ó<   € V ^8„  d   QhR\         R\         R\        /# )rW   Útype_rÐ  rY   )rc   r›   )rZ   s   "r[   r\   r\     s&   € ÷ @ñ @Œcð @¤ð @´ñ @r]   c                 ó   € R V /VCRV/C# )ÚtyperÐ  rv   )rÝ  rÐ  Úextras   &&,r[   Ú_prá    s   € Ø�EÐ?˜UÐ? M°;Ñ?Ð?r]   Únamer»  rÐ  z™Spawn one or more subagents in isolated contexts. Description is rebuilt at every get_definitions() call to reflect the user's current delegation limits.rÎ  rß  ÚobjectrÏ  r˜  ÚarrayÚminItemsrÑ  r¬   Ústringuz   What this subagent should accomplish. Be specific and self-contained â€” it knows nothing about your conversation history.r­   u¤   Background THIS child needs: file paths, error messages, constraints. Each child sees only its own context â€” repeat shared background in every task that needs it.rš  uP  Optional JSON Schema this child's final answer must validate against (told to the child up front; parent validates with one bounded correction retry; result gains schema_valid, plus schema_errors on failure â€” the child's raw text is still returned as summary, never discarded). Keep it forgiving â€” require only fields you will read.r›  uC  Optional images this child must SEE (max 8): local file paths or http(s) URLs â€” e.g. a screenshot the user sent, a design mock, a chart. Vision-capable children receive the pixels on their first turn; non-vision children get path hints for vision_analyze. Text files do NOT belong here â€” put paths in 'context' instead.)rÑ  rÒ  aZ  Optional result-delivery bucket within this call (only when delegation.independent_completions is enabled; otherwise the whole call returns as one message). Tasks sharing a group return together in ONE message; ungrouped tasks return individually as each finishes. This does not order execution; if B needs A's output, dispatch B after A returns.Úrequiredz#(rebuilt at get_definitions() time)rœ  aR  Default 'spawn'. Live control of running children: 'list' = ids/goals/status/transcripts; 'steer' = queue course-correction text into one child (subagent_id + message) without stopping it; 'stop' = end one child early (subagent_id; partial result still returns). Control actions return immediately; goal/tasks are ignored unless spawning.)ÚenumrÌ   zPTarget for action='steer'/'stop' (ids from the spawn response or action='list').r�  zwFor action='steer': the course correction, appended to the child's next tool result mid-run. Be directive and specific.)Úregistryrª  c                ó0   € V ^8„  d   QhR\         R\        /# )rW   rQ  rY   )r›   rt   )rZ   s   "r[   r\   r\   \  s   € ÷ ?ñ ?¤$ð ?¼dñ ?r]   c                ó$   € \        VR^ 4      ^ 8”  * # )u
  Background flag for the MODEL-facing dispatch path (registry fallback). Top-level delegations always run in the
background â€” the model does not choose â€” for single tasks and fan-out batches alike (one async unit, one
consolidated result); an orchestrator subagent (depth > 0) is the exception since it needs its workers' results
within its own turn. The live path is ``run_agent._dispatch_delegate_task``; this mirrors it for the rare case
the intercept is bypassed. Direct Python callers keep the synchronous default.rÃ   )ra   )rQ  rX   s   &&r[   Ú_model_background_valuerì  \  s   € ô �|Ð%6¸Ó:¸QÒ>Ð>r]   Úacp_commandÚacp_argsc                ó0   € V ^8„  d   QhR\         R\         /# )rW   r˜  rY   ry   )rZ   s   "r[   r\   r\   f  s   € ÷ }ñ }¬3ð }´3ñ }r]   c                óz  € \        V \        4      '       d;   \        ;QJ d    R V  4       F  '       g   K   RM	  RM! R V  4       4      '       g   V # V  UUUu. uFL  p\        V\        4      '       d2   VP	                  4        UUu/ uF  w  r#V\
        9  g   K  W#bK  	  uppMTNKN  	  uppp# u uppi u upppi )zlDrop trusted-config-only task fields from model-supplied tasks (same list object back when nothing changed).c              3   óˆ   "  € T F8  p\        V\        4      ;'       d    \        VP                  4       ,          x € K:  	  R # 5ir£  )rb   r›   Ú_MODEL_HIDDEN_TASK_FIELDSÚkeys)r¤  rt  s   & r[   r¥  Ú2_strip_model_hidden_task_fields.<locals>.<genexpr>h  s5   é € Ð-zÑtyÐop¬j¸¼DÓ.A×.jÐ.jÔF_Ðbc×bhÑbhÓbjÕFjÔ.jÓtyùs
   ‚Až$ATF)rb   r¾   Úanyr›   rÑ  rò  )r˜  rt  r×  rØ  s   &   r[   Ú_strip_model_hidden_task_fieldsrö  f  sŒ   € ä�eœT×"Ò"¯#«#Ñ-zÑtyÓ-z¯#¯#ª#Ñ-zÑtyÓ-z×*zÒ*zØˆÙv{Õ|Ñv{ÐqrÔR\Ð]^Ô`d×ReÒRe˜aŸg™gœiÔN™i‘d�a¨1Ô4MÑ+MŒTˆQŠT™iÓNÐklÒlÑv{Ó|Ð|ùÓNùÔ|s   Á.B6ÂB0ÂB0Â!
B6Â0B6Ú
delegationc                 ó¼  € \        V P                  R 4      V P                  R4      \        V P                  R4      4      V P                  R4      V P                  R4      \        WP                  R4      4      V P                  R4      V P                  R4      V P                  R4      V P                  R	4      V P                  R
4      VP                  R4      R7      # )r¬   r­   r˜  r°   rº   rX   rš  r›  rœ  rÌ   r�  )r¬   r­   r˜  r°   rº   r™  rš  r›  rœ  rÌ   r�  rX   )r»  r¡   rö  rì  )rQ  Úkws   &,r[   ræ   ræ   q  s«   € œ}Ø�X‰X�fÓ t§x¡x°	Ó':ÔBaÐbf×bjÑbjÐkrÓbsÓBtØ—x‘xÐ 0Ó1¸¿¹ÀÓ8HÜ*¨4·±¸Ó1GÓHÐX\×X`ÑX`ÐapÓXqØ�x‰x˜Ó!¨$¯(©(°8Ó*<È$Ï(É(ÐS`ÓJaÐko×ksÑksÐt}Ók~Ø—V‘V˜NÓ+õ r]   u   ðŸ”€)râ  ÚtoolsetrF  ÚhandlerÚcheck_fnÚemojiÚdynamic_schema_overrides)NNNNNNNNrT   NNN)NN)NNNNNNNNNNNNN)rŸ  r¾   ÚsteerÚstopr£  )�Ú__doc__r>  r°  r  Úpathlibr   Útypingr   r   r   r   Útools.terminal_toolr   Ú_set_subagent_approval_cbÚutilsr   Ú	getLoggerÚ__name__re   Útools.delegate_tool_child_runr	   r
   r   r   r   r   r   r   r   r   r   r   r   rÃ  r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   Útools.delegate_tool_dispatchr'   r(   r)   r*   Útools.delegate_tool_progressr+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   Útools.delegate_tool_registryr7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   Útools.delegate_tool_tasksrF   rG   rH   rI   rJ   Útools.delegate_tool_tuningrK   Útools.delegate_tool_toolsetsrL   rM   rN   rO   Útools.delegate_tool_resultsrP   rQ   rR   rS   Ú	frozensetro   ri   rq   r«  Ú_HEARTBEAT_INTERVALÚ_HEARTBEAT_STALE_CYCLES_IDLEÚ_HEARTBEAT_STALE_CYCLES_IN_TOOLÚ_STALE_RESULT_GRACE_SECONDSrw   rˆ   r�   r•   r—   r©   r#  rK  rR  rW  r|  rƒ  r�  r–  r»  rÈ  rÄ  rÅ  rË  rÛ  rá  rÕ  Útools.registryré  rª  rì  rò  rö  Úregisterrv   r]   r[   Ú<module>r     s   ðñ
ó Û Û Ý ß ,Ó ,å RÝ !à	×	Ò	˜8Ó	$€÷÷ ÷ õ ÷÷ ÷ ÷ õ ÷ ^Ó ]÷÷ ÷ ó ÷
÷ ÷ ÷ ñ ÷õ õ >÷ó ÷ó ñ 
�F˜NÐ+Ó	,€õõDð Ð ØÐ ð
  "Ð Ø"$Ð ð "Ð õõ
õ> ð €õõ$)÷&]ñ~?EØdhð?Eàð?Eà=A÷?Eð ?EõD
õð6ð jn÷6õr*õVõ÷(q)ðl_¸D÷ _ð8+ð ð: sð õõõ<@ð ˆOð ð	rð Ø�Øð
 Ø˜Ø˜AØØ˜HØ Ø¡Ø$ðGó!ð
 "¡2Ø$ðró$ð
 (©Ø$ðuó*ð !¡"Ø#ð[ð $*¨8Ð"4ô#ð  ¡Ø$ðbó"ð5!#ðD   ðI%ðL ÐDðS*ðZ ‘bØð^ò 8ô	ð ™2˜hÐ(zÓ{Ø‘rØðSóð{B
ðF 	�BðKFðPÐ ÷h 0÷?ð +¨JÐ7Ð õ}ð 	× Ó Ø	ØØñð )Ø
Ø<÷r]   