mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 03:30:48 +08:00
fix(scheduler): inherit creator specialist when creating scheduled jobs
Pass the active workspace lane into tool execution and default schedule_create to that specialist so WhatsApp ops-bound jobs are stored and run as ops instead of generalist. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
62ac04c40d
commit
146d83c336
4 changed files with 89 additions and 3 deletions
|
|
@ -1309,7 +1309,7 @@ def process_inbound_payload(payload: dict[str, Any]) -> dict[str, Any]:
|
|||
store,
|
||||
tenant_id=tenant_id,
|
||||
user_id=user_id,
|
||||
specialist="generalist",
|
||||
specialist=selected_specialist,
|
||||
session_id=str(session_id),
|
||||
lang=lang,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -467,6 +467,33 @@ def truncate_tool_result_for_llm_messages(result: dict[str, Any], *, max_chars:
|
|||
}
|
||||
|
||||
|
||||
_INTERNAL_TOOL_SPECIALISTS = frozenset({"", "oclaw"})
|
||||
|
||||
|
||||
def _resolve_creator_specialist(ctx: ToolExecutionContext) -> str:
|
||||
"""Specialist actively running this turn (for schedule_create inheritance)."""
|
||||
from runtime.types import normalize_requested_specialist
|
||||
|
||||
md = ctx.inbound_metadata if isinstance(ctx.inbound_metadata, dict) else {}
|
||||
for raw in (
|
||||
str(ctx.workspace_lane_role or "").strip(),
|
||||
str(ctx.specialist or "").strip(),
|
||||
str(md.get("selected_specialist") or "").strip(),
|
||||
str(md.get("manager_selected_specialist") or "").strip(),
|
||||
):
|
||||
if not raw or raw.lower() in _INTERNAL_TOOL_SPECIALISTS:
|
||||
continue
|
||||
return normalize_requested_specialist(raw)
|
||||
for raw in (
|
||||
str(ctx.workspace_lane_role or "").strip(),
|
||||
str(md.get("selected_specialist") or "").strip(),
|
||||
str(md.get("manager_selected_specialist") or "").strip(),
|
||||
):
|
||||
if raw:
|
||||
return normalize_requested_specialist(raw)
|
||||
return "generalist"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ToolExecutionConfig:
|
||||
max_workers: int = 8
|
||||
|
|
@ -543,7 +570,7 @@ class ToolExecutor:
|
|||
or ""
|
||||
).strip()
|
||||
if tname == "schedule_create":
|
||||
cur_spec = str(ctx.specialist or "").strip().lower()
|
||||
cur_spec = _resolve_creator_specialist(ctx)
|
||||
if cur_spec and not str(tool_args.get("specialist") or "").strip() and not str(
|
||||
tool_args.get("selected_specialist") or ""
|
||||
).strip():
|
||||
|
|
|
|||
|
|
@ -1144,6 +1144,7 @@ def _execute_tool_step(
|
|||
inbound_metadata: dict[str, Any] | None = None,
|
||||
) -> tuple[int, dict[str, tuple[dict[str, Any], int]]]:
|
||||
t0 = time.perf_counter()
|
||||
lane = str(workspace_lane_role or "").strip().lower()
|
||||
_tool_messages, results_by_id = skill_exec.execute_skill_uses(
|
||||
ctx=SkillExecutionContext(
|
||||
store=store,
|
||||
|
|
@ -1152,7 +1153,7 @@ def _execute_tool_step(
|
|||
lang=lang,
|
||||
user_text=user_text,
|
||||
inbound_metadata=inbound_metadata,
|
||||
specialist="oclaw",
|
||||
specialist=lane or "oclaw",
|
||||
trace_id=trace_id,
|
||||
parent_span_id=parent_span_id,
|
||||
workspace_dir=workspace_dir,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue