ó
    ³ü¡jÈ  ã                  ó0  • % S r SSKJr  SSKJr  SSKJrJrJrJ	r	J
r
JrJr  SSKJrJrJr  SSKJrJr  SSKJr  SSKJr  SS	KJr  SS
KJrJr  Sr\	S   r\\ \\   \\    S.r!S\"S'   Sr# " S S\5      r$ " S S\5      r%\" SS9SS j5       r&SS jr'SS jr(g)u¡  Answering into a schema built for the question that was asked.

Two calls. A planner reads the question alone â€” never the context, never the
answer â€” and declares the fields the answer should have. Those declarations
are compiled into a Pydantic model, and the answering agent is constrained to
it through the same call `declared` uses. The only difference between the two
approaches is who authored the model.

The planner emits field declarations rather than raw JSON Schema. A model
writing free-form JSON Schema produces dialects the validator then rejects,
and that surfaces as a retry loop rather than an answer; a closed set of field
types cannot fail that way.
é    )Úannotations)Ú	lru_cache)ÚAnyÚDictÚListÚLiteralÚOptionalÚTupleÚType)Ú	BaseModelÚFieldÚcreate_model)ÚAgentÚNativeOutput)ÚModelSettings)Úusage_metadata_from)Úanthropic_model)Úrun_metadataÚtracerzclaude-haiku-4-5)ÚstringÚnumberÚstring_listÚnumber_listzDict[str, Any]Ú	_PY_TYPESuá  You design the return shape for a financial-document question. You are given
the QUESTION only â€” never the document, never the answer. Do not attempt to
answer it.

Decide first whether the question asks for data or for explanation.

- If it asks you to explain, compare, summarize, or reason, set `wants_value`
  false and return no fields. It will be answered in prose.
- Otherwise set `wants_value` true and declare the fields that hold the
  answer, and only those.

Rules for fields:
- Declare the narrowest set that answers the question. A question naming one
  figure gets ONE field holding that figure, plus at most the qualifiers the
  question itself names.
- Name fields in snake_case after what they hold.
- Each field's description must tell the answering agent to report the figure
  exactly as printed in the source, with no surrounding words.
- Never declare a field for citations or sources; those are added for you.
- Never declare a field whose value would be a sentence.
c                  óf   • \ rS rSr% \" SS9rS\S'   \" SS9rS\S'   \" S	S9rS\S
'   Sr	S\S'   Sr
g)Ú	FieldSpecé?   zsnake_case field name.©ÚdescriptionÚstrÚnamezThe field's type.Ú	FieldTypeÚtypez'What the answering agent must put here.r   TÚboolÚrequired© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r!   Ú__annotations__r#   r   r%   Ú__static_attributes__r&   ó    Ú>/home/mande/repo/quber/src/quber/playground/answers/planned.pyr   r   ?   s<   ‡ ÙÐ":Ñ;€Dˆ#Ó;ÙÐ(;Ñ<€Dˆ)Ó<ÙÐ)RÑS€K�ÓSØ€HˆdÖr-   r   c                  óD   • \ rS rSr% \" SS9rS\S'   \" \SS9rS\S	'   S
r	g)ÚPlanéF   zITrue when the question asks for data; false when it asks for explanation.r   r$   Úwants_valuez5The answer's fields. Empty when wants_value is false.©Údefault_factoryr   zList[FieldSpec]Úfieldsr&   N)
r'   r(   r)   r*   r   r2   r+   Úlistr5   r,   r&   r-   r.   r0   r0   F   s/   ‡ ÙØ_ñ€K�ó ñ $ØÐ*añ€FˆOö r-   r0   é   )Úmaxsizec            	     ód   • [        [        [        5      [        [        5      [
        [        SS9S9$ )Ng        )Útemperature)Úoutput_typeÚsystem_promptÚmodel_settings)r   r   ÚPLANNER_MODELr   r0   ÚPLANNER_PROMPTr   r&   r-   r.   Ú_plannerr@   O   s*   € äÜœÓ&Ü ¤Ó&Ü$Ü$°Ñ5ñ	ð r-   c              ƒ  ó°  #   • SU  3nSS[         S.SUS./0n[        5       R                  SU[        [	        5       S9 IS h  v•N n[        5       R                  U5      I S h  v•N nUR                  nSUR                  5       S./[        UR                  5      S	.Ul        S S S 5      IS h  v•N   U$  Nr NS N
