OUTPUT #892 | 20953 karakter | 439 satır
========== YENİ KOMUT | 21.09.2026 16:17:20 ==========



========== YENİ KOMUT | 21.09.2026 16:17:20 ==========


### DELEGATION CONFIG
1:model:
2-  default: gpt-5.6-sol
3:  provider: openai-codex
4-  base_url: https://chatgpt.com/backend-api/codex
5-database:
6-  journal_mode: wal
7-runtime:
--
9-agent:
10-  max_turns: 150
11-  image_input_mode: text
12-  verbose: false
13:  reasoning_effort: medium
14-  personalities: {}
15-terminal:
16-  backend: local
17-  cwd: .
--
30-browser:
31-  inactivity_timeout: 120
32-  extension_control:
33-    enabled: false
34:  cloud_provider: camofox
35-tool_loop_guardrails:
36-  warnings_enabled: true
37-  hard_stop_enabled: true
38-  warn_after:
--
67-prompt_caching:
68-  cache_ttl: 5m
69-auxiliary:
70-  vision:
71:    provider: openai-codex
72:    model: gpt-5.6-sol
73-    timeout: 180
74:    reasoning_effort: none
75-  compression:
76:    provider: openai-codex
77:    model: gpt-5.6-luna
78-  skills_hub:
79:    provider: openai-codex
80:    model: gpt-5.6-luna
81:    reasoning_effort: minimal
82-  approval:
83:    provider: openai-codex
84:    model: gpt-5.6-luna
85-  review:
86:    provider: openai-codex
87:    model: gpt-5.6-luna
88:    reasoning_effort: low
89-  mcp:
90:    provider: openai-codex
91:    model: gpt-5.6-luna
92:    reasoning_effort: minimal
93-  title_generation:
94:    provider: openai-codex
95:    model: gpt-5.6-luna
96-  memory_query_rewrite:
97:    provider: openai-codex
98:    model: gpt-5.6-luna
99-  tts_audio_tags:
100:    provider: openai-codex
101:    model: gpt-5.6-luna
102:    reasoning_effort: none
103-  triage_specifier:
104:    provider: openai-codex
105:    model: gpt-5.6-luna
106:    reasoning_effort: low
107-  kanban_decomposer:
108:    provider: openai-codex
109:    model: gpt-5.6-luna
110:    reasoning_effort: low
111-  profile_describer:
112:    provider: openai-codex
113:    model: gpt-5.6-luna
114:    reasoning_effort: none
115-  curator:
116:    provider: openai-codex
117:    model: gpt-5.6-luna
118:    reasoning_effort: low
119-  background_review:
120-    enabled: false
121:    provider: openai-codex
122:    model: gpt-5.6-luna
123:    reasoning_effort: low
124-display:
125-  compact: false
126-  busy_input_mode: interrupt
127-  bell_on_complete: false
128:  show_reasoning: false
129-  background_process_notifications: concise
130-  streaming: true
131-  skin: default
132-  interim_assistant_messages: true
--
137-stt:
138-  enabled: true
139-  language: en
140-  local:
141:    model: base
142-  openai:
143:    model: whisper-1
144-    language: ''
145-memory:
146-  memory_enabled: true
147-  user_profile_enabled: true
148-  memory_char_limit: 2200
149-  user_char_limit: 1375
150-  nudge_interval: 10
151:delegation:
152:  model: gpt-6-astra
153:  provider: openai-codex
154-  fallback_providers: []
155-  child_timeout_seconds: 180
156-  max_iterations: 6
157-  toolsets: []
--
235-  - hermes-teams
236-  google_chat:
237-  - hermes-google_chat
238-image_gen:
239:  provider: openai-codex
240:  model: gpt-image-2-medium
241-known_plugin_toolsets:
242-  cli:
243-  - a2a
244-  - spotify

