Adjust pool capacity and support local agent creation#76
Conversation
…ature/phase4-task1_pool-capacity-10
perf(agent-pool): POOL_CAPACITY 8 → 10
…ature/phase4-task2_agent-create-local-mode
…cal-mode
feat(agent): Agent.create に local: { cwd } を明示 (PoC 成功を受けて採用)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Summary by CodeRabbit
Walkthroughプール容量を8から10に拡大し、Agent.createにローカル作業ディレクトリ( ChangesAgent作成オプション統一
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
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 Summaryプール容量を 8 から 10 に増やし、
Confidence Score: 4/5ローカルエージェント作成のサポートとプール容量の調整は低リスクな変更であり、マージ自体は安全です。
|
| 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
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
No description provided.