|
24 | 24 | worker group as each group's workers become spawn-safe. |
25 | 25 |
|
26 | 26 | Design: idea-5 ``design.md`` in the combine-agentspan analysis workspace. |
27 | | -""" |
28 | 27 |
|
29 | | -from __future__ import annotations |
| 28 | +NOTE: deliberately NO ``from __future__ import annotations`` here — the task |
| 29 | +runners read parameter types from ``inspect.signature(execute_function)`` |
| 30 | +(the class ``__call__``'s annotations for entry instances) and pass them to |
| 31 | +``isinstance``-based input conversion; string annotations would break that |
| 32 | +(``TypeError: isinstance() arg 2 must be a type``). |
| 33 | +""" |
30 | 34 |
|
31 | 35 | import importlib |
32 | 36 | import inspect |
@@ -173,9 +177,9 @@ def __init__(self, tool_name, fn_ref=None, fn_direct=None, guardrails=None, |
173 | 177 | def for_callable(cls, fn, tool_name, guardrails=None, credential_names=None): |
174 | 178 | """Build an entry for *fn*, preferring by-reference transport. |
175 | 179 |
|
176 | | - Falls back to direct transport for callable instances (picklable by |
177 | | - value) and for closures — the latter only work under ``fork``; the |
178 | | - registration probe polices that under ``spawn``. |
| 180 | + Falls back to direct transport for picklable callables (instances, |
| 181 | + bound methods of picklable objects); unpicklable closures are caught |
| 182 | + by the registration probe with an actionable error. |
179 | 183 | """ |
180 | 184 | framework = bool(getattr(fn, "_agentspan_framework_callable", False)) |
181 | 185 | try: |
@@ -218,8 +222,9 @@ def __call__(self, task): |
218 | 222 | def wrap_callable(fn): |
219 | 223 | """Best transport for a user callable: FunctionRef when resolvable, raw otherwise. |
220 | 224 |
|
221 | | - Raw transport only survives ``fork`` (or picklable instances); the |
222 | | - registration probe polices that under ``spawn``. |
| 225 | + Raw transport works for picklable callables (instances with plain-data |
| 226 | + attrs, bound methods of picklable objects); anything else is caught by the |
| 227 | + registration probe with an actionable error. |
223 | 228 | """ |
224 | 229 | if fn is None: |
225 | 230 | return None |
@@ -354,7 +359,8 @@ class StopWhenEntry: |
354 | 359 | def __init__(self, stop_when_fn): |
355 | 360 | self.fn_t = wrap_callable(stop_when_fn) |
356 | 361 |
|
357 | | - async def __call__(self, result="", iteration: int = 0, messages=None) -> object: |
| 362 | + async def __call__(self, result: object = "", iteration: int = 0, |
| 363 | + messages: object = None) -> object: |
358 | 364 | from conductor.ai.agents.runtime.runtime import _call_user_fn, _resolve_loop_iteration |
359 | 365 |
|
360 | 366 | iteration = _resolve_loop_iteration(iteration) |
|
0 commit comments