Split effort into its own request column
This commit is contained in:
@@ -71,7 +71,7 @@ uv run codex-retry-gateway-tui
|
|||||||
Views:
|
Views:
|
||||||
|
|
||||||
- overview: current gateway status and summary counts
|
- overview: current gateway status and summary counts
|
||||||
- requests: recent requests, response/request/thread IDs, timing, usage, cached ratio, attempts, reasoning effort/summary, and `usage_last_updated_at`
|
- requests: recent requests, response/request/thread IDs, timing, effort, usage, cached ratio, retry note, and `usage_last_updated_at`
|
||||||
- logs: recent gateway logs
|
- logs: recent gateway logs
|
||||||
- profiles: saved profiles, active profile default selection, profile actions
|
- profiles: saved profiles, active profile default selection, profile actions
|
||||||
|
|
||||||
|
|||||||
+20
-28
@@ -472,27 +472,21 @@ def request_chunk_progress(row: dict[str, Any]) -> str:
|
|||||||
return f"{row.get('stream_chunk_count') or 0} / {format_bytes(row.get('response_bytes_received'))}"
|
return f"{row.get('stream_chunk_count') or 0} / {format_bytes(row.get('response_bytes_received'))}"
|
||||||
|
|
||||||
|
|
||||||
def request_reasoning_mode_summary(row: dict[str, Any]) -> str:
|
def request_effort_text(row: dict[str, Any]) -> str:
|
||||||
effort = str(row.get("reasoning_effort") or "").strip()
|
return str(row.get("reasoning_effort") or "").strip() or "-"
|
||||||
summary = str(row.get("reasoning_summary") or "").strip()
|
|
||||||
bits = []
|
|
||||||
if effort:
|
def request_retry_note(row: dict[str, Any]) -> str:
|
||||||
bits.append(effort)
|
attempts = as_int(row.get("upstream_attempt_count"))
|
||||||
if summary:
|
if attempts <= 1:
|
||||||
bits.append(f"summary {summary}")
|
return ""
|
||||||
return " | ".join(bits)
|
return str(row.get("error") or "").strip()
|
||||||
|
|
||||||
|
|
||||||
def request_row_cells(row: dict[str, Any], text_limits: dict[str, int] | None = None) -> tuple[Any, ...]:
|
def request_row_cells(row: dict[str, Any], text_limits: dict[str, int] | None = None) -> tuple[Any, ...]:
|
||||||
limits = text_limits or {}
|
limits = text_limits or {}
|
||||||
note_prefix = f"{row['upstream_attempt_count'] or 0}x "
|
note_width = max(4, limits.get("note", 22))
|
||||||
note_width = max(4, limits.get("note", 22) - len(note_prefix))
|
retry_note = request_retry_note(row)
|
||||||
note_parts = []
|
|
||||||
reasoning_mode = request_reasoning_mode_summary(row)
|
|
||||||
if reasoning_mode:
|
|
||||||
note_parts.append(reasoning_mode)
|
|
||||||
if row.get("error"):
|
|
||||||
note_parts.append(str(row["error"]))
|
|
||||||
return (
|
return (
|
||||||
str(row["seq"]),
|
str(row["seq"]),
|
||||||
short_text(request_id_text(row), limits.get("req_id", 18)) or "-",
|
short_text(request_id_text(row), limits.get("req_id", 18)) or "-",
|
||||||
@@ -502,7 +496,7 @@ def request_row_cells(row: dict[str, Any], text_limits: dict[str, int] | None =
|
|||||||
f"{status_symbol(row)} {row.get('status_code') or '-'}",
|
f"{status_symbol(row)} {row.get('status_code') or '-'}",
|
||||||
short_text(row["path"], limits.get("path", 22)),
|
short_text(row["path"], limits.get("path", 22)),
|
||||||
short_text(row["model"] or row["requested_model"] or row["forwarded_model"], limits.get("model", 16)),
|
short_text(row["model"] or row["requested_model"] or row["forwarded_model"], limits.get("model", 16)),
|
||||||
row["reasoning_tokens"] if row["reasoning_tokens"] is not None else "-",
|
short_text(request_effort_text(row), limits.get("effort", 10)),
|
||||||
short_text(request_usage_summary(row), limits.get("usage", 24)),
|
short_text(request_usage_summary(row), limits.get("usage", 24)),
|
||||||
format_bytes(row.get("request_body_bytes")),
|
format_bytes(row.get("request_body_bytes")),
|
||||||
format_bytes(row.get("response_bytes_received")),
|
format_bytes(row.get("response_bytes_received")),
|
||||||
@@ -510,7 +504,7 @@ def request_row_cells(row: dict[str, Any], text_limits: dict[str, int] | None =
|
|||||||
format_duration_ms_as_seconds(row["first_response_delay_ms"]),
|
format_duration_ms_as_seconds(row["first_response_delay_ms"]),
|
||||||
format_duration_ms_as_seconds(row["duration_ms"]),
|
format_duration_ms_as_seconds(row["duration_ms"]),
|
||||||
request_updated_elapsed(row),
|
request_updated_elapsed(row),
|
||||||
f"{note_prefix}{short_text(' | '.join(note_parts), note_width)}",
|
short_text(retry_note, note_width),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -706,7 +700,6 @@ def request_match_score(row: dict[str, Any], needle: str) -> bool:
|
|||||||
"requested_model",
|
"requested_model",
|
||||||
"forwarded_model",
|
"forwarded_model",
|
||||||
"reasoning_effort",
|
"reasoning_effort",
|
||||||
"reasoning_summary",
|
|
||||||
"error",
|
"error",
|
||||||
"upstream_origin",
|
"upstream_origin",
|
||||||
"upstream_path",
|
"upstream_path",
|
||||||
@@ -828,8 +821,6 @@ def render_request_detail(row: dict[str, Any]) -> str:
|
|||||||
bits.append(f"forwarded {row['forwarded_model']}")
|
bits.append(f"forwarded {row['forwarded_model']}")
|
||||||
if row.get("reasoning_effort"):
|
if row.get("reasoning_effort"):
|
||||||
bits.append(f"effort {row['reasoning_effort']}")
|
bits.append(f"effort {row['reasoning_effort']}")
|
||||||
if row.get("reasoning_summary"):
|
|
||||||
bits.append(f"summary {row['reasoning_summary']}")
|
|
||||||
if row.get("reasoning_tokens") is not None:
|
if row.get("reasoning_tokens") is not None:
|
||||||
bits.append(f"reasoning {row['reasoning_tokens']}")
|
bits.append(f"reasoning {row['reasoning_tokens']}")
|
||||||
if row.get("input_tokens") is not None or row.get("output_tokens") is not None or row.get("total_tokens") is not None or row.get("cached_tokens") is not None:
|
if row.get("input_tokens") is not None or row.get("output_tokens") is not None or row.get("total_tokens") is not None or row.get("cached_tokens") is not None:
|
||||||
@@ -1252,7 +1243,7 @@ def run_textual(
|
|||||||
"status": 7,
|
"status": 7,
|
||||||
"path": 22,
|
"path": 22,
|
||||||
"model": 16,
|
"model": 16,
|
||||||
"reasoning": 10,
|
"effort": 8,
|
||||||
"usage": 36,
|
"usage": 36,
|
||||||
"req": 10,
|
"req": 10,
|
||||||
"resp": 10,
|
"resp": 10,
|
||||||
@@ -1271,7 +1262,7 @@ def run_textual(
|
|||||||
"status": 7,
|
"status": 7,
|
||||||
"path": 40,
|
"path": 40,
|
||||||
"model": 24,
|
"model": 24,
|
||||||
"reasoning": 10,
|
"effort": 8,
|
||||||
"usage": 72,
|
"usage": 72,
|
||||||
"req": 12,
|
"req": 12,
|
||||||
"resp": 12,
|
"resp": 12,
|
||||||
@@ -1312,7 +1303,7 @@ def run_textual(
|
|||||||
"status": requests.add_column("Status", width=width_profile["status"], key="status"),
|
"status": requests.add_column("Status", width=width_profile["status"], key="status"),
|
||||||
"path": requests.add_column("Path", width=width_profile["path"], key="path"),
|
"path": requests.add_column("Path", width=width_profile["path"], key="path"),
|
||||||
"model": requests.add_column("Model", width=width_profile["model"], key="model"),
|
"model": requests.add_column("Model", width=width_profile["model"], key="model"),
|
||||||
"reasoning": requests.add_column("Reasoning", width=width_profile["reasoning"], key="reasoning"),
|
"effort": requests.add_column("Effort", width=width_profile["effort"], key="effort"),
|
||||||
"usage": requests.add_column("Usage", width=self.request_usage_width, key="usage"),
|
"usage": requests.add_column("Usage", width=self.request_usage_width, key="usage"),
|
||||||
"req_bytes": requests.add_column("Req Size", width=width_profile["req"], key="req_bytes"),
|
"req_bytes": requests.add_column("Req Size", width=width_profile["req"], key="req_bytes"),
|
||||||
"resp_bytes": requests.add_column("Resp Size", width=width_profile["resp"], key="resp_bytes"),
|
"resp_bytes": requests.add_column("Resp Size", width=width_profile["resp"], key="resp_bytes"),
|
||||||
@@ -1598,10 +1589,11 @@ def run_textual(
|
|||||||
"thread": width_profile["thread"],
|
"thread": width_profile["thread"],
|
||||||
"path": width_profile["path"],
|
"path": width_profile["path"],
|
||||||
"model": width_profile["model"],
|
"model": width_profile["model"],
|
||||||
|
"effort": width_profile["effort"],
|
||||||
"usage": self.request_usage_width,
|
"usage": self.request_usage_width,
|
||||||
"note": width_profile["note"],
|
"note": width_profile["note"],
|
||||||
}
|
}
|
||||||
for name in ("req_id", "resp_id", "thread", "path", "model", "usage", "note"):
|
for name in ("req_id", "resp_id", "thread", "path", "model", "effort", "usage", "note"):
|
||||||
key = self.request_table_column_keys.get(name)
|
key = self.request_table_column_keys.get(name)
|
||||||
column = table.columns.get(key) if key is not None else None
|
column = table.columns.get(key) if key is not None else None
|
||||||
if column is None or not getattr(column, "width", 0):
|
if column is None or not getattr(column, "width", 0):
|
||||||
@@ -1827,9 +1819,9 @@ def print_once(snapshot: dict[str, Any], filter_text: str = "") -> None:
|
|||||||
try:
|
try:
|
||||||
print(
|
print(
|
||||||
f"{row['seq']:>6} {short_text(request_id_text(row), 16):<16} {short_text(response_id_text(row), 16):<16} {short_text(row.get('thread_id'), 14):<14} {short_time(row.get('started_at')):<19} {status_symbol(row)} {row.get('status_code') or '-':<4} "
|
f"{row['seq']:>6} {short_text(request_id_text(row), 16):<16} {short_text(response_id_text(row), 16):<16} {short_text(row.get('thread_id'), 14):<14} {short_time(row.get('started_at')):<19} {status_symbol(row)} {row.get('status_code') or '-':<4} "
|
||||||
f"{short_text(row['path'], 20):<20} {short_text(row['model'] or row['requested_model'] or row['forwarded_model'], 16):<16} "
|
f"{short_text(row['path'], 20):<20} {short_text(row['model'] or row['requested_model'] or row['forwarded_model'], 16):<16} {short_text(request_effort_text(row), 6):<6} "
|
||||||
f"{short_text(request_usage_summary(row), 26):<26} {format_bytes(row.get('request_body_bytes')):<8} {request_chunk_progress(row):<14} {format_duration_ms_as_seconds(row['duration_ms']):<8} {request_updated_elapsed(row):<8} "
|
f"{short_text(request_usage_summary(row), 26):<26} {format_bytes(row.get('request_body_bytes')):<8} {request_chunk_progress(row):<14} {format_duration_ms_as_seconds(row['duration_ms']):<8} {request_updated_elapsed(row):<8} "
|
||||||
f"{format_count(row['upstream_attempt_count'] or 0):<4} {short_text(row['error'], 30)}"
|
f"{short_text(request_retry_note(row), 30)}"
|
||||||
)
|
)
|
||||||
except BrokenPipeError:
|
except BrokenPipeError:
|
||||||
return
|
return
|
||||||
|
|||||||
+19
-2
@@ -105,7 +105,6 @@ class CodexRetryGatewayTUITests(unittest.TestCase):
|
|||||||
self.assertIn("resp resp_1", mod.render_request_detail(row))
|
self.assertIn("resp resp_1", mod.render_request_detail(row))
|
||||||
self.assertIn("updated 1.0s", mod.render_request_detail(row))
|
self.assertIn("updated 1.0s", mod.render_request_detail(row))
|
||||||
self.assertIn("effort xhigh", mod.render_request_detail(row))
|
self.assertIn("effort xhigh", mod.render_request_detail(row))
|
||||||
self.assertIn("summary auto", mod.render_request_detail(row))
|
|
||||||
self.assertEqual(mod.request_updated_elapsed(row), "1.0s")
|
self.assertEqual(mod.request_updated_elapsed(row), "1.0s")
|
||||||
self.assertEqual(mod.request_chunk_progress(row), "7 / 4.1KB")
|
self.assertEqual(mod.request_chunk_progress(row), "7 / 4.1KB")
|
||||||
|
|
||||||
@@ -149,6 +148,7 @@ class CodexRetryGatewayTUITests(unittest.TestCase):
|
|||||||
wide = mod.request_row_cells(row, {"req_id": 36, "resp_id": 36, "thread": 36, "path": 40, "model": 24, "usage": 72, "note": 48})
|
wide = mod.request_row_cells(row, {"req_id": 36, "resp_id": 36, "thread": 36, "path": 40, "model": 24, "usage": 72, "note": 48})
|
||||||
self.assertEqual(compact[10], "0B")
|
self.assertEqual(compact[10], "0B")
|
||||||
self.assertEqual(wide[10], "0B")
|
self.assertEqual(wide[10], "0B")
|
||||||
|
self.assertEqual(compact[8], "-")
|
||||||
self.assertLess(len(compact[1]), len(wide[1]))
|
self.assertLess(len(compact[1]), len(wide[1]))
|
||||||
self.assertLess(len(compact[2]), len(wide[2]))
|
self.assertLess(len(compact[2]), len(wide[2]))
|
||||||
self.assertLess(len(compact[3]), len(wide[3]))
|
self.assertLess(len(compact[3]), len(wide[3]))
|
||||||
@@ -187,9 +187,26 @@ class CodexRetryGatewayTUITests(unittest.TestCase):
|
|||||||
cells = mod.request_row_cells(row)
|
cells = mod.request_row_cells(row)
|
||||||
self.assertEqual(cells[1], "req_1")
|
self.assertEqual(cells[1], "req_1")
|
||||||
self.assertEqual(cells[2], "resp_1")
|
self.assertEqual(cells[2], "resp_1")
|
||||||
|
self.assertEqual(cells[8], "xhigh")
|
||||||
self.assertEqual(cells[10], "1.5KB")
|
self.assertEqual(cells[10], "1.5KB")
|
||||||
self.assertEqual(cells[11], "4.1KB")
|
self.assertEqual(cells[11], "4.1KB")
|
||||||
self.assertIn("xhigh", cells[16])
|
self.assertEqual(cells[16], "-")
|
||||||
|
|
||||||
|
def test_request_retry_note_only_shows_retry_reason(self) -> None:
|
||||||
|
mod = load_module()
|
||||||
|
single_attempt = {
|
||||||
|
"upstream_attempt_count": 1,
|
||||||
|
"error": "Selected model is at capacity. Please try a different model.",
|
||||||
|
}
|
||||||
|
retried = {
|
||||||
|
"upstream_attempt_count": 3,
|
||||||
|
"error": "Selected model is at capacity. Please try a different model.",
|
||||||
|
}
|
||||||
|
self.assertEqual(mod.request_retry_note(single_attempt), "")
|
||||||
|
self.assertEqual(
|
||||||
|
mod.request_retry_note(retried),
|
||||||
|
"Selected model is at capacity. Please try a different model.",
|
||||||
|
)
|
||||||
|
|
||||||
def test_request_rows_read_usage_from_nested_usage_object(self) -> None:
|
def test_request_rows_read_usage_from_nested_usage_object(self) -> None:
|
||||||
mod = load_module()
|
mod = load_module()
|
||||||
|
|||||||
Reference in New Issue
Block a user