### DELEGATE MODEL RESOLUTION
2-"""
3-Delegate Tool -- Subagent Architecture
4-
5-Spawns child AIAgent instances with a fresh conversation, their own task_id
6-(terminal session, file-ops cache), the parent's toolsets minus child-blocked
7-tools, and a focused system prompt built from goal + context. Single-task and
8:batch (parallel) modes; top-level model calls run in the background while
9-orchestrator children wait for their own workers. The parent only ever sees
10:the delegation call and the summary result, never the child's intermediate
11-tool calls or reasoning.
12-"""
13-
14-import logging
15-import time
16-import weakref
--
28-    _lease_child_credential, _merge_late_steer, _register_child, _start_heartbeat, _validate_child_output_schema,
29-)
30-from tools.delegate_tool_config import (  # noqa: F401
31-    _DEFAULT_MAX_CONCURRENT_CHILDREN, _get_child_timeout, _get_max_async_children, _get_max_concurrent_children,
32-    _get_max_spawn_depth, _get_orchestrator_enabled, _get_subagent_approval_callback, _get_worktree_isolation,
33-    _inherit_parent_capabilities, _load_config, _merge_request_overrides, _resolve_child_credential_pool,
34:    _resolve_child_runtime, _resolve_delegation_credentials,
35-    _subagent_auto_approve, _subagent_auto_deny,
36-)
37-from tools.delegate_tool_dispatch import _Batch, _announce_batch, _capture_origin, _run_batch
38-from tools.delegate_tool_progress import (  # noqa: F401
39-    DelegateEvent, SUBAGENT_FAILURE_STATUSES, _batch_prefix, _build_child_progress_callback,
40-    _build_child_system_prompt, _clean_error_text, _emit_parent_console, _quiet, _resolve_workspace_hint,
--
53-from tools.delegate_tool_results import (  # noqa: F401
54-    _apply_summary_budget, _build_child_preserving_parent_tools, _run_child_lifecycle, _summarize_tool_arguments,
55-)
56-
57-_ROLES = frozenset({"leaf", "orchestrator"})
58-
59:# Nested delegation is granted by depth/role in _build_child_agent, never by the
60:# model naming toolsets (there is no model-facing toolsets argument).
61-def _normalize_role(r: Optional[str]) -> str:
62-    """'leaf' | 'orchestrator'; None/empty/unknown -> 'leaf' (unknown warns)."""
63-    r_norm = str(r).strip().lower() if r else "leaf"
64-    if r_norm not in _ROLES:
65-        logger.warning("Unknown delegate_task role=%r, coercing to 'leaf'", r)
66-        return "leaf"
67-    return r_norm
68-
69-DEFAULT_MAX_ITERATIONS = 250
70:_HEARTBEAT_INTERVAL = 30  # seconds between parent activity heartbeats during delegation
71-# Stale-heartbeat thresholds (cycles of _HEARTBEAT_INTERVAL with no progress). Progress = iteration, current_tool OR
72:# last_activity_ts advancing; an in-flight model wait refreshes last_activity_ts, so slow models are not "idle". Idle
73-# stays tight so a truly wedged child doesn't mask the gateway timeout; in-tool is much higher so legitimately long
74-# tools can finish.
75-_HEARTBEAT_STALE_CYCLES_IDLE = 15  # 450s idle between turns → stale
76-_HEARTBEAT_STALE_CYCLES_IN_TOOL = 40  # 1200s stuck on same tool → stale
77-
78-def check_delegate_requirements() -> bool:
--
112-        child._cache_ttl = "5m"
113-
114-_CHILD_CAP_MIN = 16_000  # below this a child compresses on every call; treat as a config error
115-
116-
117-def _child_compression_cap_tokens(raw) -> "int | None":
118:    """Validated ``delegation.compression_threshold_tokens``: an int >= 16000, or None for "no cap".
119-
120-    Unset / ``0`` / ``false`` / ``null`` mean no subagent-specific cap: the child compacts at the
121-    same ratio trigger as everyone else (0.50 x window). A bool ``true`` (YAML) would coerce to 1
122-    and make every call compress; a string like ``"200k"`` would silently read as no cap. Both are
123-    config errors: warn and treat as unset so a typo never changes compaction behaviour."""
124-    if raw is None or raw is False or raw == 0:
125-        return None
126-    if isinstance(raw, bool) or not isinstance(raw, (int, float)) or int(raw) < _CHILD_CAP_MIN:
127-        logger.warning(
128:            "delegation.compression_threshold_tokens=%r is not a token count >= %d; ignoring it "
129-            "(children keep the ratio trigger).", raw, _CHILD_CAP_MIN,
130-        )
131-        return None
132-    return int(raw)
133-
134-
135:def _apply_child_compression_cap(child, delegation_cfg: dict) -> None:
136:    """Optional absolute cap on the child's compaction trigger, ``delegation.compression_threshold_tokens``
137-    (lower of it and any global ``compression.threshold_tokens``). Off by default: a 1M-window child
138-    compacts at 500K like its parent. The compressor applies the cap on first window resolution, which
139-    happens after construction, so setting it here is exactly equivalent to config."""
140-    from agent.context_compressor import ContextCompressor
141-
142-    cc = getattr(child, "context_compressor", None)
143-    if not isinstance(cc, ContextCompressor):
144-        return
145:    cap = _child_compression_cap_tokens((delegation_cfg or {}).get("compression_threshold_tokens"))
146-    if cap is None:
147-        return
148-    existing = cc.threshold_tokens_cap
149-    cc.threshold_tokens_cap = min(cap, existing) if isinstance(existing, int) and existing > 0 else cap
150-    if cc._threshold_tokens is not None:  # already resolved: re-clamp now
151-        cc._apply_threshold_tokens_cap()
--
153-
154-def _build_child_agent(
155-    task_index: int,
156-    goal: str,
157-    context: Optional[str],
158-    toolsets: Optional[List[str]],
159:    model: Optional[str],
160-    max_iterations: int,
161-    task_count: int,
162-    parent_agent,
163:    # Credential overrides from delegation config
164:    override_provider: Optional[str] = None,
165-    override_base_url: Optional[str] = None,
166-    override_api_key: Optional[str] = None,
167-    override_api_mode: Optional[str] = None,
168-    override_request_overrides: Optional[Dict[str, Any]] = None,
169-
170:    # ACP transport overrides from trusted delegation config.
171-    override_acp_command: Optional[str] = None,
172-    override_acp_args: Optional[List[str]] = None,
173:    # Configuration block that owns the selected provider/model route. Internal
174-    # callers such as /review pass auxiliary.review here so fallback policy is
175:    # not accidentally read from the general delegation block.
176-    routing_cfg: Optional[Dict[str, Any]] = None,
177-    # Legacy; accepted for wire compat but ignored (capability is depth-derived).
178-    role: str = "leaf",
179-):
180:    """Build (don't run) a child AIAgent on the main thread. override_* (from delegation config) replace parent
181:    inheritance so children can run on a different provider:model pair."""
182-    import uuid as _uuid
183-    from run_agent import AIAgent
184:    from agent.delegation_context import delegated_child_context
185-    # Role is depth-derived: a child may delegate iff the kill switch is on and
186-    # depth budget remains below max_spawn_depth. The `role` arg is ignored.
187-    child_depth = getattr(parent_agent, "_delegate_depth", 0) + 1
188-    max_spawn = _get_max_spawn_depth()
189-    effective_role = "orchestrator" if _get_orchestrator_enabled() and child_depth < max_spawn else "leaf"
190-
191-    # One subagent_id shared by the progress callback, spawn_requested event and
192-    # the live registry; parent_id is set when THIS parent is itself a subagent.
193-    subagent_id = f"sa-{task_index}-{_uuid.uuid4().hex[:8]}"
194-    parent_subagent_id = getattr(parent_agent, "_subagent_id", None)
195-
196:    # General delegation behavior (reasoning, compression, capabilities) stays
197-    # global. Only fallback policy follows the owner of a per-call route such
198-    # as auxiliary.review.
199:    delegation_cfg = _load_config()
200-    child_toolsets, child_disabled_toolsets = _resolve_child_toolsets(parent_agent, toolsets, effective_role)
201-    child_prompt = _build_child_system_prompt(
202-        goal, context, workspace_path=_resolve_workspace_hint(parent_agent), role=effective_role,
203-        max_spawn_depth=max_spawn, child_depth=child_depth,
204-    )
205-    parent_api_key = getattr(parent_agent, "api_key", None)
206-    if (not parent_api_key) and hasattr(parent_agent, "_client_kwargs"):
207-        parent_api_key = parent_agent._client_kwargs.get("api_key")
208-
209:    # Shared ref: session_id once the child exists, delegation_id once
210-    # delegate_task stamps it — both ride on every relayed event.
211-    child_session_ref: Dict[str, Any] = {}
212-    child_progress_cb = _build_child_progress_callback(
213-        task_index, goal, parent_agent, task_count, subagent_id=subagent_id, parent_id=parent_subagent_id,
214-        depth=max(0, child_depth - 1),  # 0 = first-level child for the UI
215:        model=model or getattr(parent_agent, "model", None), toolsets=child_toolsets, session_ref=child_session_ref,
216-    )
217-    rt = _resolve_child_runtime(
218:        parent_agent, delegation_cfg, parent_api_key, model=model, override_provider=override_provider,
219-        override_base_url=override_base_url, override_api_key=override_api_key, override_api_mode=override_api_mode,
220-        override_acp_command=override_acp_command,
221-        override_acp_args=override_acp_args,
222-        routing_cfg=routing_cfg,
223-    )
224-    if override_request_overrides is not None:
225-        # honored whenever set, incl. the inherit branch where
226:        # _resolve_delegation_credentials already merged OVER the parent's
227-        request_overrides = dict(override_request_overrides)
228-    else:
229:        request_overrides = {} if override_provider else dict(getattr(parent_agent, "request_overrides", {}) or {})
230-    parent_sid = getattr(parent_agent, "session_id", None)
231-    child_session_db = _open_child_session_db(parent_agent)
232-    with delegated_child_context():
233-        try:
234-            child = AIAgent(
235-                **rt, max_iterations=max_iterations, prefill_messages=getattr(parent_agent, "prefill_messages", None),
--
258-    # Ownership transfer for the dedicated handle: the child's close() must release it (nothing else holds a
259-    # reference), and no parent teardown can close it out from under a background child (#81267).
260-    child_session_ref["session_id"] = getattr(child, "session_id", "") or ""
261-    child._progress_identity_ref = child_session_ref
262-    child._delegate_depth, child._delegate_role = child_depth, effective_role  # post-degrade role
263-    child._subagent_id, child._parent_subagent_id = subagent_id, parent_subagent_id
264:    _apply_child_compression_cap(child, delegation_cfg)
265-    # Ownership chain for action=list/steer/stop; weakref so a finished parent
266-    # can be collected while a detached child record lingers in the registry.
267-    try:
268-        child._delegate_parent_ref = weakref.ref(parent_agent)
269-    except TypeError:
270-        child._delegate_parent_ref = None  # non-weakref-able test doubles
271-    # Sidebar marker: subagent sessions stay out of session pickers even when a
272-    # parent delete orphans them (mirrors /branch's ``_branched_from``).
273:    if parent_sid and getattr(child, "_session_init_model_config", None) is not None:
274:        child._session_init_model_config["_delegate_from"] = parent_sid
275-    # Shared pool lets children rotate credentials on rate limits.
276:    child_pool = _resolve_child_credential_pool(rt["provider"], parent_agent, rt["base_url"])
277-    if child_pool is not None:
278-        child._credential_pool = child_pool
279-
280-    _attach_child(parent_agent, child)  # interrupt propagation
281-    # spawn_requested now — the child may queue for seconds when the pool is
282-    # saturated — then the subagent_start lifecycle hook.
--
361-    task_list: List[Dict[str, Any]], task_schemas: List[Optional[Dict[str, Any]]], creds: Dict[str, Any], *,
362-    top_role: str, max_iterations: int, parent_agent, routing_cfg: Dict[str, Any],
363-    live_deleg_id: Optional[str], live_writers: list,
364-) -> tuple[List[tuple], Optional[str]]:
365-    """Build every child on the main thread (construction is not thread-safe);
366-    ``(children, None)`` or ``([], error)`` on an explicit-pin preflight failure."""
367:    from tools.delegation_live_log import wrap_progress_callback
368:    from tools.delegation_output_schema import append_output_contract
369-    overrides = {
370:        "override_provider": creds["provider"], "override_base_url": creds["base_url"],
371-        "override_api_key": creds["api_key"], "override_api_mode": creds["api_mode"],
372-        "override_request_overrides": creds.get("request_overrides"),
373-        "override_acp_command": creds.get("command"),
374-        "override_acp_args": creds.get("args"),
375-        "routing_cfg": routing_cfg,
376-    }
--
381-        if _task_schema is not None:
382-            _child_context = append_output_contract(_child_context, _task_schema)
383-        try:
384-            child = _build_child_preserving_parent_tools(
385-                task_index=i, goal=t["goal"], context=_child_context,
386-                toolsets=None,  # always inherit the parent's toolsets
387:                model=creds["model"], max_iterations=max_iterations, task_count=len(task_list),
388-                parent_agent=parent_agent, role=_normalize_role(t.get("role") or top_role), **overrides,
389-            )
390-        except ValueError as exc:
391-            return [], str(exc)
392-        if _task_schema is not None:
393-            with _quiet("Could not attach output schema to child %d", i):
--
396-        # _flush contract and swallows writer failures).
397-        _writer = live_writers[i] if i < len(live_writers) else None
398-        if _writer is not None:
399-            child.tool_progress_callback = wrap_progress_callback(getattr(child, "tool_progress_callback", None), _writer)
400-            child._live_transcript_path = str(_writer.path)
401-        if live_deleg_id:
402:            setattr(child, "_delegation_id", live_deleg_id)
403-            _ident_ref = getattr(child, "_progress_identity_ref", None)
404-            if isinstance(_ident_ref, dict):
405:                _ident_ref["delegation_id"] = live_deleg_id
406-        children.append((i, t, child))
407-    return children, None
408-
409-
410-def delegate_task(
411-    goal: Optional[str] = None, context: Optional[str] = None, tasks: Optional[List[Dict[str, Any]]] = None,
412-    max_iterations: Optional[int] = None, role: Optional[str] = None, background: Optional[bool] = None,
413-    output_schema: Optional[Dict[str, Any]] = None, action: Optional[str] = None, subagent_id: Optional[str] = None,
414:    message: Optional[str] = None, parent_agent=None, credentials_cfg: Optional[Dict[str, Any]] = None,
415-) -> str:
416-    """Spawn child agents (single ``goal`` or ``tasks=[...]`` batch) or control running ones. ``action``
417-    list/steer/stop run synchronously and bypass the pause gate, depth limit and async dispatch. ``role`` is legacy
418-    (per-task beats top-level; capability is depth-derived). Returns JSON with one results entry per task, or a
419-    dispatch handle when running in the background."""
420-    if parent_agent is None:
--
423-    normalized_action = (action or "").strip().lower()
424-    if normalized_action in _CONTROL_ACTIONS:
425-        return _handle_control_action(normalized_action, subagent_id, message, parent_agent)
426-    if normalized_action and normalized_action != "spawn":
427-        return tool_error(f"Unknown action '{action}'. Use spawn (default), list, steer, or stop.")
428-
429:    # Operator kill switch (TUI / delegation.pause RPC): blocks NEW spawns only.
430-    if is_spawn_paused():
431-        return tool_error(
432-            "Delegation spawning is paused. Clear the pause via the TUI "
433:            "(`p` in /agents) or the `delegation.pause` RPC before retrying."
434-        )
435-
436-    top_role = _normalize_role(role)
437-    # background applies to single tasks AND batches: a batch is ONE async unit
438-    # that joins on every child and re-enters as a single consolidated message.
439-    background = is_truthy_value(background, default=False) if background is not None else False
440-
441-    depth = getattr(parent_agent, "_delegate_depth", 0)
442-    max_spawn = _get_max_spawn_depth()
443-    if depth >= max_spawn:
444-        return tool_error(
445-            f"Delegation depth limit reached (depth={depth}, max_spawn_depth={max_spawn}). Raise "
446:            f"delegation.max_spawn_depth in config.yaml if deeper nesting is required (no hard ceiling, but each level "
447-            f"multiplies API cost)."
448-        )
449-
450-    cfg = _load_config()
451-    default_max_iter = cfg.get("max_iterations", DEFAULT_MAX_ITERATIONS)
452-    # Caller-supplied max_iterations is ignored: the config value is authoritative
453-    # so budgets stay predictable (kwarg kept for internal callers/tests).
454-    if max_iterations is not None and max_iterations != default_max_iter:
455-        logger.debug(
456:            "delegate_task: ignoring caller-supplied max_iterations=%s; using delegation.max_iterations=%s from config",
457-            max_iterations, default_max_iter,
root@213-238-170-219:~#