Skip to content

[NET-1341] update: Use new split version of initialse multi turn runs and user message generation#334

Open
muhammedrazalak wants to merge 3 commits into
developfrom
update/simulation-flow
Open

[NET-1341] update: Use new split version of initialse multi turn runs and user message generation#334
muhammedrazalak wants to merge 3 commits into
developfrom
update/simulation-flow

Conversation

@muhammedrazalak

@muhammedrazalak muhammedrazalak commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Split multi-turn run creation into separate initialization and first-turn generation APIs.
  • Removed the legacy initialization fallback.
  • Run per-item setup and first-turn generation concurrently.
  • Ensure after hooks execute for setup failures and after_all receives complete results.
  • Updated simulation tests for the new API flow.

Testing

  • Updated unit tests for run initialization and first-turn generation.
  • Verified simulation success and failure flows.

Comment thread netra/simulation/api.py
Comment thread netra/simulation/api.py
Comment thread netra/simulation/api.py
Comment thread netra/simulation/api.py
item_context = await run_before(hooks, dataset_item_id, shared_context)
setup_contexts[run_item_id] = item_context
except Exception as exc:
error_msg = f"before hook failed: {exc}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay to skip run_after_all() if run_before() fails for all items?

Comment thread netra/simulation/api.py
return sim_item

async def _run_all_before_and_first_turns() -> list[Optional[SimulationItem]]:
return list(await asyncio.gather(*[run_before_and_generate_first_turn(item) for item in items]))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self._client.generate_first_turn(...) is a synchronous, blocking httpx call invoked directly in the coroutine. It blocks the event loop, so the asyncio.gather yields no concurrency for them. Try switching to the ThreadPool Executor as we did for the conversation loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants