What I could imagine for this situation is a custom metadata that you could set to whatever value you want using the Set Suite Metadata keyword.
Then you can create a small ResultVisitor to retrieve the needed metadata. I am using Robot Framework 3.1.2 for the example below.
Example (SO.robot):
*** Test Cases ***
Test
Set Suite Metadata My Return Value My VALUE append=True top=True
The Python file calling Robot CLI and the ResultVisitor:
from robot import run_cli
from robot.api import ExecutionResult, ResultVisitor
class ReturnValueFetcher(ResultVisitor):
def __init__(self):
self.custom_rc = None
def visit_suite(self, suite):
try:
self.custom_rc = suite.metadata["My Return Value"]
except KeyError:
self.custom_rc = 'Undefined' # error, False, exception, log error, etc.
# Only visit the top suite
return False
# Run robot, exit=False is needed so the script won't be terminated here
rc = run_cli(['SO.robot'], exit=False)
# Instantiate result visitor
retval = ReturnValueFetcher()
# Parse execution result using robot API
# assuming the output.xml is in the same folder as the Python script
result = ExecutionResult("./output.xml")
# Visit the top level suite to retrive needed metadata
result.visit(retval)
# Print return values
print(f"normal rc:{rc} - custom_rc:{retval.custom_rc}")
Your custom return value will be clearly visible in your log.html and report.html files as well.

This is the console output:
