Skip to content

Adjust pool capacity and support local agent creation#76

Merged
yohi merged 10 commits into
masterfrom
feature/phase4_agent-create-finalization__base
May 14, 2026
Merged

Adjust pool capacity and support local agent creation#76
yohi merged 10 commits into
masterfrom
feature/phase4_agent-create-finalization__base

Conversation

@yohi
Copy link
Copy Markdown
Owner

@yohi yohi commented May 14, 2026

No description provided.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6f8bd31e-1766-4b61-9a61-18e25a8d2527

📥 Commits

Reviewing files that changed from the base of the PR and between 9aea28d and 8be8159.

📒 Files selected for processing (3)
  • docs/superpowers/plans/2026-05-12-bun-to-node-migration.md
  • src/openai-proxy.ts
  • src/provider.ts
✅ Files skipped from review due to trivial changes (1)
  • docs/superpowers/plans/2026-05-12-bun-to-node-migration.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/openai-proxy.ts

Summary by CodeRabbit

  • 改善
    • エージェント プール容量を 8→10 に増加し、より多くの同時処理が可能になりました。
    • エージェント作成時にローカル作業ディレクトリを明示的に指定するようにして作成フローを堅牢化しました。
  • テスト
    • エージェント生成に関する検証を強化しました(作成時オプション確認を追加)。
  • ドキュメント
    • 移行プランの該当フェーズを完了済みに更新しました。

Walkthrough

プール容量を8から10に拡大し、Agent.createにローカル作業ディレクトリ(process.cwd())を明示的に設定。AgentCreateOpts型を導入してオプションを正式化し、openai-proxyとproviderで実装を統一し、テストを更新。

Changes

Agent作成オプション統一

Layer / File(s) Summary
プール容量拡張
src/index.ts
POOL_CAPACITY定数を8から10に増加。
Agent.createオプションの型定義と実装
src/provider.ts, src/openai-proxy.ts, tests/provider.test.ts
AgentCreateOpts型導入でオプション形状を正式化。provider.ts の performAgentCreationAttempt / createAgentWithRetry を更新し、Agent.create 呼び出しに local: { cwd: process.cwd() } を追加。openai-proxy の動的 import 型を構造的型に置換し、テスト内のアサーションを強化して新しいオプション形式を検証。
ドキュメントのチェックリスト更新
docs/superpowers/plans/2026-05-12-bun-to-node-migration.md
Phase/Task のチェック項目を未完了から完了に更新(POOL_CAPACITY 変更や PoC/テスト手順の完了表示など)。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 プールは十へ伸びて、
カレントの径を明らかに。
型は約束を紡ぎ、
作成の道をテストが辿る。
小さな調整で庭は整う。

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive プルリクエストの説明が提供されていないため、変更内容との関連性を判断できない。 詳細な説明を追加して、各変更の目的と影響を明確にしてください。
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed タイトルは変更内容の主要な2つのポイント(プール容量調整とローカルエージェント生成サポート)を明確に要約している。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/phase4_agent-create-finalization__base

Comment @coderabbitai help to get the list of available commands and usage tips.

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 14, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 14, 2026

Greptile Summary

