Skip to content

Add --timeout flag to run-sql, document env var configuration - #1

Merged
project-defiant merged 2 commits into
mainfrom
add-run-sql-timeout-flag
Jul 9, 2026
Merged

Add --timeout flag to run-sql, document env var configuration#1
project-defiant merged 2 commits into
mainfrom
add-run-sql-timeout-flag

Conversation

@project-defiant

Copy link
Copy Markdown
Contributor

Summary

Adds a --timeout <seconds> flag to run-sql, letting a caller (typically the Skill, on behalf of an LLM) override the default ~45s query timeout for one specific call — for a query that's already minimal but legitimately slow (e.g. a full aggregate over a very large dataset), rather than a mistake that needs narrowing.

  • cli.py: new --timeout option, validated to be positive, passed through as commands.run_sql's existing timeout_seconds parameter (already plumbed through sql_guard.run_guarded_query, just not previously exposed at the CLI layer).
  • Tests: pass-through (custom value and default-when-omitted, via a mocked commands.run_sql), validation rejection, and a real end-to-end confirmation that a short --timeout genuinely cuts execution short (a view wrapping range() created outside the guard, same pattern as the existing timeout tests). 168 → 172 tests.
  • SKILL.md: documents --timeout on run-sql, and updates the timeout error-type guidance / behavioral rule 5 to distinguish "narrow the query" from "retry with --timeout" depending on whether the query is already minimal.
  • README.md / SKILL.md: added a consolidated environment-variable configuration section (OTAI_CACHE_DIR, OTAI_BASE_URI, OTAI_LOG_LEVEL), replacing previously scattered mentions.

Branched from this repo's current main (e136e64), so the diff is scoped to just this feature and preserves the Update SKILL.md invocation-URL change.

Test plan

  • make lint passes
  • make test (172 tests) passes
  • prek run --all-files passes locally
  • Manual end-to-end run against the real S3 bucket: a real slow cross join times out early with a short --timeout, and a real query succeeds with an explicit override

SzymonSzyszkowski and others added 2 commits July 9, 2026 13:05
- cli.py: new --timeout <seconds> option on run-sql, overriding
  sql_guard.DEFAULT_TIMEOUT_SECONDS for that call only. Rejects
  non-positive values via a validation callback (same pattern as
  --format). Lets the Skill (or a human) retry a query that's already
  minimal but legitimately slow, instead of only being able to narrow
  the query or accept the default ~45s limit.
- tests: pass-through (custom value and default-when-omitted, via a
  mocked commands.run_sql), validation rejection, and a real
  end-to-end confirmation that a short --timeout genuinely cuts
  execution short (view wrapping range() outside the guard, same
  pattern used for the existing timeout tests). 168 -> 172 tests.
- SKILL.md: documents --timeout on run-sql, updates the timeout
  error-type guidance and behavioral rule 5 to distinguish "narrow the
  query" from "retry with --timeout" depending on whether the query is
  already minimal.
- README.md / SKILL.md: added a consolidated environment-variable
  configuration section (OTAI_CACHE_DIR, OTAI_BASE_URI,
  OTAI_LOG_LEVEL) in both, replacing the previously scattered mentions.

Verified end-to-end against the real S3 bucket: a real slow cross
join times out early with a short --timeout, and a real query
succeeds with an explicit override.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Typer/Click's error panel wraps its message text differently depending
on the terminal width Rich detects, which differs between a local
terminal and the CI runner - splitting "positive number" across the
box border there. Matches this file's own established convention for
invalid-option tests (test_unknown_format_is_rejected): check
result.exit_code only.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@project-defiant
project-defiant merged commit 542f0ba into main Jul 9, 2026
2 checks passed
@project-defiant
project-defiant deleted the add-run-sql-timeout-flag branch July 9, 2026 13:38
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.

2 participants