fix: isolate rein results and normalize manager startup failures
Some checks failed
ci / validate (push) Has been cancelled
Some checks failed
ci / validate (push) Has been cancelled
Assistant: codex Assistant-Model: gpt-6-astra Assistant-Session: 01a0726e-5232-73f2-aaca-2c05ceb62efb
This commit is contained in:
parent
73cee37ad8
commit
53f2abf7e0
8 changed files with 152 additions and 32 deletions
|
|
@ -108,11 +108,11 @@ def run_execution(
|
|||
_report(request, result)
|
||||
return result
|
||||
|
||||
manager = manager or SandboxManager()
|
||||
status = None
|
||||
session = None
|
||||
try:
|
||||
try:
|
||||
manager = manager if manager is not None else SandboxManager()
|
||||
status = manager.create(
|
||||
SandboxCreateRequest(
|
||||
profile=profile.sandbox_profile,
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ class ReinAharness(Rein):
|
|||
self.model = model
|
||||
self.tool_profile = tool_profile
|
||||
self.budget_tokens = budget_tokens
|
||||
self._last_result: dict[str, Any] = {}
|
||||
|
||||
def _bin(self, transport: ExecutionTransport) -> str:
|
||||
try:
|
||||
|
|
@ -109,18 +108,18 @@ class ReinAharness(Rein):
|
|||
proc = transport.run(argv, timeout=session["timeout_seconds"])
|
||||
ok = proc.returncode == 0
|
||||
output, events = self._split_stream_events(proc.stdout)
|
||||
self._last_result = parse_json_object(output)
|
||||
last_result = session["last_result"] = parse_json_object(output)
|
||||
return ToolResult(
|
||||
ok=ok,
|
||||
output=output,
|
||||
error=None if ok else (proc.stderr or self._last_result.get("reason")),
|
||||
error=None if ok else (proc.stderr or last_result.get("reason")),
|
||||
events=events,
|
||||
events_completeness="complete" if self.stream_tool_events else "unavailable",
|
||||
tokens_spent=self._last_result.get("tokens_spent"),
|
||||
duration_s=self._last_result.get("execution_time_s"),
|
||||
resolved_model=self._last_result.get("model") or self.model,
|
||||
tokens_spent=last_result.get("tokens_spent"),
|
||||
duration_s=last_result.get("execution_time_s"),
|
||||
resolved_model=last_result.get("model") or self.model,
|
||||
metadata={
|
||||
"tool_profile": self._last_result.get("tool_profile") or self.tool_profile,
|
||||
"tool_profile": last_result.get("tool_profile") or self.tool_profile,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
@ -147,10 +146,11 @@ class ReinAharness(Rein):
|
|||
|
||||
def end_session(self, session: dict[str, Any]) -> ExecutionSummary:
|
||||
transport: ExecutionTransport = session["transport"]
|
||||
last_result = session.get("last_result", {})
|
||||
head_after = transport.git_head()
|
||||
committed = bool(head_after) and head_after != session.get("head_before")
|
||||
reported_ok = bool(self._last_result.get("ok", committed))
|
||||
reason = self._last_result.get("reason") or None
|
||||
reported_ok = bool(last_result.get("ok", committed))
|
||||
reason = last_result.get("reason") or None
|
||||
outcome = "succeeded" if committed and reported_ok else (
|
||||
"refused" if isinstance(reason, str) and reason.startswith("refused:") else "failed"
|
||||
)
|
||||
|
|
@ -159,13 +159,13 @@ class ReinAharness(Rein):
|
|||
committed=committed,
|
||||
outcome=outcome,
|
||||
reason=reason,
|
||||
tokens_spent=self._last_result.get("tokens_spent"),
|
||||
duration_s=self._last_result.get("execution_time_s"),
|
||||
resolved_model=self._last_result.get("model") or self.model,
|
||||
tokens_spent=last_result.get("tokens_spent"),
|
||||
duration_s=last_result.get("execution_time_s"),
|
||||
resolved_model=last_result.get("model") or self.model,
|
||||
artifacts=[head_after] if committed and head_after else [],
|
||||
metadata={
|
||||
"tool_profile": self._last_result.get("tool_profile") or self.tool_profile,
|
||||
"persona_source": self._last_result.get("persona_source"),
|
||||
"tool_profile": last_result.get("tool_profile") or self.tool_profile,
|
||||
"persona_source": last_result.get("persona_source"),
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ class ReinOpenWeights(Rein):
|
|||
self.max_turns = max_turns
|
||||
self.budget_tokens = budget_tokens
|
||||
self.tool_profile = tool_profile
|
||||
self._last_result: dict[str, Any] = {}
|
||||
|
||||
def _bin(self, transport: ExecutionTransport) -> str:
|
||||
try:
|
||||
|
|
@ -94,27 +93,28 @@ class ReinOpenWeights(Rein):
|
|||
argv += ["--tool-profile", self.tool_profile]
|
||||
proc = transport.run(argv, timeout=session["timeout_seconds"])
|
||||
ok = proc.returncode == 0
|
||||
self._last_result = parse_json_object(proc.stdout)
|
||||
last_result = session["last_result"] = parse_json_object(proc.stdout)
|
||||
return ToolResult(
|
||||
ok=ok,
|
||||
output=proc.stdout,
|
||||
error=None if ok else (proc.stderr or self._last_result.get("reason")),
|
||||
error=None if ok else (proc.stderr or last_result.get("reason")),
|
||||
events_completeness="unavailable",
|
||||
tokens_spent=self._last_result.get("tokens_spent"),
|
||||
duration_s=self._last_result.get("execution_time_s"),
|
||||
resolved_model=self._last_result.get("model") or self.model,
|
||||
tokens_spent=last_result.get("tokens_spent"),
|
||||
duration_s=last_result.get("execution_time_s"),
|
||||
resolved_model=last_result.get("model") or self.model,
|
||||
metadata={
|
||||
"turns": self._last_result.get("turns"),
|
||||
"tool_profile": self._last_result.get("tool_profile") or self.tool_profile,
|
||||
"turns": last_result.get("turns"),
|
||||
"tool_profile": last_result.get("tool_profile") or self.tool_profile,
|
||||
},
|
||||
)
|
||||
|
||||
def end_session(self, session: dict[str, Any]) -> ExecutionSummary:
|
||||
transport: ExecutionTransport = session["transport"]
|
||||
last_result = session.get("last_result", {})
|
||||
head_after = transport.git_head()
|
||||
committed = bool(head_after) and head_after != session.get("head_before")
|
||||
reported_ok = bool(self._last_result.get("ok", committed))
|
||||
reason = self._last_result.get("reason") or None
|
||||
reported_ok = bool(last_result.get("ok", committed))
|
||||
reason = last_result.get("reason") or None
|
||||
outcome = "succeeded" if committed and reported_ok else (
|
||||
"refused" if reason == "no OpenRouter credential resolved" else "failed"
|
||||
)
|
||||
|
|
@ -123,13 +123,13 @@ class ReinOpenWeights(Rein):
|
|||
committed=committed,
|
||||
outcome=outcome,
|
||||
reason=reason,
|
||||
tokens_spent=self._last_result.get("tokens_spent"),
|
||||
duration_s=self._last_result.get("execution_time_s"),
|
||||
resolved_model=self._last_result.get("model") or self.model,
|
||||
tokens_spent=last_result.get("tokens_spent"),
|
||||
duration_s=last_result.get("execution_time_s"),
|
||||
resolved_model=last_result.get("model") or self.model,
|
||||
artifacts=[head_after] if committed and head_after else [],
|
||||
metadata={
|
||||
"turns": self._last_result.get("turns"),
|
||||
"tool_profile": self._last_result.get("tool_profile") or self.tool_profile,
|
||||
"turns": last_result.get("turns"),
|
||||
"tool_profile": last_result.get("tool_profile") or self.tool_profile,
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue