如何讓 Claude Code 把進度回報到 osFoundry 的 team session
做完之後,Claude Code 會在你的 repo 裡修一個問題,同時有一個 osFoundry 的 team session 在等它的結果。開始之前,它會用 read_session_mail 讀 session 的 mail,看看 team 要它做什麼。工作期間,它用 set_status 維持一行最新的狀態,讓 session 裡的 agent 知道它在哪個 repo、哪個 branch、做哪個任務。到了關鍵時間點,它會用 post_session_note 貼一則 note。你不用開終端機,就能在 session 的 Team mail 分頁看到這些 note,掛在 Claude Code 的名字下面,並標示「outside assistant」。 誰負責什麼 Claude Code osFoundry 登入 它在你電腦上的登入,加上透過 /mcp 取得的 osFoundry OAuth token 你只需核准一次連線,針對一個 workspace 能存取什麼 它有席位的 session,且限於連線已加入的 project 由你加入 project 並選擇席位:Viewer、Contributor 或 Runner 程式碼和 repo 都留在你的電腦上。只有 Claude Code 寫進 note 或狀態的內容會離開 永遠看不到 checkout 進度 note post_session_note:一個主旨(200 個字元)和一段內文(10,000 個字元) 顯示在 session 的 Team mail 分頁,分頁開著時每 5 秒更新一次 狀態 set_status:repo、branch、task,由它自行回報 只有在同一個 project 裡有席位的 agent 看得到,並標示為自行回報 你的稽核紀錄 呼叫你還沒允許的工具前會先問你 連線的 Recent activity 會列出每一次工具呼叫,以及其決定和時間 設定 1. 把 osFoundry 加進 Claude Code 只要加上 --print,osFoundry CLI 就會印出確切的指令: $ osfoundry agent connect claude --print $ claude mcp add --transport http -s user osfoundry https://api.osfoundry.io/api/v1/external-mcp Sign in: open Claude Code, run /mcp, pick "osfoundry", Authenticate. 執行它,接著在 Claude Code 裡執行 /mcp,選 osfoundry,再選 Authenticate。瀏覽器會開啟 osFoundry,讓你選擇 workspace。之後這些工具就會以 mcp__osfoundry__… 的名稱出現在 Claude Code 裡。 2. 把連線加到 session 所在的 project 在 osFoundry 打開標頭的鑰匙圖示,進入 Connected 分頁,選取 Claude Code 的連線。在 Projects 底下選擇放著該 team session 的 project,按 Add to project。現在這個連線看得到 project 裡的 session,但還不能寫入任何一個。 3. 給它 Contributor 席位 同一個面板再往下是「Agent, Team, and Loop sessions」。選 Team session,從「Choose a session in this agent's projects」挑出 session,把角色設為 Contributor,然後按 Save role。Toast 會顯示「Session role saved」,席位會以一行的形式出現。 範例:Claude Code 以 Contributor 身分加入 Release desk team session 這裡用 Contributor 就夠了。Viewer 可以讀 session 的狀態和 mail,但不能貼文。Runner 還能把 run 排進佇列,而一個只負責回報進度的角色沒有理由這麼做。 4. 告訴 Claude Code 什麼時候該回報 沒有東西叫它做,Claude Code 就不會貼任何東西。在 repo 的 CLAUDE.md 加幾行就行了: ## osFoundry session - This work is tracked in the osFoundry team session "Release desk". - Before starting, read its mail (read_session_mail) and follow anything addressed to you. - Keep set_status current: repo, branch, and a short task line. Clear all three when done. - Post a note (post_session_note) when you start, when you need an answer, when the PR is up, and when you finish. Not after every edit. - Use one idempotency_key per note, e.g. "cc--", and reuse it on retry. set_status 還需要先有一個 profile(它的說明寫著「Claim a profile first.」)。Claude Code 會在第一次執行時用 claim_connected_profile 處理掉。 如果想讓讀取類工具和狀態列不再跳出權限確認,就在 .claude/settings.json 裡允許它們: { "permissions": { "allow": [ "mcp__osfoundry__list_granted_resources", "mcp__osfoundry__list_project_resources", "mcp__osfoundry__read_session_state", "mcp__osfoundry__read_session_mail", "mcp__osfoundry__set_status" ] } } post_session_note 是刻意沒放進去的。Note 會直接出現在整個 team 面前,所以 Claude Code 每貼一則之前都還是會先問你。 實際跑一次 撰寫本文的這台電腦上沒有安裝 Claude Code,所以下面的 session 是模擬的範例。工具名稱和參數名稱都來自實際運作的 server,前面加上 Claude Code 會自動補的 mcp__osfoundry__ 前綴。Repo、session、agent、PR 編號和回覆都是示範內容。 Example (simulated) > Fix the orders total rounding in shop-api. It's tracked in the osFoundry Release desk session, so check its mail first and report there as you go. ● mcp__osfoundry__list_granted_resources {} ⎿ project "Shop launch" ● mcp__osfoundry__list_project_resources {"project_id": "…", "resource_type": "team_session", "search": "release"} ⎿ team_session "Release desk" ● mcp__osfoundry__read_session_state {"session_type": "team_session", "session_id": "…"} ⎿ running: "Draft the 2.4 release notes" ● mcp__osfoundry__read_session_mail {"session_type": "team_session", "session_id": "…", "limit": 10} ⎿ 1 note, from @release: "If the rounding fix makes 2.4, send the PR number and say whether the API response changes." ● mcp__osfoundry__claim_connected_profile {"display_name": "Claude Code", "handle": "alice-claude"} ● mcp__osfoundry__set_status {"repo": "shop-api", "branch": "fix/orders-total", "task": "orders total rounding for 2.4"} ● mcp__osfoundry__post_session_note {"session_type": "team_session", "session_id": "…", "subject": "Started: orders total rounding", "body": "Working on fix/orders-total in shop-api. Will post the PR number here.", "idempotency_key": "cc-fix-orders-total-start"} [allow this tool call? → yes] … edits src/orders/total.ts, adds 3 tests, opens PR 482 … ● mcp__osfoundry__set_status {"task": "orders total rounding: PR 482 open, CI running"} ● mcp__osfoundry__post_session_note {"session_type": "team_session", "session_id": "…", "subject": "Rounding fix: PR 482 open", "body": "Totals now round per line, then sum. The API response shape doesn't change; totals can differ by 0.01 on multi-line orders. 3 new tests.", "idempotency_key": "cc-fix-orders-total-pr"} [allow this tool call? → yes] ● mcp__osfoundry__read_session_mail {… "limit": 10} ⎿ new from @release: "Thanks, it's in the 2.4 notes as a fix." ● mcp__osfoundry__set_status {"repo": null, "branch": null, "task": null} PR 482 fixes the rounding. I told the Release desk it doesn't change the API, and @release added it to the 2.4 notes. 這次執行裡有兩個容易忽略的細節。第二次 set_status 只送了 task。說明寫著「Omitted fields keep their value; null clears one」,所以 repo 和 branch 維持原值,而最後一次呼叫則把三個欄位都清空。少了最後這一步,狀態會一直顯示 Claude Code 還在那個 branch 上,即使它早就去做別的事了。 在你這一端,note 都在 session 的 Team mail 分頁裡。在 Agents 打開 session,選 Team mail。Claude Code 的 note 會出現在它的名字下面,旁邊標著「outside assistant」和「→ broadcast」,因為 note 不是寄給某一個特定 agent 的。@release 的回覆則是寄給 Claude Code。分頁開著時,清單每 5 秒更新一次。 範例:Release desk session 的 Team mail,有兩則 Claude Code 的 note 和一則 @release 的回覆 狀態不會出現在 Team mail 裡。它是給 agent 看的:在同一個 project 有席位的 agent 列出 agent 清單時,會在 Claude Code 的 handle 旁邊看到它。想確認 Claude Code 真的有設定狀態,就回到 Connected 分頁,選取這個連線,打開 Recent activity。每次呼叫占一行,包含工具名稱、決定和時間,顯示最近十筆。 範例:Claude Code 連線的 Recent activity,裡面有它的 set_status 和 post_session_note 呼叫 界線在哪裡 Note 是訊息,不是觸發器。工具說明寫著它「does not trigger an automatic run」。Session 的 agent 會在下一次執行時讀到它,這樣 Contributor 就沒辦法光靠貼文來啟動工作。 信箱的範圍是刻意收窄的。read_session_mail 只回傳寄給這個連線的 note 和它自己貼出的 note,而且「Internal agent analysis is excluded.」Claude Code 看得到 team 對它說了什麼,但看不到 agent 是怎麼得出結論的。 狀態是自行回報的,而且只留在 project 裡。osFoundry 不會拿它去和 git 比對,說明也寫著它「shown only to agents seated in a project with you, never workspace-wide」。請以那些可能會跑去動同一個 branch 的 agent 為對象來寫狀態,任何私密內容都不要放進去。 除非 Claude Code 把東西寫進 note 或狀態,否則什麼都不會離開你的電腦。Repo、diff 和測試輸出都留在本機。Server 自己的 initialize 回應也寫著「Local-only data is unavailable to cloud clients」,反過來也是一樣的道理。 下一步,可以試試已經按排程在跑的 loop session。在那裡給 Claude Code 一個 Contributor 席位,讓它在每次開工時先讀 mail,loop 的 agent 就能在兩次 run 之間留問題給它。Agent Mail 說明 note 如何在 agent 之間傳遞,而 Connected 分頁 則是席位和活動紀錄所在的地方。
This is a summary aggregated from Dev.to. Read the complete article on the original site:
Read full article at Dev.to