Skip to content

Commit ff41447

Browse files
authored
Update runs.py
1 parent 66a5e00 commit ff41447

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎app/controllers/runs.py‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
from sqlalchemy.orm import Session
1515

1616
from ..models import Conversation, ConversationFile, Run
17+
from .access import get_owned
1718
from .conversations import files_of
18-
from .errors import Conflict, NotFound
19+
from .errors import Conflict
1920
from .manager import Controller
2021

2122
# Told to the agent, not to the user: the sandbox cwd is the only place
@@ -67,10 +68,14 @@ def start(
6768

6869
def of_conversation(db: Session, conversation: Conversation, run_id: str) -> Run:
6970
"""A run belonging to this conversation, or NotFound."""
70-
run = db.get(Run, run_id)
71-
if run is None or run.conversation_id != conversation.id:
72-
raise NotFound("run not found")
73-
return run
71+
return get_owned(
72+
db,
73+
Run,
74+
run_id,
75+
owner_field="conversation_id",
76+
owner_value=conversation.id,
77+
detail="run not found",
78+
)
7479

7580

7681
def cancel(controller: Controller, run_id: str) -> bool:

0 commit comments

Comments
 (0)