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

Function _merge_text

src/agent/opencode_agent/runner.py:383–395  ·  view source on GitHub ↗

Combine repeated emissions for one text part id. OpenCode streams can look like snapshots (new value contains the previous value) or deltas (new value is only the next chunk). Handle both shapes.

(existing: str, new: str)

Source from the content-addressed store, hash-verified

381
382
383def _merge_text(existing: str, new: str) -> str:
384 """Combine repeated emissions for one text part id.
385
386 OpenCode streams can look like snapshots (new value contains the previous
387 value) or deltas (new value is only the next chunk). Handle both shapes.
388 """
389 if not existing:
390 return new
391 if new.startswith(existing):
392 return new
393 if existing.startswith(new):
394 return existing
395 return existing + new
396
397
398def _is_step_finish(event: dict[str, Any], part: dict[str, Any], part_type: str) -> bool:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected