MCPcopy
hub / github.com/HKUDS/OpenHarness / _stream_command_result

Method _stream_command_result

ohmo/gateway/runtime.py:315–388  ·  view source on GitHub ↗
(
        self,
        *,
        bundle: RuntimeBundle,
        message: InboundMessage,
        session_key: str,
        user_prompt: str,
        result,
    )

Source from the content-addressed store, hash-verified

313 yield update
314
315 async def _stream_command_result(
316 self,
317 *,
318 bundle: RuntimeBundle,
319 message: InboundMessage,
320 session_key: str,
321 user_prompt: str,
322 result,
323 ):
324 if result.refresh_runtime:
325 bundle = await self._refresh_bundle(session_key, bundle, user_prompt)
326
327 if result.message:
328 yield GatewayStreamUpdate(
329 kind="final",
330 text=result.message,
331 metadata={"_session_key": session_key, "_command": True},
332 )
333
334 if result.submit_prompt is not None:
335 original_model = bundle.engine.model
336 if result.submit_model:
337 bundle.engine.set_model(result.submit_model)
338 try:
339 async for update in self._stream_engine_message(
340 bundle=bundle,
341 message=message,
342 session_key=session_key,
343 user_prompt=result.submit_prompt,
344 user_message=result.submit_prompt,
345 ):
346 yield update
347 finally:
348 if result.submit_model:
349 bundle.engine.set_model(original_model)
350 return
351
352 if result.continue_pending:
353 settings = bundle.current_settings()
354 if bundle.enforce_max_turns:
355 bundle.engine.set_max_turns(settings.max_turns)
356 bundle.engine.set_system_prompt(
357 self._runtime_system_prompt(bundle, _last_user_text(bundle.engine.messages))
358 )
359 turns = result.continue_turns if result.continue_turns is not None else bundle.engine.max_turns
360 reply_parts: list[str] = []
361 try:
362 async for event in bundle.engine.continue_pending(max_turns=turns):
363 async for update in self._convert_stream_event(
364 event=event,
365 bundle=bundle,
366 message=message,
367 session_key=session_key,
368 content=user_prompt,
369 reply_parts=reply_parts,
370 ):
371 yield update
372 except MaxTurnsExceeded as exc:

Callers 1

stream_messageMethod · 0.95

Calls 12

_refresh_bundleMethod · 0.95
_convert_stream_eventMethod · 0.95
_save_snapshotMethod · 0.95
_last_user_textFunction · 0.90
GatewayStreamUpdateClass · 0.85
current_settingsMethod · 0.80
set_modelMethod · 0.45
set_max_turnsMethod · 0.45
set_system_promptMethod · 0.45
continue_pendingMethod · 0.45

Tested by

no test coverage detected