MCPcopy Index your code
hub / github.com/IBM/AssetOpsBench / _final_answer

Function _final_answer

src/agent/opencode_agent/runner.py:406–420  ·  view source on GitHub ↗

Return text from the final assistant message only.

(
    text_by_part: OrderedDict[str, str], msg_by_part: dict[str, str]
)

Source from the content-addressed store, hash-verified

404
405
406def _final_answer(
407 text_by_part: OrderedDict[str, str], msg_by_part: dict[str, str]
408) -> str:
409 """Return text from the final assistant message only."""
410 if not text_by_part:
411 return ""
412 last_msg = None
413 for part_id in text_by_part:
414 last_msg = msg_by_part.get(part_id, part_id)
415 answer = "".join(
416 text
417 for part_id, text in text_by_part.items()
418 if msg_by_part.get(part_id, part_id) == last_msg
419 )
420 return _visible_text(answer)
421
422
423def _build_trajectory_from_events(

Callers 1

Calls 2

_visible_textFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected