[相談] 添付ファイルのタイミング問題 — gitea-agent-orchestrator #1

Open
opened 2026-03-09 16:16:32 +00:00 by swallow · 0 comments

問題

gitea-agent-orchestrator で、Issue 作成時の添付ファイルが webhook 発火時点では存在しないケースがある。

現象

  1. Gitea API で Issue 作成 → issues.opened webhook が発火
  2. その直後に添付ファイルを API でアップロード
  3. worker が webhook を受けてジョブ開始、getIssueAttachments() を呼ぶが、添付がまだ存在しない
  4. input/ が空のまま処理が進み、LLM が「ファイルが見つからない」と ASK に遷移

現在のコード(worker.ts)

if (isFirstRun) {
  const attachments = await this.gitea.getIssueAttachments(repoName, issueNumber);
  for (const att of attachments) {
    const content = await this.gitea.downloadAttachment(att.browser_download_url);
    writeFileSync(join(workspacePath, 'input', safeName), content);
  }
}

考えている対策案

  1. ジョブ開始前に短い delay を入れる(例: 3秒待つ)
  2. webhook で添付追加イベントも監視して、添付があればリトリガー
  3. 添付が0件の場合にリトライする(例: 5秒後に再チェック)
  4. Issue 本文に添付 URL が含まれるまで待つ

他に良いアプローチがあれば教えてほしい。シンプルで確実な方法が良い。

関連コード: https://gitea.swallow.wjg.jp/agent-bot/gitea-agent-orchestrator/src/branch/main/src/worker.ts

## 問題 gitea-agent-orchestrator で、Issue 作成時の添付ファイルが webhook 発火時点では存在しないケースがある。 ### 現象 1. Gitea API で Issue 作成 → `issues.opened` webhook が発火 2. その直後に添付ファイルを API でアップロード 3. worker が webhook を受けてジョブ開始、`getIssueAttachments()` を呼ぶが、添付がまだ存在しない 4. input/ が空のまま処理が進み、LLM が「ファイルが見つからない」と ASK に遷移 ### 現在のコード(worker.ts) ```typescript if (isFirstRun) { const attachments = await this.gitea.getIssueAttachments(repoName, issueNumber); for (const att of attachments) { const content = await this.gitea.downloadAttachment(att.browser_download_url); writeFileSync(join(workspacePath, 'input', safeName), content); } } ``` ### 考えている対策案 1. **ジョブ開始前に短い delay を入れる**(例: 3秒待つ) 2. **webhook で添付追加イベントも監視して、添付があればリトリガー** 3. **添付が0件の場合にリトライする**(例: 5秒後に再チェック) 4. **Issue 本文に添付 URL が含まれるまで待つ** 他に良いアプローチがあれば教えてほしい。シンプルで確実な方法が良い。 関連コード: https://gitea.swallow.wjg.jp/agent-bot/gitea-agent-orchestrator/src/branch/main/src/worker.ts
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: agent-bot/takt#1
No description provided.