
    ;-i]                    `    d Z ddlmZ ddlZddlmZmZ ddlmZ dZ	dZ
	 	 dddZddZddZdS )z Agent config generation helpers.    )annotationsN)	LLMClientLLMParseError)AgentConfiga  Generate a valid AgentConfig JSON object.

Return exactly one JSON object compatible with the AgentConfig model.

Requirements:
- The agent must be stateless.
- The system_prompt must instruct the agent to produce structured JSON output only.
- The input_schema must describe an object with prompt, meeting_summary, and context_summary.
- The output_schema for a normal agent must be compatible with AgentTurnResult.
- AgentTurnResult compatibility requires these output fields:
  - response
  - key_points
  - risks
  - recommendations
  - citations
- The output_schema must require response.
- The response must be concise, valid JSON only, with no markdown fences or commentary.
a  Generate a valid AgentConfig JSON object for a PM orchestration agent.

Return exactly one JSON object compatible with the AgentConfig model.

Requirements:
- The agent must be stateless.
- The system_prompt must instruct the PM agent to output valid JSON decisions only.
- The PM agent output must be compatible with PMDecision.
- PMDecision compatibility requires these fields:
  - analysis
  - next_action
  - target_agent
  - prompt_for_agent
  - final_report
- The output contract must make CALL_AGENT and FINISH explicit.
- The output_schema must require analysis and next_action.
- The response must be concise, valid JSON only, with no markdown fences or commentary.
standarddescriptionstrnameroleprovidermodel
llm_clientLLMClient | None
agent_kindreturnr   c                   t           j                            d          dk    rF||| d| d|  ddddd	idd	idd	id
g d
dt          |          ||dd	}t	          j        |          S |pt                      }t          |          }	d| d| d| d|  }
d}t          d          D ]J}	 |	                    |||	|
          }t	          j        |          c S # t          $ r}|}Y d}~Cd}~ww xY w||t          d          )zABuild an agent configuration from a natural-language description.MULTI_AGENT_FAKE_BUILDER1zYou are z. z?Input contains PM prompt, meeting summary, and context summary.z/Output must be structured JSON for the runtime.objecttypestring)promptmeeting_summarycontext_summaryr   
propertiesrequired)r   r   )	r
   r   r   system_promptinput_schema_descriptionoutput_schema_descriptioninput_schemaoutput_schemametadatazname=z
role=z
kind=z
description=N   )r   r   r   user_promptz%builder retry loop ended unexpectedly)osenvironget_default_output_schemar   model_validater   _builder_system_promptrangegenerate_structured_responser   RuntimeError)r   r
   r   r   r   r   r   payloadclientr   r%   
last_error_excs                 9/root/projects/multi-agents-meeting/core/agent_builder.pybuild_agent_configr5   3   s    
z~~011S88&=====(i)Z %x0(.'9(.'9 
 MLL  4J??%->>#
 
& )'222&9;;F*:66M	% 	% 	%	% 	%	% 	% #	% 	%  (,J1XX 
 
		99!+'	 :  G -g66666 	 	 	JJJJJJ	 
>
?
??s   +,C
C0$C++C0c                *    | dk    rt           S t          S )Npm)PM_AGENT_BUILDER_SYSTEM_PROMPT$STANDARD_AGENT_BUILDER_SYSTEM_PROMPTr   s    r4   r+   r+   o   s    T--//    dict[str, object]c                l    | dk    rdddiddiddiddiddidddgdS dddidd	idd	idd	idd	id
dgdS )Nr7   r   r   r   )analysisnext_actiontarget_agentprompt_for_agentfinal_reportr>   r?   r   array)response
key_pointsrisksrecommendations	citationsrD    r:   s    r4   r)   r)   u   s    T#X. &1!' 2%+X$6!' 2  $]3

 

 
	
 *!7+g& &0 '*
 
  L
 
 
r;   )Nr   )r   r	   r
   r	   r   r	   r   r	   r   r	   r   r   r   r	   r   r   )r   r	   r   r	   )r   r	   r   r<   )__doc__
__future__r   r&   core.llmr   r   core.modelsr   r9   r8   r5   r+   r)   rI   r;   r4   <module>rN      s    & & " " " " " " 				 - - - - - - - - # # # # # #( $(" 4 $( 9@ 9@ 9@ 9@ 9@x0 0 0 0     r;   