mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-25 12:01:04 +02:00
fix: move draft and template context handling out of create_workflow_run (#560)
* fix: move draft and template context handling out of create_workflow_run create_workflow_run now only creates the run with the definition_id and initial_context provided by the caller. Test call paths explicitly resolve draft definitions and merge template context variables before creating the run, while production/runtime paths bind the published definition without adding template defaults. * fix: review comments * chore: format and minor cleanups --------- Co-authored-by: Abhishek Kumar <abhishek@a6k.me>
This commit is contained in:
parent
94dce42209
commit
90c5831984
19 changed files with 657 additions and 72 deletions
|
|
@ -198,6 +198,11 @@ async def test_text_chat_session_creation_executes_initial_assistant_turn(
|
|||
workflow_definition=workflow_definition,
|
||||
suffix="bootstrap",
|
||||
)
|
||||
draft = await db_session.save_workflow_draft(
|
||||
workflow_id=workflow.id,
|
||||
workflow_definition=workflow_definition,
|
||||
template_context_variables={"name": "draft", "draft_only": "kept"},
|
||||
)
|
||||
|
||||
llm = MockLLMService(
|
||||
mock_steps=[
|
||||
|
|
@ -219,7 +224,7 @@ async def test_text_chat_session_creation_executes_initial_assistant_turn(
|
|||
):
|
||||
create_response = await client.post(
|
||||
f"/api/v1/workflow/{workflow.id}/text-chat/sessions",
|
||||
json={},
|
||||
json={"initial_context": {"name": "explicit"}},
|
||||
)
|
||||
assert create_response.status_code == 200
|
||||
created = create_response.json()
|
||||
|
|
@ -242,6 +247,11 @@ async def test_text_chat_session_creation_executes_initial_assistant_turn(
|
|||
assert "Start" in (created["gathered_context"] or {}).get("nodes_visited", [])
|
||||
workflow_run = await db_session.get_workflow_run_by_id(created["workflow_run_id"])
|
||||
assert workflow_run is not None
|
||||
assert workflow_run.definition_id == draft.id
|
||||
assert workflow_run.initial_context == {
|
||||
"name": "explicit",
|
||||
"draft_only": "kept",
|
||||
}
|
||||
assert "call_duration_seconds" in workflow_run.usage_info
|
||||
assert _log_texts(run_payload["logs"], "rtf-bot-text") == [
|
||||
"Hello from the workflow tester."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue