Skip to content

loopguard, trace: expand source extensions and dynamically resolve Antigravity model pricing - #309

Open
Xinghan Pan (PStarH) wants to merge 1 commit into
microsoft:mainfrom
PStarH:feat/loopguard-source-extensions-and-antigravity-model
Open

Xinghan Pan (PStarH) wants to merge 1 commit into
microsoft:mainfrom
PStarH:feat/loopguard-source-extensions-and-antigravity-model

Conversation

@PStarH

Copy link
Copy Markdown

Summary

This PR improves shell edit detection in loopguard and enhances the Antigravity session trace importer:

  1. Loopguard Shell Edit Detection:

    • _SOURCE_FILE regex in tokeneconomizer/loopguard/shell_edits.py now recognizes .cu, .cuh (CUDA), .zig, .dart, .sol (Solidity), .proto (Protobuf), .graphql/.gql, .astro, and .cmake.
    • Previously, shell-based modifications (sed -i, cat > ...) on these file types were not recognized as source edits, which could falsely trigger loopguard stuck turn detection during polyglot/systems development.
  2. Antigravity Trace & Dynamic Pricing:

    • antigravity_session_usage() now inspects PLANNER_RESPONSE rows to detect the active model (e.g., gemini-2.5-pro, gemini-3.8-flash) rather than hardcoding "antigravity".
    • In tokeneconomizer/pricing.py, weights_for() strips thinking-budget and variant suffixes (e.g. -high, -medium, -low, -thinking, -latest) when doing dictionary lookups so variants like gemini-3.8-flash-high correctly resolve to their base weights instead of raising ValueError.
    • Added lowercase key support (path, file_path, filePath, pattern, directory) and search_web mapping to antigravity.py tool definitions.
    • Exported antigravity_tool in tokeneconomizer.trace.__all__.

Verification

  • Added parameterized unit tests in tests/test_live_core.py covering all newly recognized extensions.
  • Added tests in tests/test_antigravity.py verifying usage model resolution and lowercase argument parsing.
  • Ran test suite: 383 passed, 6 skipped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant