← Về thư mục
openai4s/agent/delegation.py
- DelegationError · class · L73-L74 — class DelegationError(RuntimeError)
- DelegationConflictError · class · L77-L80 — class DelegationConflictError(DelegationError)
- DelegationBudget · class · L83-L328 — class DelegationBudget
- init · method · L92-L116 — def init( self, root_frame_id: str | None = None, *, limit: int | None = None, initial_usage: Mapping[str, Any] | None = None, store: Any | None = None, owner_instance_id: str | None = None, runner_instance_id: str | None = None, ) -> None
- reserve · method · L118-L153 — def reserve( self, count: int, *, depth: int, parent_child_id: str | None = None, ) -> list[str]
- reserve_request · method · L155-L228 — def reserve_request( self, *, depth: int, parent_child_id: str | None, parent_action_group_id: str, native_call_id: str, request_sha256: str, payload: Mapping[str, Any] | None = None, ) -> dict[str, Any]
- continue_request · method · L230-L256 — def continue_request( self, *, child_id: str, depth: int, parent_child_id: str | None, ) -> dict[str, Any]
- release · method · L258-L273 — def release(self, count: int = 1) -> None
- usage · method · L275-L290 — def usage(self) -> dict[str, Any]
- _set_spawned_for_compatibility · method · L292-L297 — def _set_spawned_for_compatibility(self, value: int) -> None
- bind_persistence · method · L299-L311 — def bind_persistence( self, *, store: Any, owner_instance_id: str, runner_instance_id: str, usage: Mapping[str, Any], ) -> None
- _durable · method · L314-L320 — def _durable(self) -> bool
- _sync_usage_locked · method · L322-L328 — def _sync_usage_locked(self, usage: Mapping[str, Any]) -> None
- _SteeringMessage · class · L331-L389 — class _SteeringMessage
- init · method · L341-L347 — def init(self, message_id: str, text: str, queued_at: float) -> None
- deliver · method · L349-L352 — def deliver(self, boundary: int, delivered_at: float) -> None
- discard · method · L354-L356 — def discard(self) -> None
- restore · method · L359-L377 — def restore(cls, value: Mapping[str, Any]) -> _SteeringMessage
- snapshot · method · L379-L386 — def snapshot(self) -> dict[str, Any]
- persistence_snapshot · method · L388-L389 — def persistence_snapshot(self) -> dict[str, Any]
- _RetryChain · class · L392-L410 — class _RetryChain
- init · method · L399-L402 — def init(self, chain_id: str) -> None
- cancel · method · L404-L407 — def cancel(self, reason: str) -> None
- cancelled · method · L409-L410 — def cancelled(self) -> bool
- _Child · class · L413-L753 — class _Child
- init · method · L416-L461 — def init( self, child_id: str, name: str | None, spec: dict[str, Any], *, depth: int, parent_child_id: str | None, parent_frame_id: str | None, store: Any | None, budget: DelegationBudget, clock: Callable[[], float], retry_chain: _RetryChain | None = None, ) -> None
- begin · method · L463-L471 — def begin(self, max_turns: int) -> bool
- attach_agent · method · L473-L478 — def attach_agent(self, agent: Any) -> bool
- detach_agent · method · L480-L483 — def detach_agent(self, agent: Any) -> None
- set_frame · method · L485-L487 — def set_frame(self, frame_id: str) -> None
- set_future · method · L489-L494 — def set_future(self, future: Future) -> None
- request_stop · method · L496-L507 — def request_stop(self, reason: str) -> tuple[bool, Any | None, Future | None]
- stop_event_reason · method · L509-L511 — def stop_event_reason(self) -> str
- finish_done · method · L513-L525 — def finish_done(self, result: dict[str, Any]) -> bool
- finish_failed · method · L527-L539 — def finish_failed(self, error: str, result: dict[str, Any]) -> bool
- stopped_result · method · L541-L544 — def stopped_result(self) -> dict[str, Any]
- enqueue · method · L546-L552 — def enqueue(self, message: _SteeringMessage) -> tuple[bool, int]
- consume_steering · method · L554-L561 — def consume_steering(self, boundary: int) -> list[_SteeringMessage]
- mark_boundary · method · L563-L566 — def mark_boundary(self, boundary: int) -> None
- snapshot · method · L568-L605 — def snapshot(self) -> dict[str, Any]
- persistence_snapshot · method · L607-L638 — def persistence_snapshot(self) -> dict[str, Any]
- from_persisted · method · L641-L714 — def from_persisted( cls, value: Mapping[str, Any], *, store: Any | None, budget: DelegationBudget, clock: Callable[[], float], ) -> _Child
- _mark_stopped_locked · method · L716-L742 — def _mark_stopped_locked(self, reason: str) -> None
- _discard_queued_locked · method · L744-L747 — def _discard_queued_locked(self) -> None
- _release_budget_locked · method · L749-L753 — def _release_budget_locked(self) -> None
- _ChildStepForwarder · class · L771-L884 — class _ChildStepForwarder
- init · method · L783-L803 — def init( self, sink: Callable[[dict[str, Any]], None], *, child_id: str, frame_id: str | None, name: str | None, depth: int, ) -> None
- call · method · L805-L809 — def call(self, event: dict[str, Any]) -> None
- _decorated · method · L811-L817 — def _decorated(self, event: dict[str, Any]) -> dict[str, Any]
- _emit_begin_locked · method · L819-L825 — def _emit_begin_locked(self, event: dict[str, Any]) -> bool
- _relay · method · L827-L849 — def _relay(self, event: dict[str, Any]) -> None
- flush · method · L851-L884 — def flush(self) -> None
- _DelegationTree · class · L887-L1086 — class _DelegationTree
- init · method · L890-L920 — def init( self, *, budget: DelegationBudget | None = None, event_sink: Callable[[dict[str, Any]], None] | None = None, child_step_sink: Callable[[dict[str, Any]], None] | None = None, persistence_sink: Callable[[_Child], None] | None = None, trusted_capture_admission: Callable[[], str | None] | None = None, trusted_capture_lease: Callable[[], Any] | None = None, clock: Callable[[], float] = time.time, ) -> None
- allocate · method · L922-L940 — def allocate( self, *, parent_child_id: str | None, depth: int, count: int ) -> list[str]
- register · method · L942-L945 — def register(self, child: _Child) -> None
- create_retry · method · L947-L986 — def create_retry( self, previous: _Child, *, spec: dict[str, Any], depth: int, parent_child_id: str | None, parent_frame_id: str | None, store: Any | None, direct_children: dict[str, _Child], ) -> _Child | None
- cancel_retry_subtrees · method · L988-L1026 — def cancel_retry_subtrees( self, child_ids: Sequence[str], reason: str ) -> list[tuple[_Child, bool, Any | None, Future | None]]
- restore · method · L1028-L1037 — def restore(self, children: Sequence[_Child]) -> None
- next_message_id · method · L1039-L1042 — def next_message_id(self) -> str
- descendants · method · L1044-L1058 — def descendants(self, child_id: str, *, include_self: bool = True) -> list[_Child]
- subtree · method · L1060-L1064 — def subtree(self, parent_child_id: str | None) -> list[_Child]
- emit · method · L1066-L1086 — def emit(self, event: str, child: _Child, **extra: Any) -> None
- _ChildCancellation · class · L1094-L1099 — class _ChildCancellation
- init · method · L1095-L1096 — def init(self, child: _Child) -> None
- cancelled · method · L1098-L1099 — def cancelled(self) -> bool
- _child_context_budget · function · L1102-L1127 — def _child_context_budget(cfg: Config)
- _budget · function · L1110-L1125 — def _budget(_state: Any) -> int | None
- _SteeringContextPolicy · class · L1130-L1183 — class _SteeringContextPolicy
- init · method · L1133-L1147 — def init(self, cfg: Config, child: _Child, tree: _DelegationTree) -> None: # The child's OWN model decides when the child compacts. This was a # bare
CompactionPolicy(cfg), which falls back to # cfg.context_window_tokens -- the daemon default, 262,144 -- while # the Web session path has always derived the budget from the model's # declared capability. A child may run a different model than its # parent (overrides["model"]), which is exactly when the two numbers # diverge: a child on a model whose usable window is 136,000 tokens # would compact against 262,144 and sail past its real limit, learning # about it as a provider rejection rather than as a compaction.
- bind_runtime · method · L1149-L1160 — def bind_runtime(self, **providers: Any) -> None
- prepare · method · L1162-L1183 — def prepare(self, state: Any) -> Sequence[Mapping[str, Any]]
- DelegationRunner · class · L1186-L2242 — class DelegationRunner
- init · method · L1189-L1344 — def init( self, cfg: Config, child_max_turns: int | None = None, depth: int = 0, parent_frame_id: str | None = None, store: Any | None = None, *, event_sink: Callable[[dict[str, Any]], None] | None = None, child_step_sink: Callable[[dict[str, Any]], None] | None = None, budget: DelegationBudget | None = None, delegation_tree: _DelegationTree | None = None, parent_child_id: str | None = None, owner_instance_id: str | None = None, runner_instance_id: str | None = None, workspace: str | Path | None = None, read_isolation: KernelReadIsolation | None = None, cell_hooks_factory: Callable[[str], object] | None = None, trusted_capture_admission: Callable[[], str | None] | None = None, trusted_capture_lease: Callable[[], Any] | None = None, env: KernelEnvSpec | None = None, private_scratch: bool | None = None, cancelled: Callable[[], bool] | None = None, ) -> None
- persist · function · L1296-L1305 — def persist(child: _Child) -> None
- _spawned · method · L1347-L1350 — def _spawned(self) -> int
- _spawned · method · L1353-L1354 — def _spawned(self, value: int) -> None
- _reserve · method · L1356-L1361 — def _reserve(self, n: int) -> list[str]
- _child_from_reservation · method · L1363-L1399 — def _child_from_reservation( self, reservation: Mapping[str, Any], spec: dict[str, Any] ) -> tuple[_Child, bool]
- _restore_one_child · method · L1401-L1418 — def _restore_one_child(self, child_id: str) -> _Child | None
- _reuse_child · method · L1420-L1431 — def _reuse_child(self, child: _Child, *, wait: bool, is_list: bool) -> Any
- _enrich_result · method · L1434-L1444 — def _enrich_result( result: Mapping[str, Any] | None, child: _Child ) -> dict[str, Any]
- _run_one · method · L1446-L1661 — def _run_one(self, child: _Child) -> dict[str, Any]
- _child_environment · method · L1663-L1698 — def _child_environment(self, child_frame_id: str | None) -> dict[str, Any]
- _child_artifacts · method · L1700-L1712 — def _child_artifacts(self, child_frame_id: str | None) -> list[str]
- _publish_scratch · method · L1714-L1729 — def _publish_scratch( self, child: _Child, scratch: Any, child_frame_id: str | None, ) -> list[dict[str, Any]]
- _run_with_retries · method · L1731-L1769 — def _run_with_retries(self, child: _Child) -> dict[str, Any]
- call · method · L1771-L1843 — def call(self, spec: dict[str, Any]) -> Any
- _call_admitted · method · L1845-L1965 — def _call_admitted( self, spec: dict[str, Any], items: list[Any], *, is_list: bool, wait: bool, ) -> Any
- children · method · L1967-L1970 — def children(self) -> list[dict[str, Any]]
- set_event_sink · method · L1972-L1975 — def set_event_sink(self, sink: Callable[[dict[str, Any]], None] | None) -> None
- set_child_step_sink · method · L1977-L1982 — def set_child_step_sink( self, sink: Callable[[dict[str, Any]], None] | None ) -> None
- set_trusted_capture_admission · method · L1984-L1989 — def set_trusted_capture_admission( self, admission: Callable[[], str | None] | None ) -> None
- set_trusted_capture_lease · method · L1991-L1994 — def set_trusted_capture_lease(self, lease: Callable[[], Any] | None) -> None
- collect · method · L1996-L2067 — def collect(self, spec: dict[str, Any]) -> list[dict[str, Any]]
- continue_child · method · L2069-L2094 — def continue_child(self, child_id: str, *, wait: bool = True) -> dict[str, Any]
- materialize_child · method · L2096-L2127 — def materialize_child( self, child_id: str, *, paths: Sequence[str] | None = None, ) -> dict[str, Any]
- stop_child · method · L2129-L2133 — def stop_child(self, child_id: str) -> dict[str, Any]
- _stop_subtree · method · L2135-L2141 — def _stop_subtree(self, child_id: str, reason: str) -> dict[str, Any]
- _signal_stopped · method · L2143-L2165 — def _signal_stopped( self, stopped: Sequence[tuple[_Child, bool, Any | None, Future | None]], *, direct_ids: set[str], ) -> None
- send_message · method · L2167-L2196 — def send_message(self, spec: dict[str, Any]) -> dict[str, Any]
- delegation_stats · method · L2198-L2218 — def delegation_stats(self) -> dict[str, Any]
- cancel_all · method · L2220-L2227 — def cancel_all(self, reason: str = "parent cancelled") -> list[str]
- close · method · L2229-L2232 — def close(self, *, cancel: bool = False) -> None
- _persist_status · method · L2234-L2242 — def _persist_status(self, child: _Child, status: str) -> None
- _derive_task_status · function · L2245-L2276 — def _derive_task_status( stop_reason: Any, submitted: Mapping[str, Any], final_message: Any, missing_artifacts: list[str] | None, ) -> str
- _completion_limitations · function · L2279-L2291 — def _completion_limitations(output: Any) -> list[str]
- _validated_require_artifacts · function · L2294-L2317 — def _validated_require_artifacts(spec: Mapping[str, Any]) -> list[str] | None
- _missing_required_artifacts · function · L2320-L2334 — def _missing_required_artifacts( patterns: list[str] | None, produced: list[str] ) -> list[str] | None
- _retry_budget · function · L2337-L2348 — def _retry_budget(spec: Mapping[str, Any]) -> int
- _retry_spec · function · L2351-L2390 — def _retry_spec( spec: Mapping[str, Any], previous: Mapping[str, Any], attempt: int ) -> dict[str, Any]
- _normalize_item · function · L2393-L2443 — def _normalize_item(item: Any, parent_spec: dict[str, Any]) -> dict[str, Any]
- _spec_to_task · function · L2446-L2462 — def _spec_to_task(spec: dict[str, Any]) -> str
- _apply_parent_execution_ceiling · function · L2465-L2523 — def _apply_parent_execution_ceiling( spec: Mapping[str, Any], parent_spec: Mapping[str, Any] ) -> dict[str, Any]
- _apply_trusted_capture_ceiling · function · L2526-L2536 — def _apply_trusted_capture_ceiling(spec: Mapping[str, Any]) -> dict[str, Any]
- _child_config · function · L2539-L2561 — def _child_config(cfg: Config, spec: Mapping[str, Any]) -> Config
- _child_turn_budget · function · L2564-L2583 — def _child_turn_budget( spec: Mapping[str, Any], configured: int | None, default: int ) -> int
- _public_overrides · function · L2586-L2619 — def _public_overrides(spec: Mapping[str, Any]) -> dict[str, Any]