MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / _detect_peer_error

Function _detect_peer_error

core/peer_shell.py:207–222  ·  view source on GitHub ↗

Return a short error description if the peer output signals failure, else None.

(output: str, returncode: int)

Source from the content-addressed store, hash-verified

205
206
207def _detect_peer_error(output: str, returncode: int) -> Optional[str]:
208 """Return a short error description if the peer output signals failure, else None."""
209 if returncode not in (0, None):
210 for kw in _PEER_ERROR_KEYWORDS:
211 if kw in output:
212 if "429" in output or "capacity" in output.lower() or "rate" in output.lower():
213 return "rate-limited (429) — model capacity exhausted"
214 return f"exited with code {returncode}"
215 # Non-zero exit with no known keyword still counts as failure
216 if returncode != 0:
217 return f"exited with code {returncode}"
218 # Check keywords even on exit-0 (some CLIs exit 0 on error)
219 for kw in _PEER_ERROR_KEYWORDS:
220 if kw in output:
221 return "API error in output"
222 return None
223
224
225def run_prompted(cli_name: str, cmd: str, flag: str, prompt_text: str) -> str:

Callers 1

run_promptedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected