feat(python): implemented host tool event normalization and error checks

- Added `_normalize_host_tool_event` to `RpcClient` to remap transport tool events to executed host tools.
- Updated worker tool-end handling to verify `is_error` is false before marking terminal actions complete.
- Added test coverage in `test_client.py` and `test_worker.py` for host tool event normalization and errored review submission behavior.
This commit is contained in:
can1357
2026-07-27 07:11:18 +02:00
parent 0388946e85
commit a9b7df8821
6 changed files with 199 additions and 12 deletions
+14 -2
View File
@@ -265,7 +265,13 @@ class GitHubClient:
last_exc = exc
log.warning(
"transient github 5xx, retrying",
extra={"method": method, "path": path, "attempt": attempt + 1, "delay": delay, "status": exc.status},
extra={
"method": method,
"path": path,
"attempt": attempt + 1,
"delay": delay,
"status": exc.status,
},
)
time.sleep(delay)
raise last_exc # type: ignore[misc]
@@ -294,7 +300,13 @@ class GitHubClient:
last_exc = exc
log.warning(
"transient github 5xx, retrying",
extra={"method": method, "path": path, "attempt": attempt + 1, "delay": delay, "status": exc.status},
extra={
"method": method,
"path": path,
"attempt": attempt + 1,
"delay": delay,
"status": exc.status,
},
)
await asyncio.sleep(delay)
raise last_exc # type: ignore[misc]
+9 -2
View File
@@ -500,14 +500,21 @@ def _run_rpc_blocking(
def _on_tool_end(event: ToolExecutionEndEvent) -> None:
tool_name = event.tool_name
if event.result is not None:
# `tool_name` is transport-normalized by omp_rpc: an xd:// device
# dispatch (`write xd://submit_pr_review`) reports the host tool that
# ran, so terminal-action detection can match on host-tool names. A
# failed execution (`is_error`) does not count as reaching the
# terminal action — a rejected submit must still trigger the
# completion reminder.
ok = event.result is not None and not event.is_error
if ok:
tools_called.add(tool_name)
log.info(
"tool_end",
extra={
"issue": bindings.issue_key,
"tool": tool_name,
"ok": event.result is not None,
"ok": ok,
},
)