MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / _extract_current_message

Function _extract_current_message

uncommon_route/proxy.py:404–425  ·  view source on GitHub ↗

Extract the actual user message from bracket-marker history context. Frameworks like OpenClaw wrap conversation history and the current message into a single user content string: [Chat messages since your last reply - for context] User: previous message Assistant: p

(text: str)

Source from the content-addressed store, hash-verified

402
403
404def _extract_current_message(text: str) -> str | None:
405 """Extract the actual user message from bracket-marker history context.
406
407 Frameworks like OpenClaw wrap conversation history and the current message
408 into a single user content string:
409
410 [Chat messages since your last reply - for context]
411 User: previous message
412 Assistant: previous reply
413
414 [Current message - respond to this]
415 User: hi
416
417 This function returns the text after the current-message marker, stripped
418 of any sender prefix like "User: ". Returns None if no marker is found.
419 """
420 match = _CURRENT_MSG_MARKER_RE.search(text)
421 if not match:
422 return None
423 after = text[match.end():].strip()
424 after = _SENDER_PREFIX_RE.sub("", after).strip()
425 return after if after else None
426
427
428def _extract_user_prompt_text(value: Any) -> str:

Calls

no outgoing calls