プール容量を 8 から 10 に増やし、Agent.create 呼び出しに local: { cwd: process.cwd() } オプションを追加してローカルエージェント作成をサポートするPRです。provider.tsopenai-proxy.ts の両コードパスに同じ変更が適用されており、テストも更新されています。

  • POOL_CAPACITY を 10 に引き上げ(src/index.ts
  • AgentCreateOpts 型に local フィールドを追加し、performAgentCreationAttemptopenai-proxy.tsAgent.create 呼び出し双方に local: { cwd: process.cwd() } を渡すよう変更
  • テストの expect.objectContaininglocal: { cwd: process.cwd() } を追加して新しい引数を検証

Confidence Score: 4/5

ローカルエージェント作成のサポートとプール容量の調整は低リスクな変更であり、マージ自体は安全です。

openai-proxy.ts では Promise<any> の使用や AgentCreateOpts 型の重複定義が残っており、将来的に local の構造変更時に片方の更新を見落とす可能性があります。機能的な欠陥ではありませんが、コードの保守性に影響します。

src/openai-proxy.ts は型定義の重複と any の使用について確認が必要です。

Important Files Changed

Filename Overview
src/index.ts POOL_CAPACITY を 8 から 10 に増加。シンプルな定数変更。
src/openai-proxy.ts Agent.create のインライン型定義に local オプションを追加。型アサーション内で Promise を使用しており、provider.ts との不整合がある。AgentCreateOpts 型が共有されていない。
src/provider.ts AgentCreateOpts 型に local フィールドを追加し、Agent.create 呼び出しに local: { cwd: process.cwd() } を渡すよう変更。型安全に実装されている。
tests/provider.test.ts Agent.create の呼び出し検証に local: { cwd: process.cwd() } を追加。テスト用プールの capacity は変更されず 8 のまま(本番は 10)。

Sequence Diagram

sequenceDiagram
    participant Client
    participant OpenAIProxy
    participant Provider
    participant AgentPool
    participant CursorSDK

    Client->>OpenAIProxy: POST /v1/chat/completions
    OpenAIProxy->>AgentPool: tryGet(prefixHash, modelId, apiKey)
    alt Pool Hit
        AgentPool-->>OpenAIProxy: SDKAgent (cached)
    else Pool Miss
        OpenAIProxy->>CursorSDK: "Agent.create({ apiKey, model, local: { cwd } })"
        CursorSDK-->>OpenAIProxy: SDKAgent (new, local mode)
    end
    OpenAIProxy->>CursorSDK: agent.send(message)
    CursorSDK-->>OpenAIProxy: stream/result
    OpenAIProxy->>AgentPool: pool.put(nextHash, agent)
    OpenAIProxy-->>Client: SSE / JSON response

    Client->>Provider: doStream(prompt)
    Provider->>AgentPool: tryGet(prefixHash, modelId, apiKey)
    alt Pool Hit
        AgentPool-->>Provider: SDKAgent (cached)
    else Pool Miss
        Provider->>CursorSDK: "Agent.create({ apiKey, model, local: { cwd } })"
        CursorSDK-->>Provider: SDKAgent (new, local mode)
    end
    Provider->>CursorSDK: agent.send(message)
    CursorSDK-->>Provider: ReadableStream
    Provider-->>Client: stream
Loading
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
src/openai-proxy.ts:155-163
`Promise<any>` を使用しており、`provider.ts` の同等コードが `Promise<unknown>` を使っているのと一貫性がありません。`any` は型チェックを無効化するため、`unknown` に変更してより安全な型推論を保持することを推奨します。

```suggestion
    const { Agent } = (await import("@cursor/sdk")) as unknown as {
      Agent: {
        create: (opts: {
          apiKey: string;
          model: { id: string };
          local: { cwd: string };
        }) => Promise<unknown>;
      };
    };
```

### Issue 2 of 2
src/openai-proxy.ts:155-163
`Agent.create` の引数型(`apiKey``model``local`)が `provider.ts``AgentCreateOpts` 型と重複して定義されています。`AgentCreateOpts` をエクスポートして `openai-proxy.ts` でインポートすれば、将来的に `local` の構造が変更された際に片方だけ更新漏れが起きるリスクを防げます。

Reviews (1): Last reviewed commit: "Merge pull request #68 from yohi/feature..." | Re-trigger Greptile

Comment thread src/openai-proxy.ts
Comment thread src/openai-proxy.ts
@yohi yohi merged commit 2f740d6 into master May 14, 2026
3 checks passed
@yohi yohi deleted the feature/phase4_agent-create-finalization__base branch May 14, 2026 01:14
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