[codex] Improve CLI reliability and tooling#1
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthrough環境設定をリポジトリから削除し、スキーマとして Changes
Sequence Diagram(s)sequenceDiagram
actor User as ユーザー
participant CLI as CLI<br/>(main)
participant System as MAGISystem
participant PM as Provider<br/>Manager
participant P as Providers<br/>(OpenAI,<br/>Anthropic,<br/>Google)
participant Handler as Response<br/>Handler
participant Output as Output<br/>Formatter
User->>CLI: トピック、ラウンド数、プロバイダー指定
CLI->>System: 初期化(プロバイダー選択)
System->>PM: 要求されたプロバイダーのみ初期化
PM->>P: クライアント初期化
P-->>PM: クライアント/エラー状態
PM-->>System: available_models、client_errors
loop 各ラウンド
CLI->>System: facilitate_discussion()
System->>System: プロンプト準備
loop 要求されたプロバイダーごと
System->>Handler: _get_model_handler()
Handler->>System: get_ai_response()
System->>System: _run_with_timeout()
par タイムアウトチェック
System->>P: API呼び出し(バックグラウンドスレッド)
P-->>System: レスポンス
and タイムアウト監視
System->>System: timeout_seconds 監視
end
System->>System: リトライロジック(retry_count)
System-->>Handler: AIResponse(content/error)
Handler-->>System: ハンドル済みレスポンス
end
System->>System: discussion_history 更新
end
System->>System: _select_conclusion_model()
System->>System: 結論生成(利用可能プロバイダー)
System-->>Output: discussion_history、結論
Output->>Output: 出力形式選択(text/JSON/Markdown)
Output->>Output: render_result() / render_markdown()
Output-->>CLI: フォーマット済み結果
CLI->>CLI: _emit_output() / write_output()
alt ファイル出力
CLI->>CLI: ディレクトリ作成(必要に応じて)
CLI->>Output: ファイルに書き込み
else stdout
CLI-->>User: 結果表示
end
sequenceDiagram
actor User as ユーザー
participant CLI as CLI
participant System as MAGISystem
participant Provider as Provider<br/>(タイムアウト/リトライ対象)
User->>CLI: --timeout-seconds 60、--retry-count 2 を指定
CLI->>System: facilitate_discussion()
loop 各ラウンド、各プロバイダー
System->>System: _run_with_timeout() 呼び出し
activate System
par API呼び出し(バックグラウンドスレッド)
System->>Provider: get_ai_response()
Note over Provider: 処理中(timeout_seconds 経過)
Provider-->>System: timeout に達する前に完了 または タイムアウト
and タイムアウト監視(メインスレッド)
System->>System: timeout_seconds の経過を監視
alt timeout 発生
System-->>System: AIResponse(error="timeout")
else 正常完了
System-->>System: AIResponse(content=...)
end
end
deactivate System
System->>System: retry_count でリトライロジック実行
alt エラーあり かつ リトライ可能
System->>Provider: get_ai_response()(リトライ)
Provider-->>System: AIResponse
end
end
System-->>CLI: 最終結果(content/error)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c6155b5c66
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| worker.join(self.timeout_seconds) | ||
|
|
||
| if worker.is_alive(): |
There was a problem hiding this comment.
Cancel timed-out provider calls before retrying
When a provider exceeds timeout_seconds, the code returns a timeout error immediately but leaves the worker thread running in the background. If retry_count > 0, the next attempt starts a second API call while the first is still in flight, which can produce duplicate billed requests and extra rate-limit pressure under slow upstream responses. This affects any run where providers are slow/intermittent and makes timeout+retry behavior unsafe for production usage.
Useful? React with 👍 / 👎.
What changed
.gitignore,.env.example,README.md, CI,ruff,mypy, and unit tests.envfrom the repository so local secrets stay out of GitWhy it changed
The repository had a broken class structure, no test coverage, weak dependency management, and tracked local secrets. The CLI was also hard to automate because it lacked structured output and runtime controls.
Impact
The project is now runnable, testable, safer to share, and easier to use from scripts or CI.
Root cause
Core methods had drifted out of the class body, secret handling relied on a tracked
.env, and there was no automation to catch regressions.Validation
python -m unittest discover -s tests -v.venv/bin/ruff check ..venv/bin/mypypython -m py_compile mogisystem.py tests/test_mogisystem.pySummary by CodeRabbit
リリースノート
New Features
--providers)、複数出力形式(JSON/Markdown)、静寂モード、タイムアウト/リトライ制御を追加Tests
Documentation
Chores