refactor(agent/agent_init): pack init_agent signature (AST-neutral)

This commit is contained in:
Teknium
2026-09-02 19:53:20 -07:00
parent 1defa76992
commit 9065fb15fa
+34 -79
View File
@@ -2211,90 +2211,45 @@ _CALLBACK_PARAMS = (
def init_agent(
agent,
base_url: str = None,
api_key: str = None,
provider: str = None,
api_mode: str = None,
acp_command: str = None,
acp_args: list[str] | None = None,
command: str = None,
args: list[str] | None = None,
model: str = "",
max_iterations: int = sys.maxsize, # Default: unlimited tool-calling iterations (shared with subagents)
enabled_toolsets: List[str] = None,
disabled_toolsets: List[str] = None,
save_trajectories: bool = False,
verbose_logging: bool = False,
quiet_mode: bool = False,
tool_progress_mode: str = "all",
ephemeral_system_prompt: str = None,
log_prefix_chars: int = 100,
log_prefix: str = "",
providers_allowed: List[str] = None,
providers_ignored: List[str] = None,
providers_order: List[str] = None,
provider_sort: str = None,
provider_require_parameters: bool = False,
provider_data_collection: str = None,
openrouter_min_coding_score: Optional[float] = None,
session_id: str = None,
tool_progress_callback: callable = None,
tool_start_callback: callable = None,
tool_complete_callback: callable = None,
thinking_callback: callable = None,
reasoning_callback: callable = None,
clarify_callback: callable = None,
read_terminal_callback: callable = None,
read_preview_callback: callable = None,
drive_preview_callback: callable = None,
read_window_below_callback: callable = None,
setup_mcp_callback: callable = None,
tour_callback: callable = None,
step_callback: callable = None,
stream_delta_callback: callable = None,
interim_assistant_callback: callable = None,
tool_gen_callback: callable = None,
status_callback: callable = None,
notice_callback: callable = None,
notice_clear_callback: callable = None,
agent, base_url: str = None, api_key: str = None, provider: str = None, api_mode: str = None,
acp_command: str = None, acp_args: list[str] | None = None, command: str = None,
args: list[str] | None = None, model: str = "", max_iterations: int = sys.maxsize,
enabled_toolsets: List[str] = None, disabled_toolsets: List[str] = None,
save_trajectories: bool = False, verbose_logging: bool = False, quiet_mode: bool = False,
tool_progress_mode: str = "all", ephemeral_system_prompt: str = None,
log_prefix_chars: int = 100, log_prefix: str = "", providers_allowed: List[str] = None,
providers_ignored: List[str] = None, providers_order: List[str] = None,
provider_sort: str = None, provider_require_parameters: bool = False,
provider_data_collection: str = None, openrouter_min_coding_score: Optional[float] = None,
session_id: str = None, tool_progress_callback: callable = None,
tool_start_callback: callable = None, tool_complete_callback: callable = None,
thinking_callback: callable = None, reasoning_callback: callable = None,
clarify_callback: callable = None, read_terminal_callback: callable = None,
read_preview_callback: callable = None, drive_preview_callback: callable = None,
read_window_below_callback: callable = None, setup_mcp_callback: callable = None,
tour_callback: callable = None, step_callback: callable = None,
stream_delta_callback: callable = None, interim_assistant_callback: callable = None,
tool_gen_callback: callable = None, status_callback: callable = None,
notice_callback: callable = None, notice_clear_callback: callable = None,
event_callback: Optional[Callable[[str, dict], None]] = None,
reaction_callback: Optional[Callable[[str], None]] = None,
max_tokens: int = None,
reasoning_config: Dict[str, Any] = None,
service_tier: str = None,
request_overrides: Dict[str, Any] = None,
prefill_messages: List[Dict[str, Any]] = None,
platform: str = None,
user_id: str = None,
user_id_alt: str = None,
user_name: str = None,
chat_id: str = None,
chat_name: str = None,
chat_type: str = None,
thread_id: str = None,
gateway_session_key: str = None,
skip_context_files: bool = False,
load_soul_identity: bool = False,
skip_memory: bool = False,
skip_background_review: bool = False,
session_db=None,
parent_session_id: str = None,
iteration_budget: "IterationBudget" = None,
run_budget_seconds: Optional[float] = None,
fallback_model: Dict[str, Any] = None,
credential_pool=None,
checkpoints_enabled: bool = False,
checkpoint_max_snapshots: int = 20,
checkpoint_max_total_size_mb: int = 500,
checkpoint_max_file_size_mb: int = 10,
pass_session_id: bool = False,
requested_provider: str = None,
capabilities: Optional[Dict[str, bool]] = None,
reaction_callback: Optional[Callable[[str], None]] = None, max_tokens: int = None,
reasoning_config: Dict[str, Any] = None, service_tier: str = None,
request_overrides: Dict[str, Any] = None, prefill_messages: List[Dict[str, Any]] = None,
platform: str = None, user_id: str = None, user_id_alt: str = None, user_name: str = None,
chat_id: str = None, chat_name: str = None, chat_type: str = None, thread_id: str = None,
gateway_session_key: str = None, skip_context_files: bool = False,
load_soul_identity: bool = False, skip_memory: bool = False,
skip_background_review: bool = False, session_db=None, parent_session_id: str = None,
iteration_budget: "IterationBudget" = None, run_budget_seconds: Optional[float] = None,
fallback_model: Dict[str, Any] = None, credential_pool=None, checkpoints_enabled: bool = False,
checkpoint_max_snapshots: int = 20, checkpoint_max_total_size_mb: int = 500,
checkpoint_max_file_size_mb: int = 10, pass_session_id: bool = False,
requested_provider: str = None, capabilities: Optional[Dict[str, bool]] = None,
):
"""Initialize the AI Agent (body of :meth:`AIAgent.__init__`).
Non-obvious parameters:
max_iterations: default unlimited (sys.maxsize); the budget is shared with subagents.
requested_provider: provider identity before runtime canonicalization.
openrouter_min_coding_score: coding-score floor for ``openrouter/pareto-code`` only.
clarify_callback: ``(question, choices) -> str``; None → the clarify tool errors.