| 84 | |
| 85 | @dataclass |
| 86 | class QueryParams: |
| 87 | messages: list[Message] |
| 88 | # WI-1.1: ``system_prompt`` accepts either the legacy ``str`` shape |
| 89 | # (joined sections, no cache_control markers) OR the block-list shape |
| 90 | # ``list[dict]`` produced by ``build_full_system_prompt_blocks``. The |
| 91 | # block-list shape is what engages Anthropic's prompt cache via |
| 92 | # ``cache_control: {type: 'ephemeral'}`` markers; the str shape is |
| 93 | # retained for backward compat with callers that pass a custom prompt. |
| 94 | system_prompt: str | list[dict[str, Any]] |
| 95 | tools: Tools |
| 96 | tool_registry: ToolRegistry |
| 97 | tool_use_context: ToolContext |
| 98 | provider: BaseProvider |
| 99 | abort_controller: AbortController |
| 100 | query_source: str = "repl_main_thread" |
| 101 | # ch05 round-3 G2: the +500k turn budget. Deliberate deviation from |
| 102 | # TS's ambient bootstrap-global design — params is the carrier; the |
| 103 | # bootstrap globals remain the mechanism (snapshot at query() entry). |
| 104 | token_budget: int | None = None |
| 105 | max_output_tokens_override: int | None = None |
| 106 | max_turns: int | None = None |
| 107 | user_context: dict[str, str] | None = None |
| 108 | system_context: dict[str, str] | None = None |
| 109 | pipeline_config: PipelineConfig | None = None |
| 110 | # Ch5/F-followup: live streaming text callback. When set, the |
| 111 | # provider's chat_stream_response receives this callback so each |
| 112 | # SSE text-delta drives the UI in real time. Critical for the |
| 113 | # TUI/headless live-stream UX after the F.2/F.3 migration to this |
| 114 | # loop — without it, callers see the entire response materialize |
| 115 | # at once after the model turn completes. The callback can also |
| 116 | # raise AbortError from inside the SDK's stream context to tear |
| 117 | # down the HTTP socket on ESC. |
| 118 | on_text_chunk: Callable[[str], None] | None = None |
| 119 | # Live thinking deltas (separate channel from on_text_chunk) for the TUI's |
| 120 | # streaming thinking view. None → thinking isn't surfaced live. |
| 121 | on_thinking_chunk: Callable[[str], None] | None = None |
| 122 | |
| 123 | # Extended thinking ("adaptive" mode) — opt the model into a private |
| 124 | # reasoning scratchpad before producing its visible answer. Defaults |
| 125 | # to ``None`` which auto-enables on Anthropic Claude 4.x models |
| 126 | # (the only family the API supports it on) and stays off elsewhere. |
| 127 | # Pass ``False`` to force-disable (e.g. for determinism in tests). |
| 128 | # Mirrors the TS reference which always passes |
| 129 | # ``thinking: {type: "adaptive"}`` on these models. |
| 130 | extended_thinking: bool | None = None |
| 131 | # Output-effort hint forwarded as ``output_config.effort``. Anthropic |
| 132 | # accepts ``"low" | "medium" | "high"``. Only sent when extended |
| 133 | # thinking is active. |
| 134 | thinking_effort: str = "medium" |
| 135 | |
| 136 | |
| 137 | @dataclass |
no outgoing calls