! , IS h  v•N  (       d  f       W$ = f7f)
Nz
QUESTION: ÚmessagesÚsystem)ÚroleÚcontentÚuserÚplan_answer)ÚmodelÚextra_metadataÚ	assistant)rB   Úusage_metadata)r?   r   Úllm_runr>   r   r@   ÚrunÚoutputÚmodel_dump_jsonr   ÚusageÚoutputs)ÚquestionÚpromptÚinputsrM   ÚresultrN   s         r.   Úplan_forrV   Y   sÐ   é € Ø˜(˜Ð$€FàØ¬.Ñ9Ø¨Ñ/ð
ð€Fô ‹x×ÑØ�v¤]Ä<Ã>ð  ÷ ñ à	Ü“z—~‘~ fÓ-×-ˆØ—}‘}ˆà"-¸&×:PÑ:PÓ:RÑSÐTÜ1°&·,±,Ó?ñ
ˆŒ÷÷ ð €Mññ .÷÷ ÷ ð €MüsZ   ‚A CÁB5ÁCÁB;Á#B7Á$?B;Â#CÂ.B9Â/CÂ7B;Â9CÂ;CÃCÃCÃCc                ó¶  • 0 nU R                    H…  nUR                  S;   a  M  [        UR                     nUR                  (       a#  U[        UR                  S94XR                  '   M\  [        U   [        SUR                  S94XR                  '   M‡     [        [           [        [        SS94US'   [        [           [        SSS94US	'   [        S
0 UD6$ )aL  Turn a plan's field declarations into a model the answer agent fills.

`cited_ids` and `not_found` are appended to every compiled model, so
grounding and the not-present case survive whatever the planner declared.
A plan that declared a field by either of those names loses it to the
appended one, which is the intended precedence.
)Ú	cited_idsÚ	not_foundr   N)Údefaultr   z,Chunk and/or cell ids supporting the answer.r3   rX   z5Set only when the context lacks the answer; say what.rY   )ÚPlannedAnswer)r5   r!   r   r#   r%   r   r   r	   r   r    r6   r   )Úplanr5   ÚspecÚpys       r.   Úcompile_modelr_   m   sÊ   € ð *,€FØ—”ˆØ�9‰9Ð2Ó2ÙÜ�t—y‘yÑ!ˆØ�=�=Ø!#¤U°t×7GÑ7GÑ%HÐ IˆF—9‘9Óä!)¨"¡¬u¸TÈt×O_ÑO_Ñ/`Ð aˆF—9‘9Óñ ô 	ŒS‰	ÜœdÐ0^Ñ_ð€Fˆ;Ñô
 	”‰Ü�dÐ(_Ñ`ð€Fˆ;Ñô Ñ2¨6Ñ2Ð2r-   N)ÚreturnzAgent[None, Plan])rR   r    r`   r0   )r\   r0   r`   zType[BaseModel]))Ú__doc__Ú
__future__r   Ú	functoolsr   Útypingr   r   r   r   r	   r
   r   Úpydanticr   r   r   Úpydantic_air   r   Úpydantic_ai.settingsr   Úquber.agents.langsmith_tracerr   Úquber.playground.agentr   Úquber.playground.tracingr   r   r>   r"   r    Úfloatr   r+   r?   r   r0   r@   rV   r_   r&   r-   r.   Ú<module>rl      s¦   ðòõ #å ß B× BÑ Bç 3Ñ 3ß +Ý .å =Ý 2ß 9à"€àÐDÑE€	ð ØØ˜‘9Ø˜‘;ñ	€	ˆ>ó ð€ô0�	ô ôˆ9ô ñ �1Ñóó ðôõ(3r-   