Skip to main content
Glama
kvrancic

prime-intellect-mcp

by kvrancic

pod_check_runaway

Identifies GPU pods that exceed time or cost limits, preventing runaway charges by catching forgotten resources at session start.

Instructions

Return locally-tracked pods that have run past max_lifetime_hours OR whose accumulated cost is approaching PRIME_MAX_TOTAL_USD.

Call this at the start of long-running sessions to catch forgotten pods.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler for the pod_check_runaway tool. Iterates locally-tracked pods, checks if they exceed max_lifetime_hours or 80% of PRIME_MAX_TOTAL_USD, and returns a list of RunawayPod dicts.
    @mcp.tool
    async def pod_check_runaway() -> list[dict[str, Any]]:
        """Return locally-tracked pods that have run past max_lifetime_hours OR whose
        accumulated cost is approaching PRIME_MAX_TOTAL_USD.
    
        Call this at the start of long-running sessions to catch forgotten pods.
        """
        runaways: list[RunawayPod] = []
        cap_total = max_total_usd()
        for tp in list_tracked():
            elapsed_hours = (time.time() - tp.started_at_unix) / 3600.0
            spend = elapsed_hours * tp.hourly_usd
            reasons = []
            if elapsed_hours > tp.max_lifetime_hours:
                reasons.append(
                    f"running for {elapsed_hours:.2f}h, declared max_lifetime_hours="
                    f"{tp.max_lifetime_hours}"
                )
            if spend > cap_total * 0.8:
                reasons.append(
                    f"estimated spend ${spend:.2f} is >80% of PRIME_MAX_TOTAL_USD=${cap_total:.2f}"
                )
            if not reasons:
                continue
            runaways.append(
                RunawayPod(
                    pod_id=tp.pod_id,
                    name=tp.name,
                    hourly_usd=tp.hourly_usd,
                    started_at_unix=tp.started_at_unix,
                    elapsed_hours=elapsed_hours,
                    estimated_spend_usd=spend,
                    max_lifetime_hours=tp.max_lifetime_hours,
                    reason="; ".join(reasons),
                )
            )
        return [r.model_dump() for r in runaways]
  • Pydantic model defining the output schema for each runaway pod returned by pod_check_runaway.
    class RunawayPod(BaseModel):
        """A pod we tracked locally that has either run past its declared max_lifetime
        or burned more than 80% of PRIME_MAX_TOTAL_USD."""
    
        pod_id: str
        name: str | None = None
        hourly_usd: float
        started_at_unix: float
        elapsed_hours: float
        estimated_spend_usd: float
        max_lifetime_hours: int
        reason: str  # e.g. "exceeded max_lifetime_hours" or "approaching total cap"
        suggestion: str = (
            "Consider terminating with pod_terminate(pod_id, confirm=True) "
            "if you no longer need this pod."
        )
  • The @mcp.tool decorator registers pod_check_runaway as an MCP tool on the FastMCP server instance.
    async def pod_check_runaway() -> list[dict[str, Any]]:
  • Helper function that reads the PRIME_MAX_TOTAL_USD environment variable, used by pod_check_runaway to compute the 80% spending threshold.
    def max_total_usd() -> float:
        raw = os.getenv("PRIME_MAX_TOTAL_USD")
        if raw is None:
            return DEFAULT_MAX_TOTAL_USD
        try:
            return float(raw)
        except ValueError:
            return DEFAULT_MAX_TOTAL_USD
  • Helper function that returns all locally-tracked pods from state.json, iterated by pod_check_runaway to find runaway pods.
    def list_tracked() -> list[TrackedPod]:
        with _lock:
            data = _read()
        return [TrackedPod(**v) for v in data.values()]
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden for behavioral disclosure. It states the tool returns matching pods but does not mention whether it is read-only, side effects, rate limits, or refresh behavior. For a check tool, assuming read-only is reasonable but not explicit.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences, no wasted words. The first sentence states purpose, the second provides usage guidance. Front-loaded with key information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with no parameters and an output schema (not shown but exists), the description is fairly complete. It could note that the operation is read-only, but overall it covers what the tool does and when to use it.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has zero parameters, baseline is 4 per instructions. Description adds context about the filtering criteria (max_lifetime_hours and cost limit) which are not parameters but clarify the tool's logic. Schema coverage is 100% due to no parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states it returns 'locally-tracked pods that have run past max_lifetime_hours OR whose accumulated cost is approaching PRIME_MAX_TOTAL_USD'. This distinguishes it from sibling tools like 'pod_list' (list all) and 'pod_status' (status of specific pod), providing a specific verb+resource combination.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly advises 'Call this at the start of long-running sessions to catch forgotten pods', giving clear when-to-use context. While it doesn't exclude other scenarios, the guidance is sufficient for typical use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kvrancic/prime-intellect-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server