Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/app/gateway/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ async def start_run(

disconnect = DisconnectMode.cancel if body.on_disconnect == "cancel" else DisconnectMode.continue_

body_context = getattr(body, "context", None) or {}
model_name = body_context.get("model_name")

Comment on lines +253 to +255
try:
record = await run_mgr.create_or_reject(
thread_id,
Expand All @@ -257,6 +260,7 @@ async def start_run(
metadata=body.metadata or {},
kwargs={"input": body.input, "config": body.config},
multitask_strategy=body.multitask_strategy,
model_name=model_name,
)
except ConflictError as exc:
raise HTTPException(status_code=409, detail=str(exc)) from exc
Expand Down
2 changes: 2 additions & 0 deletions backend/packages/harness/deerflow/persistence/run/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ async def put(
thread_id,
assistant_id=None,
user_id: str | None | _AutoSentinel = AUTO,
model_name: str | None = None,
status="pending",
multitask_strategy="reject",
metadata=None,
Expand All @@ -85,6 +86,7 @@ async def put(
thread_id=thread_id,
assistant_id=assistant_id,
user_id=resolved_user_id,
model_name=model_name,
status=status,
Comment on lines 96 to 102
multitask_strategy=multitask_strategy,
metadata_json=self._safe_json(metadata) or {},
Expand Down
4 changes: 4 additions & 0 deletions backend/packages/harness/deerflow/runtime/runs/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class RunRecord:
abort_event: asyncio.Event = field(default_factory=asyncio.Event, repr=False)
abort_action: str = "interrupt"
error: str | None = None
model_name: str | None = None


class RunManager:
Expand Down Expand Up @@ -65,6 +66,7 @@ async def _persist_to_store(self, record: RunRecord) -> None:
metadata=record.metadata or {},
kwargs=record.kwargs or {},
created_at=record.created_at,
model_name=record.model_name,
)
except Exception:
logger.warning("Failed to persist run %s to store", record.run_id, exc_info=True)
Expand Down Expand Up @@ -171,6 +173,7 @@ async def create_or_reject(
metadata: dict | None = None,
kwargs: dict | None = None,
multitask_strategy: str = "reject",
model_name: str | None = None,
) -> RunRecord:
Comment on lines 171 to 177
"""Atomically check for inflight runs and create a new one.

Expand Down Expand Up @@ -221,6 +224,7 @@ async def create_or_reject(
kwargs=kwargs or {},
created_at=now,
updated_at=now,
model_name=model_name,
)
self._runs[run_id] = record

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async def put(
thread_id: str,
assistant_id: str | None = None,
user_id: str | None = None,
model_name: str | None = None,
status: str = "pending",
multitask_strategy: str = "reject",
metadata: dict[str, Any] | None = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async def put(
thread_id,
assistant_id=None,
user_id=None,
model_name=None,
status="pending",
multitask_strategy="reject",
metadata=None,
Expand All @@ -35,6 +36,7 @@ async def put(
"thread_id": thread_id,
"assistant_id": assistant_id,
"user_id": user_id,
"model_name": model_name,
"status": status,
"multitask_strategy": multitask_strategy,
"metadata": metadata or {},
Expand Down
Loading